PDFtoPrinter icon indicating copy to clipboard operation
PDFtoPrinter copied to clipboard

File not found when printing from web service

Open JeffSE97062 opened this issue 2 years ago • 10 comments

I am trying to print from a .NET web service. The exception being thrown is "The system cannot find the file specified". I assume that means the pdf itself, but the file does exist. System.IO.File.Exists(mypdffile) run during debug returns true. The service is running in Visual Studio 2013 framework 4.7 on my local box on which I am an admin. If I use the same code in a console app it works fine. The PDFtoPrinter.dll and PDFtoPrinter.exe are in the project's bin folder.

var wrapper = new PDFtoPrinterPrinter();
                await wrapper
                    .Print(new PrintingOptions(
                        printer, filePath)
                        );

Update: I noticed a closed post where someone was having the same issue but in a WPF project. A recommendation was to install using Nuget rather than manually (even though that works in a console app). Unfortunately, the install fails and is rolled back:

image

Thanks for any help.

JeffSE97062 avatar May 20 '22 19:05 JeffSE97062

Hi @JeffSE97062

Could you please provide your ".csproj" file? This will help to investigate the issue.

svishnevsky avatar May 27 '22 09:05 svishnevsky

EmailService.zip Hi @svishnevsky, file is attached.

JeffSE97062 avatar May 27 '22 14:05 JeffSE97062

Hi @JeffSE97062 Could you please try version 1.3.1 of the package and let me know if it works? (https://www.nuget.org/packages/PDFtoPrinter/1.3.2)

As I see the issue is in https://github.com/svishnevsky/PDFtoPrinter/blob/master/PDFtoPrinter/build/PDFtoPrinter.targets image However it is required for other projects. I still trying different conditions to do not break existing platforms support. Will keep you updated if I'll find an options to support all cases.

svishnevsky avatar May 30 '22 14:05 svishnevsky

Hi @svishnevsky, your last message said to try 1.3.1 but your link is to 1.3.2. Can you please clarify?

JeffSE97062 avatar May 30 '22 17:05 JeffSE97062

Hi @JeffSE97062 Sorry for confusion. Please try 1.3.1 https://www.nuget.org/packages/PDFtoPrinter/1.3.1

svishnevsky avatar May 30 '22 17:05 svishnevsky

@svishnevsky 1.3.1 installed without errors, but the project wouldn't build because it couldn't find the file "...packages\PDFtoPrinter.1.3.1\buildPDF-XChange Viewer Settings.dat". I copied the file (not sure if version matters??) into the expected folder and the project built successfully, but I received the same error: "The system cannot find the file specified".

JeffSE97062 avatar May 30 '22 17:05 JeffSE97062

I believe that the file not found is PDFtoPrinter.exe on Process Start. I am getting this error, even with PDFtoPrinter.exe and .dll (as well as PDF-X-Change Viewer Settings.dat) in the bin folder.

TinaKopp avatar Jun 02 '22 19:06 TinaKopp

That file is in my bin as well as the dll. Identical setup in a console app works, just not in a web service. Seems to work in a Windows service as well.

JeffSE97062 avatar Jun 03 '22 01:06 JeffSE97062

@JeffSE97062 sorry for the long response, it is not easy to reproduce this issue. What approach do you use to build a windows service? I use in person Topshelf and it works fine.

svishnevsky avatar Jun 06 '22 10:06 svishnevsky

@svishnevsky I am actually getting the file-not-found error in a .NET web (not Windows) service. I am using VS 2013 .NET 4.5 with the 1.3.1 Nuget package installed. Solution compiles OK.

JeffSE97062 avatar Jun 06 '22 15:06 JeffSE97062