Incorrect output path and file name of PDF file.

Community Beginner ,
Mar 06, 2019 Mar 06, 2019

Copy link to clipboard

Copied

The FileToPDF() method which is an API of Acrobat Distiller may not work properly. The FileToPDF() method is executed by VBA script of Microsoft Excel, and the source code is as follows.

----------VBA script start----------

Option Explicit

Const m_strDistillerProgID = "pdfdistiller.pdfdistiller.1"

Sub Button1_Click()
    CreatePDF2 ActiveSheet.Range("D2").Value, ActiveSheet.Range("D3").Value
End Sub

Function CreatePDF2(szPSFilePath As String, strFullPathOfPDFFile As String) As Boolean
    Dim DistillerObj As Object
    ActiveSheet.PrintOut copies:=1, PrToFileName:=szPSFilePath
    Set DistillerObj = CreateObject(m_strDistillerProgID)
    DistillerObj.FileToPDF szPSFilePath, strFullPathOfPDFFile, ""
    Set DistillerObj = Nothing
End Function

----------VBA script end----------

Usually, the PDF file is created in the path in strFullPathOfPDFFile. (expected behavior)

However, if the VBA script is executed while printing another file with Adobe PDF, the PDF file is created in the path (including file name) of another file being printed. (unexpected behavior)

Would you teach me the cause and hot to deal with it?

Note:

When the PDF file is created in incorrect path, the Post Script file was created in correct path.

I confirmed this problem in Adobe Acrobat Pro DC (version 2015.006.30033) and 2017 (version 2017.011.30078).

Thank you for your consideration.

TOPICS
Acrobat SDK and JavaScript

Views

461

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Most Valuable Participant ,
Mar 07, 2019 Mar 07, 2019

Copy link to clipboard

Copied

No part of the Acrobat SDK supports multi threading or multiple invocations. I believe this is noted in the Developer FAQ. You must not try to print two things at a time to PDF. Serialise.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 07, 2019 Mar 07, 2019

Copy link to clipboard

Copied

Thank you for your reply.
I want to make an application which creates PDF automatically at an arbitrary timing.
Is there any way to prevent conflict by coding or setting?

The following is another question.
Some application have similar problems without conflicting.

e.g.
Application A creates PDF and completes normally.
After that application B creates PDF but PDF is created with the path and name which are set for application A.

Do you know the cause?(e.g. some process is insufficient for application A.)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Most Valuable Participant ,
Mar 08, 2019 Mar 08, 2019

Copy link to clipboard

Copied

Serialize. If serialization not possible, forbid simultaneous execution. This is not for use in automated worlds.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 10, 2019 Mar 10, 2019

Copy link to clipboard

Copied

LATEST

I see that simultaneous execution is prohibited.

Do you know the cause of another problem?

Even if two applications are executed one by one, the same problem may occur.

Is there any insufficiency in the application executed first? (This application was developed by us.)

Or is there any way to avoid it in the application executed later?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines