PDF Creation from Windows Service and IIS  SOLVED

This Forum is for the use of Software Developers requiring help and assistance for Tracker Software's PDF-Tools SDK of Library DLL functions(only) - Please use the PDF-XChange Drivers API SDK Forum for assistance with all PDF Print Driver related topics or PDF-XChange Viewer SDK if appropriate.

Moderators: Daniel - PDF-XChange, PDF-XChange Support, Vasyl - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Stefan - PDF-XChange

shahchandra
User
Posts: 2
Joined: Mon May 19, 2025 9:08 am

PDF Creation from Windows Service and IIS

Post by shahchandra »

The problem is whenever we try to create PDF from windows service or IIS the PDF is saved to the windows "system32" folder with name "untitled.pdf".

Attached you can find a demo windows service project (C#), basically derived from the example provided when installing PDF-Xchange.

We have all the properties set for the PDF-Xchange, but the windows service / IIS always saves the file in System32 folder.

We have tried all the options, like for windows service, Longin via network account, admin account, full rights to the path where file has to be saved, added IIS Users permissions to the folder but the result is same.

Using COM Library from the PDF-Xchange, using nuget package both have the same result.

Changing the properties for pdfsaver.exe, full permission for IIS Users, service users also doesn't help.

Any help is appreciated.
TestPDF.zip
You do not have the required permissions to view the files attached to this post.
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 10998
Joined: Wed Jan 03, 2018 6:52 pm

Re: PDF Creation from Windows Service and IIS

Post by Daniel - PDF-XChange »

Hello, shahchandra

I have escalated this item to our Dev team for review. If they do not reach out directly, I will return here once I have heard back from them on the matter.

Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3586
Joined: Thu Jul 08, 2004 10:36 pm

Re: PDF Creation from Windows Service and IIS  SOLVED

Post by Ivan - Tracker Software »

The problem is in the driver, but there is a simple workaround.
The problem is that the driver expects the destination file name to be specified in two components: "Save.Path" and "Save.File". If the "Save.Path" is empty (default value), the user's "My Documents" folder is used. Then, this folder name is combined with the filename itself. If the "Save.File" contains the absolute path, it is used instead of the path specified in "Save.Path". And there is a mistake in the driver's logic - it fails when the folder name is empty. And that happens under service, as there are no "My Documents". We will fix this issue in the next build.

Now, about the workaround - it is enough to specify any folder in the "Save.Path" parameter, for example, add this line:

Code: Select all

PDFPrinter.set_Option("Save.Path", @"c:\");
HTH
PDF-XChange Co Ltd. (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
shahchandra
User
Posts: 2
Joined: Mon May 19, 2025 9:08 am

Re: PDF Creation from Windows Service and IIS

Post by shahchandra »

Hi,

Thanks for the quick response.

The given workaround works with both windows service and IIS.
User avatar
Radi - PDF-XChange
Site Admin
Posts: 617
Joined: Tue Mar 03, 2015 12:46 pm

PDF Creation from Windows Service and IIS

Post by Radi - PDF-XChange »

:)