Error with merging pdf files on terminal server


#1

Hi

I use the following code:


Dim outPath$
Dim folder As String
Dim PDFfilename As String

folder = "N:\Styringssystem\Database UDVIKLING\"    'CHANGE AS REQUIRED
If Right(folder, 1) <> "" Then folder = folder & ""
   
PDFfilename = Dir(folder & "*.pdf", vbNormal)
outPath = "n:\styringssystem\database udvikling\outputFile.pdf"

Dim oPDF As PDFCreator_COM.PdfCreatorObj
Set oPDF = New PDFCreator_COM.PdfCreatorObj

While Len(PDFfilename) <> 0
    filnavn = folder & PDFfilename
    oPDF.AddFileToQueue filnavn
    PDFfilename = Dir()  ' Get next matching file'
Wend

When I use it on a stand alone machine with the free version it works fine - when I use it on the terminal server I get a error on this line: oPDF.AddFileToQueue filnavn

The error is a run time error -2147024809 (80070057) with the message "Der må ikke bruges tomme stinavne". Translated from Danish: "You are not allowed to use empty path names"

When I check the log file, I can see this error:

2018-11-03 22:30:07.1262 [Error] pdfforge.PDFCreator.Core.DirectConversion.DirectConversionInfFileHelper.TransformToInfFileWithMerge: Error while coping ps-file in spool folder:
Typeinitialiseringsfunktionen for 'PdfTools.Pdf.Internal.NativeBase' udløste en undtagelse.

Any suggestions?

Kasper


#2

Hi,

sorry for the trouble.
We will need to look into this.
The paid PDFCreator editions use some third party libraries from pdftools, which aren't included in the free version; this is probably the reason why the freeware doesn't have this issue.
A possible workaround might be to use the /merge command line parameter instead of the COM interface, as this uses a different workflow internally:
http://docs.pdfforge.org/pdfcreator/3.3/en/pdfcreator/using-pdfcreator/command-line-parameters/

Best regards

Robin


#3

Hi Robin

Thanks for answer.

Do I understand you correct if you mean this should work?

Dim stAppName As String
stAppName = "C:\Program Files\PDFCreator\pdfcreator.exe"
Call Shell("stAppName /OutputFile=n:\test.pdf" /Merge=n:\file_a.pdf /Merge=n:\file_b.pdf", 1)

I can't make it work.. :frowning:

Kasper


#4

Hi Kasper,

it should work if you change the third line to
Call Shell("stAppName /OutputFile=n:\test.pdf" /Merge=n:\file_a.pdf n:\file_b.pdf", 1)
I just realized the example in the docs is incomplete and we will update it accordingly.

Best regards

Robin


#5

Sorry Robin

I can't make it work...

I need a functionality where I from VBA code can merge several pdf-files to one pdf. I has to work in the background without starting pdfcreator with prompts for user input.

Can pdfcreator give mig a code which works with COM on a terminal server or a command line which can do the trick - or can you recommed something else?

Thank you in advance :smile:

Kasper


#6

Hi,

what went wrong? Did you get a prompt for the output location even though you specified the OutputFile parameter, or which prompt(s) did you get? We have in the past seen a few cases i which VBA doesn't play along nicely with COM, does the JS merge example in "PDFCreator\COM Scripts\JS Scripts\How To" work?
We will look into the COM issue and see if we can find the cause of it.

Best regards

Robin