Jump to content

PDFTK Merge Command


Recommended Posts

Run("C:\Program Files\PDFTK Builder\pdftk.exe ""C:\asdf.pdf"" ""C:\qwer.pdf"" cat output ""C:\combined.pdf""")
Run("C:\Program Files\PDFTK Builder\pdftk.exe ""C:\*.pdf"" cat output ""C:\combined2.pdf""")

The first line works combining 2 pdf files into one, but the second one fails combining all pdf files into one. The examples at pdftk show that it should work.

Join in1.pdf and in2.pdf into a new PDF, out1.pdf
pdftk in1.pdf in2.pdf cat output out1.pdf
or (using handles):
pdftk A=in1.pdf B=in2.pdf cat A B output out1.pdf
or (using wildcards):
pdftk *.pdf cat output combined.pdf

Any thoughts?

Link to comment
Share on other sites

And like this ?

Run("C:\Program Files\PDFTK Builder\pdftk.exe C:\*.pdf cat output C:\combined2.pdf" )

Yes I did try that. The only thing that's changing is using a wildcard instead of listing the files. I'm trying to merge about 50 files so listing them is not really an option.

Link to comment
Share on other sites

Yes I did try that. The only thing that's changing is using a wildcard instead of listing the files.

I'm pretty sure one of those pdf files has an space in its name... anyway, I've just tried it in my computer and it is mergin all files.

Run('C:\Program Files\PDFTK Builder\pdftk.exe "C:\*.pdf" cat output C:\combined2.pdf')
Link to comment
Share on other sites

I'm pretty sure one of those pdf files has an space in its name... anyway, I've just tried it in my computer and it is mergin all files.

Run('C:\Program Files\PDFTK Builder\pdftk.exe "C:\*.pdf" cat output C:\combined2.pdf')

Ya no spaces. I did dumb it down to c:, but I did create those dummy files and it still doesn't work.
Link to comment
Share on other sites

Ya no spaces. I did dumb it down to c:, but I did create those dummy files and it still doesn't work.

Strange, I've used that command in my computer and that command merged all pdf files. Are you using Windows 7?, I ask because of you will need admin rights to write in C:\.

Link to comment
Share on other sites

Strange, I've used that command in my computer and that command merged all pdf files. Are you using Windows 7?, I ask because of you will need admin rights to write in C:\.

It is Windows 7, but calling each file separately works, it's just when I use the wildcard that it doesn't.

Link to comment
Share on other sites

It is Windows 7, but calling each file separately works, it's just when I use the wildcard that it doesn't.

Try like this :

#include <Constants.au3>

Global $_StderrRead, $_StdoutRead
; pdftk *.pdf cat output combined.pdf

$_PdftkExePath = @ProgramFilesDir & '\PDFTK Builder\pdftk.exe'
$_PdfInputFolderPath = 'C:'
$_PdfOutputPath = 'C:\combined2.pdf'

$_Run = '"' & $_PdftkExePath & '" ' & FileGetShortName ( $_PdfInputFolderPath ) & '\*.pdf cat output "' & $_PdfOutputPath & '"'
ConsoleWrite ( '$_Run : ' & $_Run & @Crlf )
$_Pid = Run ( $_Run, '', @SW_SHOW, $STDERR_CHILD + $STDOUT_CHILD )

While ProcessExists ( $_Pid )
    $_StderrRead = StderrRead ( $_Pid )
    If Not @error And $_StderrRead <> '' Then ConsoleWrite ( "STDERR read : " & $_StderrRead & @Crlf )
    $_StdoutRead = StdoutRead ( $_Pid )
    If Not @error And $_StdoutRead <> '' Then ConsoleWrite ( "STDOUT read : " & $_StdoutRead & @Crlf )
WEnd

If it doesn't work, you will see the error message ! Posted Image

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

Try like this :

#include <Constants.au3>

Global $_StderrRead, $_StdoutRead
; pdftk *.pdf cat output combined.pdf

$_PdftkExePath = @ProgramFilesDir & '\PDFTK Builder\pdftk.exe'
$_PdfInputFolderPath = 'C:'
$_PdfOutputPath = 'C:\combined2.pdf'

$_Run = '"' & $_PdftkExePath & '" ' & FileGetShortName ( $_PdfInputFolderPath ) & '\*.pdf cat output "' & $_PdfOutputPath & '"'
ConsoleWrite ( '$_Run : ' & $_Run & @Crlf )
$_Pid = Run ( $_Run, '', @SW_SHOW, $STDERR_CHILD + $STDOUT_CHILD )

While ProcessExists ( $_Pid )
    $_StderrRead = StderrRead ( $_Pid )
    If Not @error And $_StderrRead <> '' Then ConsoleWrite ( "STDERR read : " & $_StderrRead & @Crlf )
    $_StdoutRead = StdoutRead ( $_Pid )
    If Not @error And $_StdoutRead <> '' Then ConsoleWrite ( "STDOUT read : " & $_StdoutRead & @Crlf )
WEnd

If it doesn't work, you will see the error message ! Posted Image

That did it! Thanks! I have more ideas now for consolewrite.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...