The page specified with the PDF document is deleted. The demand of deleting all pages with the document is disregarded because there should be at least page 1 in the PDF document.
It doesn’t operate in Acrobat Reader.
Syntax
[DocDeletePages(char* fullPath, long fromPage, long toPage)]
Argument
fullPath [char*] |
The full path of PDF document |
fromPage [long] |
The page number of the first page to be deleted. It begins from 0. |
toPage [long] |
The page number of the last page to be deleted. It begins from 0. |
Returns
true | The pages are deleted successfully. |
false | Otherwise. |
Sample: VBA of Excel
The PDF document from page 2 to page 4 is deleted.
- Please confirm the test by the step execution with F8 key.
Sub DDE_DocDeletePages()
Dim lChanNo As Long ‘DDE channel number
‘A double quotation mark is added for blank starting full path.
Const CON_PDF_PATH = “””E:\Test01.pdf”””
‘The Acrobatapplication is Started.
‘Shell “C:\Program Files\Adobe\Acrobat 7.0\Acrobat\Acrobat.exe”
‘Shell “C:\Program Files\Adobe\Acrobat 9.0\Acrobat\Acrobat.exe”
Shell “C:\Program Files\Adobe\Acrobat 8.0\Acrobat\Acrobat.exe”
‘Open of DDE channel
lChanNo = DDEInitiate(“Acroview”, “Control”)
‘Open of PDF file
DDEExecute lChanNo, “[DocOpen(” & CON_PDF_PATH & “)]”
‘The page is deleted (deletion of 2, 3, and page 4).
DDEExecute lChanNo, “[DocDeletePages(” & CON_PDF_PATH & “,1,3)]”
‘Saving of PDF file. Note) Optimization is not done.
DDEExecute lChanNo, “[DocSave(” & CON_PDF_PATH & “)]”
‘The Acrobat applicaton is ended..
‘If this is not done, the Acrobat process remains.
DDEExecute lChanNo, “[AppHide()]”
‘The DDE channel is shut.
DDETerminate lChanNo
End Sub
Execution result
It is a result of the comparison on page thumbnail screen of Acrobat.
Deletion of page (deletion of 2, 3, and page 4).
Before |
After |
DocDeletePage(Before) |
DocDeletePage(After) |
Remarks
- The number of the second arguments begins from 0. The first page is specified by 0.
- If PDF file doesn’t open, False is returned by the return value. And, the method is disregarded.
- False is returned by the return value when demanding of deleting all pages. And, the method is disregarded.
- It doesn’t operate in Acrobat Reader.
Environment to confirm the operation
- WindowsXP + SP3 + WindowsUpdate
- Adobe Acrobat Pro 7.0.8 + Office Pro 2003
- Adobe Acrobat Pro 8.1.4 + Office Pro 2003
- Adobe Acrobat Pro 9.1.0 + Office Pro 2003