Code with C | Programming: Projects & Source Codes › Forums › Visual Basic Classic › How to split a PDF into parts using visual basic 2013
September 16, 2015 at 12:17 pm #7746
How to split a PDF into parts using visual basic 2013
September 16, 2015 at 12:18 pm #7747
The easiest way, imo, would be to call the PDFtk Server from your VB code. The PDF Toolkit (PDFtk) is an excellent (free!) product that has numerous features to manipulate PDFs. It comes in both command line and GUI versions. The command line version is called PDFtk Server and may be downloaded here:
Don’t be misled by “Server” in the name. I don’t know why they called it that, but it’s just an executable (pdftk.exe, with a supporting DLL, libiconv2.dll) that runs on XP, Vista, W7, and W8 (I tested it on W10 Pro 64-bit and it worked fine, but I don’t think it is officially certified yet for W10). That is, it does not have to run on a “server” OS.
The operation to split a PDF into separate pages is called burst. You may learn about it here:
> our App needs separate pages
So here’s the one-line command to split your large PDF into separate pages:
pdftk in.pdf burst
By default, the separate pages will be named pg_xxxx.pdf (where xxxx is the page number, such as pg_0001, pg_0002, etc.). If you prefer to create different file names, use the output option, such as:
pdftk in.pdf burst output separate%02d.pdf
That will create files called separate01.pdf, separate02.pdf, etc.
The burst operation also creates a file called doc_data.txt that contains a lot of metadata from the source file. The content of the file is described in the dump_data operation:
You must be logged in to reply to this topic.