본문 바로가기

프로그래밍/Delphi

Acrobat DDE : DocSaveAs 사용예 - VB예제

원본 : http://acrobat-dde.nnn2.com/?p=36

PDF파일을 읽고 페이지 삽입 또는 삭제 작업 처리후 다른 파일로 재저장 하기 위한 용도

Acrobat/DDE:DocSaveAs

Specified PDF file is preserved by the alias naming the name. Preservation to PDF file on the same name comes. When preserving it, the optimization of PDF file (reduction of the size) is done.
It doesn’t operate in Acrobat Reader.

Syntax

 [DocSaveAs(char* fullPath, char* newPath)]

Argument

fullPath
[char*]
The full path in updated PDF file. It is necessary already to be opened by the Acrobat application.
newPath
[char*]
The Full path in the new PDF file.

Returns

true The pages are saved successfully.
false Otherwise.


 Notes: The return value cannot be acquired with DDE of VBA of Excel.

Sample: VBA of Excel

Specified PDF file is preserved and the name is preserved by the alias putting it.

・Please confirm the test by the step execution with F8 key.

Sub DDE_DocSaveAs()
    
Dim lChanNo     As Long ‘DDE channel number
    Const CON_PDF_PATH = “”"E:\Test01.pdf”"”
    
    
‘The Acrobat application is Started.
    Shell “C:\Program Files\Adobe\Acrobat 9.0\Acrobat\Acrobat.exe”
    ‘Open of DDE channel
    lChanNo = DDEInitiate(“Acroview”“Control”)

    ‘Open of PDF file
    DDEExecute lChanNo, “[DocOpen(" & CON_PDF_PATH & ")]“
    ‘Deletion of page (deletion of 2, 3, and page 4)
    DDEExecute lChanNo, “[DocDeletePages(" & CON_PDF_PATH & ",1,3)]“
    ‘Saves an the PDF file to a new path.。
    DDEExecute lChanNo, “[DocSaveAs(" & _
        CON_PDF_PATH & 
"," & """E:\Test02A.pdf""" & ")]“

    ‘The Acrobat applicaton is ended..
    DDEExecute lChanNo, “[AppExit()]“ ‘If this is not done, the Acrobat process remains.
    ‘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

DocSave(Before) DocSave(After)
 
 
Remarks

・It doesn’t operate in Acrobat Reader.
・The difference with DocSave is two points. The alias can be preserved. It is optimized.


Environment to confirm the operation

・WindowsXP + SP3 + WindowsUpdate
・Adobe Acrobat Pro 7.0.8 + Office Pro 2003
・Adobe Acrobat Pro 9.1.0 + Office Pro 2003