I have a need to delete every 3rd-6th page of a pdf.
So if it is six pages to start it will end as a two pager (1&2), and if it is 18 pages, end up as a six pager ( 1 & 2, 7 & 8, 13 & 14 ), PDF could be any length of 6x
My question is two pronged...
1. setting a control structure to set what pages to delete
2. how to delete the pages in the pdf itself.
Any direction would be greatly appreciated.
Perhaps start in the Tech Support Database. There are multiple pdf related tasks. Here is but one:
http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/OLE~COM~ADO~CDO~ADSI~LDAP/OLE~with~Acrobat~Viewer+Append~Two~PDF~Files~Together.txt (http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/OLE~COM~ADO~CDO~ADSI~LDAP/OLE~with~Acrobat~Viewer+Append~Two~PDF~Files~Together.txt)
Yeah, I saw that before posting, but couldn't get it working for my use.
I wanted to see if someone else had already gone down this road before I started a trial and error...mostly error process. :)
You are not alone. It kinda goes with the writing-software territory.
This works fine...a bit clunky but it works.
adobe = ObjectCreate("AcroExch.app") ; create an application object
PDF = ObjectCreate("AcroExch.pdDoc")
PDFFileName = "Y:\Data\Test\PDFS\a.pdf"
t1 = PDF.open(PDFFileName)
PDF_NumPages = PDF.GetNumPages()
message("pages",PDF_NumPages)
if PDF_NumPages == 6
t1 = PDF.DeletePages (2,5) ;Delete Pages 3 to 6 (index starts at 0)
t1 = PDF.save(1,"Y:\Data\Test\PDFS\a.pdf")
endif
if PDF_NumPages == 12
t1 = PDF.DeletePages (2,5) ;Delete Pages 3 to 6 (index starts at 0)
t1 = PDF.save(1,"Y:\Data\Test\PDFS\a.pdf")
t1 = PDF.DeletePages (4,7) ;Delete Pages 5 to 8 (index starts at 0)
t1 = PDF.save(1,"Y:\Data\Test\PDFS\a.pdf")
endif
if PDF_NumPages == 18
t1 = PDF.DeletePages (2,5) ;Delete Pages 3 to 6 (index starts at 0)
t1 = PDF.save(1,"Y:\Data\Test\PDFS\a.pdf")
t1 = PDF.DeletePages (4,7) ;Delete Pages 5 to 8 (index starts at 0)
t1 = PDF.save(1,"Y:\Data\Test\PDFS\a.pdf")
t1 = PDF.DeletePages (6,9) ;Delete Pages 7 to 10 (index starts at 0)
t1 = PDF.save(1,"Y:\Data\Test\PDFS\a.pdf")
endif
PDF.close
adobe.exit; exit the application
adobe = "" ; close the application object
FirstPDF = "" ; close the application object