pdftk and cat command

PBMY_Vincent
Newbie
Posts: 6
Joined: Thu Aug 16, 2012 11:49 am

Re: pdftk and cat command

Post by PBMY_Vincent »

Deo gratias freddyp in quotes tips. has adiecit mores effugium :mrgreen:

Thanks freddyp on the quotes tips. has added escape character :D

i've also added PDFtk to the windows environment variables

Code: Select all

function jobArrived( s : Switch, job : Job )
{
	//pdftk A=fronts.pdf B=back_x1500.pdf shuffle A B output print_job.pdf
	var jobFolder = job.createPathWithName(job.getNameProper(), true);	
	var pdfFilename = jobFolder + "/" + job.getNameProper() + ".pdf";
	var fronts = '\"C:\\SwitchTemplate\\PCFrontV01.pdf\"';
	var backs = job.getPath();
	var AA = "A="+fronts;
	var BB = "B="+"\""+backs+"\"";
	var CC = "\""+pdfFilename+"\"";
	
	command = "pdftk"+" "+AA+" "+BB+" shuffle A B"+" output"+" "+CC;
	var exitCode = Process.execute(command);
	s.log(2, Process.stderr);
	s.log(1, command);
	s.log(1, exitCode);
}
Still no luck though, exit code = 1 and PDFtk complain it can't find the file :
Error: Unable to find file. Error: Failed to open PDF file: "C:\SwitchTemplate\PCFrontV01.pdf" Error: Unable to find file. Error: Failed to open PDF file: "C:/Users/ADMINI~1/AppData/Local/Temp/2/FixtureTest01/inFolder2/_00001_playingCardBack_v01-X56.pdf" Errors encountered. No output created. Done. Input errors, so no output created.
When running the command at cmd prompt, it only works when output destination is changed to location outside of AppData eg: "c:\output3.pdf"
pdftk A="C:\SwitchTemplate\PCFrontV01.pdf" B="C:/Users/ADMINI~1/AppData/Local/Temp/2/FixtureTest01/inFolder2/_00001_playingCardBack_v01-X56.pdf" shuffle A B output "C:/Users/Administrator/AppData/Roaming/Enfocus/SwitchScripter/temp/1/ScriptElement/1/13/playingCardBack_v01-X56/playingCardBack_v01-X56.pdf"
Thanks jan_suhr

Now i need to figure out how to execute the *.bat file

Btw, dkelly i reckon PDFtk doesn't like the "'," the array added in between and i has revert back to building the command string.
jan_suhr
Advanced member
Posts: 586
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: pdftk and cat command

Post by jan_suhr »

You run the .bat in the Execute Command as the Command or Path property. In argument you just put "%1" "%2"
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
PBMY_Vincent
Newbie
Posts: 6
Joined: Thu Aug 16, 2012 11:49 am

Re: pdftk and cat command

Post by PBMY_Vincent »

Many thanks jan_suhr now it work just like magic!

The *.bat file i use for PDFtk Shuffle command :

Code: Select all

set inputfile=%1
set outfile=%2
pdftk.exe A="C:\SwitchTemplate\PCFrontV01.pdf" B=%inputfile%  shuffle A B output %outfile%
The 'Execute Command' Settings :

Code: Select all

Name | PDFtk Shuffle BAT
Description | A B PDF Shuffle Insert -  A is generic, B is Variable Design  
Execution mode | Concurrent
Command or path | D:/Switch-Resource/PDFtk-Shuffe-PlayingCards-v01.bat
Arguments | "%1" "%2"
Output | File at path
Copy input job | Yes
Output extension | Automatic
Fail if exit code is | Nonzero
*PDFtk has added to Windows Environment Variable
sonmezroy
Newbie
Posts: 1
Joined: Mon Feb 21, 2022 9:32 am
Contact:

Re: pdftk and cat command

Post by sonmezroy »

Thanks for the answers, actually i was also searching for the same thing.
Post Reply