Steinic30
Steinic30

Reputation: 1

Issue while using function "CombineFiles" from FoxitPhantomPDF64-DLL in Excel

I wrote a program in VBA that first creates a PDF file and then allows you to combine it with other PDF files. To do this, I use the external library “FoxitPhantomPDF64.dll”, which can be found in the “Foxit PDF Editor” installation folder.

When I call the "CombineFiles" function, the Excel file regularly hangs and has to be closed - in other cases the program runs without errors.

Does anyone have an idea what it could be or what I misunderstood? Attached is a shortened version of the program, the reference to the library is of course included.

Public Sub CreateAndCombine()

   Dim fso As New Scripting.FileSystemObject
   Dim pco As New FoxitPhantomPDF.Creator
   Dim pathTemplate As String
   Dim pathCreated As String
   Dim pathCombined 
   Dim createdPDF As FoxitPhantomPDF.FoxitPDDoc

   Set createdPDF = New FoxitPhantomPDF.FoxitPDDoc   

   pathTemplate = fso.BuildPath(ThisWorkbook.Path, "My_Template.pdf")
   pathCreated = fso.BuildPath(ThisWorkbook.Path, "My_Copy.pdf")
   pathCombined = fso.BuildPath(ThisWorkbook.Path, "Combined.pdf")   

   Call createdPDF.Open(pathTemplate)

   Call createdPDF.Save(FoxitPhantomPDF.PDSaveFlags.PDSaveFull, pathCreated)

   Call createdPDF.Close 

   Call pco.CombineFiles(bstrFiles:=pathCreated & "|" & pathTemplate, DestPDFFile:=pathCombined, uCombineFlags:=FoxitPhantomPDF.CombineFlags.COMBINE_DEFAULT)

End Sub

The strange thing is that it usually freezes on the first few attempts and then works - as if the software had to "warm up" first. I also noticed that the combined file was created and can be opened, but the program is still stuck in the "CombineFiles" function.

Upvotes: 0

Views: 59

Answers (0)

Related Questions