Deleting pages from PDF file through Acrobat automation
Detailed info on Acrobat automation can be found in Interapplication Communication API Reference
from Acrobat 8.1 SDK or Acrobat 9.0 SDK at http://www.adobe.com/devnet/acrobat/?navID=downloads. Free registration may be required.
This is sample code. Add error handling and adjust to your requirements as necessary. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 #DEFINE PDSaveFull 1 && Write the entire file. * Original PDF file lcPdfFile = "..." * new PDF file with specified pages deleted lcNewPdfFile = "..." * Delete 3 pages starting with page 5 lnPage2DelStart = 5 lnPage2DelEnd = lnPage2DelStart + 3 * Acrobat application loAcroApp = CREATEOBJECT("AcroExch.App") *loAcroApp.Show() * A view of a PDF document in a window loAVDoc = CREATEOBJECT("AcroExch.AVDoc") IF loAVDoc.Open(lcPdfFile, "PDF") == 0 * Error, cannot open the file * Do something ... ENDIF * The underlying PDF representation of a document loPDDoc = loAVDoc.GetPDDoc() * Delete specified pages. The page numbers are zero based IF loPDDoc.DeletePages(lnPage2DelStart-1, lnPage2DelEnd-1) == 0 * Error, cannot delete pages * Do something ... ENDIF * Save to new PDF file and close loPDDoc.Save(PDSaveFull, lcNewPdfFile) && PDF document loPDDoc.Close() * Close PDF view w/o prompt to save loAVDoc.Close(.T.) * Close Acrobat. loAcroApp.Exit()
Comments
pdf automation with Foxpro
I would like to use FoxPro Automation to convert an 8.5x11 3 page pdf into a 4 page 11x17 pdf so we can laser print properly.
Anyone take pity and share some of that wonderful knowledge? I can provide samples and much more info if anyone would like to help.
My email is cburkhart@ricklanddirect.com
Thanks very much.... stay Foxy !