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. |
#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()
Recent comments
1 week 22 hours ago
1 week 22 hours ago
1 week 1 day ago
1 week 1 day ago
1 week 1 day ago
2 weeks 1 day ago
6 weeks 2 days ago
7 weeks 3 days ago
7 weeks 3 days ago
8 weeks 1 day ago