CPDF -

Post Reply
Clive Andrews
Member
Posts: 85
Joined: Thu Jun 23, 2011 11:41 am

CPDF -

Post by Clive Andrews »

Can anyone help with one issue I have with CPDF….



I have a variable in my XML called “Imprint” – which reflects where the imprint of the book is. I’m trying to use CPDF to extract just this imprint with:

“%1” [Metadata.Integer:Path=”/jobInfo/Imprint”,Dataset=”Xml”,Model=”XML”] –o “%2”



I’m extracting the info, but I think I must have the wrong syntax – as I’m getting no output – can you see where I am going wrong – or how I might get an exit/error code to tell me why I have no file…?



Thanks!
dkelly
TOP CONTRIBUTOR
Posts: 658
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

CPDF -

Post by dkelly »

Clive, here's how I call an external application.



var String args = new Array();

var appPath = s.getSpecialFolderPath("PluginResources") + "/" + "ftpdel.pl"

args[0] = appPath;

args[1] = theServer;

args[2] = thePath;

args[3] = job.getName();



var myProc = new Process(args);

myProc.start();

myProc.waitForFinished(60);

if (myProc.exitStatus != 0) {

job.log(cLogError, "FTPdel: delete failed");

}

Clive Andrews
Member
Posts: 85
Joined: Thu Jun 23, 2011 11:41 am

CPDF -

Post by Clive Andrews »

dkelly wrote: Clive, here's how I call an external application.



var String args = new Array();

var appPath = s.getSpecialFolderPath("PluginResources") + "/" + "ftpdel.pl"

args[0] = appPath;

args[1] = theServer;

args[2] = thePath;

args[3] = job.getName();



var myProc = new Process(args);

myProc.start();

myProc.waitForFinished(60);

if (myProc.exitStatus != 0) {

job.log(cLogError, "FTPdel: delete failed");

}




Thanks Dwight - but here's where I show my ignorance - how do i get that code in, with the CPDF variables...?
paulsanter
Newbie
Posts: 1
Joined: Sun Nov 27, 2011 5:20 pm

CPDF -

Post by paulsanter »

Hi Clive, I'm not sure what you are trying to do with the "imprint" information but below is an example of the syntax I use in switch with CPDF to add a blank page and insert some variables into the blank page. Hope it helps.



-pad-after "%1" AND -add-text "[Stats.PageWidth] n[Stats.PageHeight] n[Stats.Colorants] n[Stats.ColorMode] n[Stats.Fonts] n[Switch.OutgoingName] n[Stats.ColorSpaceFamilies]" -range 2 -o "%2"
Clive Andrews
Member
Posts: 85
Joined: Thu Jun 23, 2011 11:41 am

CPDF -

Post by Clive Andrews »

Hmm, this is "doing my head in" - I can launch CPDF from a command prompt - and all is fine. Using some sample flows I had from Bert - all is fine. I can write text onto a PDF by CPDF - all is fine...



...but when I try the code at the start of the thread - even substituting manual variables, all I get is:



File '_311Q9_Bronner.pdf' was sent to null; it will be deleted when the entry point finishes



It's driving me up the wall - grrr



*angry face
dkelly
TOP CONTRIBUTOR
Posts: 658
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

CPDF -

Post by dkelly »



var value = job.getVariableAsString("Metadata.Integer:Path=”/jobInfo/Imprint”,Dataset=”Xml”,Model=”XML”");



var String args = new Array();

args[0] = "/opt/local/bin/CPDF";

args[1] = inputPath;

args[2] = value;

args[3] = outputPath;



var myProc = new Process(args);

myProc.start();

myProc.waitForFinished(60);

if (myProc.exitStatus != 0) {

job.log(cLogError, "CPDF failed: " + myProc.exitStatus);

}

Clive Andrews
Member
Posts: 85
Joined: Thu Jun 23, 2011 11:41 am

CPDF -

Post by Clive Andrews »

dkelly wrote:

var value = job.getVariableAsString("Metadata.Integer:Path=”/jobInfo/Imprint”,Dataset=”Xml”,Model=”XML”");



var String args = new Array();

args[0] = "/opt/local/bin/CPDF";

args[1] = inputPath;

args[2] = value;

args[3] = outputPath;



var myProc = new Process(args);

myProc.start();

myProc.waitForFinished(60);

if (myProc.exitStatus != 0) {

job.log(cLogError, "CPDF failed: " + myProc.exitStatus);

}




You're going to get very fed up with me Dwight - I am still failing to see how i write this into a script element. I launch the scripter, and paste it between:



// Is invoked each time a new job arrives in one of the input folders for the flow element.

// The newly arrived job is passed as the second parameter.

function jobArrived( s : Switch, job : Job )

{





and



}



giving:

// Is invoked each time a new job arrives in one of the input folders for the flow element.

// The newly arrived job is passed as the second parameter.

function jobArrived( s : Switch, job : Job )

{

var String args = new Array();

args[0] = "/opt/local/bin/CPDF";

args[1] = inputPath;

args[2] = value;

args[3] = outputPath;



var myProc = new Process(args);

myProc.start();

myProc.waitForFinished(60);

if (myProc.exitStatus != 0) {

job.log(cLogError, "CPDF failed: " + myProc.exitStatus);

}

}



...but I can't save this as a script...



I know I am missing something really basic here - but alas, I'm no programmer - I could get by in Basic, and understand most of the principles - once I can get my head round my problem I'm sure I'll fall into a scripting frenzy...
dkelly
TOP CONTRIBUTOR
Posts: 658
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

CPDF -

Post by dkelly »



function jobArrived( s : Switch, job : Job )

{

var outputPath = job.createPathWithName(job.getName(), false);

var value = job.getVariableAsString("[Metadata.Integer:Path='/jobInfo/Imprint',Dataset='Xml',Model='XML']");



var String args = new Array();

args[0] = "/opt/local/bin/CPDF";

args[1] = job.getPath();

args[2] = value;

args[3] = outputPath;



var myProc = new Process(args);

myProc.start();

myProc.waitForFinished(60);

if (myProc.exitStatus == 0) {

job.sendToSingle(outputPath);

return;

}

job.fail("CPDF failed!");

}



Clive Andrews
Member
Posts: 85
Joined: Thu Jun 23, 2011 11:41 am

CPDF -

Post by Clive Andrews »

Thanks Dwight,



I just had to change the path (as CPDF is running on a PC Switch), and add the "-o" output as another argument - and it's working, yay, happy days etc...



function jobArrived( s : Switch, job : Job )

{

var outputPath = job.createPathWithName(job.getName(), false);

var value = job.getVariableAsString("[Metadata.Integer:Path='/jobInfo/Imprint',Dataset='Xml',Model='XML']");

var ouput = "-o"



var String args = new Array();

args[0] = "cpdf.exe";

args[1] = job.getPath();

args[2] = value;

args[3] = ouput;

args[4] = outputPath;



var myProc = new Process(args);

myProc.start();

myProc.waitForFinished(60);

if (myProc.exitStatus == 0) {

job.sendToSingle(outputPath);

return;

}

job.fail("CPDF failed Clivey!");

}

}



Thanks for all your help my friend!
dkelly
TOP CONTRIBUTOR
Posts: 658
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

CPDF -

Post by dkelly »

you don't need to define a variable for the "-o" argument, just use



args[3] = "-o";
Clive Andrews
Member
Posts: 85
Joined: Thu Jun 23, 2011 11:41 am

CPDF -

Post by Clive Andrews »

dkelly wrote: you don't need to define a variable for the "-o" argument, just use



args[3] = "-o";




Yes - I see that now, I'd put it in, but without the quotes, and when it didn't work thought I had to use it as a variable like the rest....



Post Reply