Breaking PDF into smaller PDFs

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Breaking PDF into smaller PDFs

askoh
Administrator
Using Smalltalk, I would like to break a PDF with 500 pages into 500 PDFs of one page each.
 
How can I do that?

Thanks,
Aik-Siong Koh
Reply | Threaded
Open this post in threaded view
|

Re: Breaking PDF into smaller PDFs

Joachim Geidel
A simple solution would be to install Ghostscript and use its command line
interface from Smalltalk. Ghostscript can process PDF files and write
one-file-per-page output, see
http://www.ghostscript.com/doc/9.06/Use.htm#One_page_per_file.

PDFsam might be an alternative, but it needs a Java Runtime Environment:
http://www.pdfsam.org/?page_id=42

HTH,

Joachim Geidel

Am 14.11.12 18:20 schrieb "askoh" unter <[hidden email]>:

>Using Smalltalk, I would like to break a PDF with 500 pages into 500 PDFs
>of
>one page each.
>
>How can I do that?
>
>Thanks,
>Aik-Siong Koh


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Breaking PDF into smaller PDFs

Holger Kleinsorgen
In reply to this post by askoh
Alternative solution:
Load Christian Haider's PDF library from the public Store repository.
Then implement something like that:

| inputStream inputPDF pageNumber |
inputStream := 'ReleaseNotes7.7.pdf' asFilename readStream binary.
[
        inputPDF := PDF.File readFrom: inputStream.
        pageNumber := 1.
        inputPDF trailer Root pagesDo: [ : page |
                | targetFilename onePageDocument |
                onePageDocument := PDF.Document new.
                onePageDocument root addPage: page.
                targetFilename := (pageNumber printString, '.pdf') asFilename.
                onePageDocument saveAs: targetFilename.
                pageNumber := pageNumber + 1.
        ].
] ensure: [ inputStream close ].
Reply | Threaded
Open this post in threaded view
|

Re: Breaking PDF into smaller PDFs

askoh
Administrator
Holger:

Thanks you very much for your help. The code helped perfectly.

My PDF has a bad reference and caused an exception. Christian Haider helped debug most promptly and graciously.

Thanks for all the help in the forum.

Aik-Siong Koh