Skip to main content
March 7, 2019
Question

Incorrect output path and file name of PDF file.

  • March 7, 2019
  • 1 reply
  • 1105 views

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.

This topic has been closed for replies.

1 reply

Legend
March 7, 2019

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.

March 8, 2019

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.)

Legend
March 8, 2019

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