Author Topic: PDF file splitter  (Read 180 times)

MW4

  • Full Member
  • ***
  • Posts: 174
PDF file splitter
« on: February 04, 2020, 11:43:05 am »
I thought there was a good PDF file splitter in the Tech Database, but I can't seem to find it.

I just want to extract every page in a pdf to a separate file.

1-3.PDF
into
1.pdf
2.pdf
3.pdf

A point in the right direction would be greatly appreciated!

Thanks!

td

  • Tech Support
  • *****
  • Posts: 3210
    • WinBatch
Re: PDF file splitter
« Reply #1 on: February 04, 2020, 01:18:04 pm »
You may not have found a cut&paste example in the Tech Database but there are multiple pdf related examples in there.  If you spend some time looking at those, you may be able to develop a script.   Otherwise, you could perform a Web search for .Net assemblies that could be called from WinBatch.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

  • Tech Support
  • *****
  • Posts: 3210
    • WinBatch
Re: PDF file splitter
« Reply #2 on: February 04, 2020, 05:29:43 pm »
Just a random thought and have never tried it but MS Word can load and save pdf documents.  Perhaps you could use it to split up your document into single page documents. Word has an extensive COM Automation programming model that can be used with WinBatch.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl

  • Pundit
  • *****
  • Posts: 998
Re: PDF file splitter
« Reply #3 on: February 05, 2020, 02:57:24 am »
Below is vba code, but should be convertible to WB
Code: Winbatch

Dim PDDoc As Acrobat.CAcroPDDoc, newPDF As Acrobat.CAcroPDDoc
Dim PDPage As Acrobat.CAcroPDPage
Dim thePDF as String, PNum as Long


Set PDDoc = CreateObject("AcroExch.pdDoc")
Result = PDDoc.Open(thePDF)
If Not Result Then
   MsgBox "Can't open file: " & FileName
   Exit Sub
End If


PNum = PDDoc.GetNumPages


For i = 0 To PNum - 1
    Set newPDF = CreateObject("AcroExch.pdDoc")
    newPDF.Create
    NewName = "Page_" & i "_of_" & PNum & ".pdf"
    newPDF.InsertPages -1, PDDoc, i, 1, 0
    newPDF.Save 1, NewName
    newPDF.Close
    Set newPDF = Nothing
Next i
 


td

  • Tech Support
  • *****
  • Posts: 3210
    • WinBatch
Re: PDF file splitter
« Reply #4 on: February 05, 2020, 07:07:33 am »
I was under the impression that ADOBE or whomever no longer supported the "AcroExch.pdDoc" COM Automation object - at least without paying them some $- but I could very easily be wrong.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

  • Tech Support
  • *****
  • Posts: 3210
    • WinBatch
Re: PDF file splitter
« Reply #5 on: February 05, 2020, 07:20:37 am »
PDFsharp is an open-source pdf library for C#.  It can be found here http://www.pdfsharp.net/.  I haven't used it but it does say it can be used to split PDF documents.  Might be worth a look.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

billfrog

  • Newbie
  • *
  • Posts: 6
Re: PDF file splitter
« Reply #6 on: February 06, 2020, 09:53:59 am »
You could avoid Winbatch altogether and download something like PDFtk...
Not sure if the free version can do what you want, but the paid version can do it from the command line.

https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/