Problems to send the pdf to printer over asp.net source code, pdfprint.exe can not find the printer from ASP.NET source code

Hi,

I am using VeryPDF PDFPrint Command Line software to print my PDF files from ASP.NET source code,

https://www.verypdf.com/app/pdf-print-cmd/index.html

I'm testing the pdfprint command line tool, my idea is to call it from asp.net code:

Dim startInfo As System.Diagnostics.ProcessStartInfo = New System.Diagnostics.ProcessStartInfo(strExe, strArguments)

And here:

* strExe: pdfprint.exe location
* strArguments: -printer PRINTERNAME FILETOPRINT

With another ms-dos commands working fine, for example:

copy PRINTER FILETOPRINT

But with pdfprint, the printer doesn't print, I have launched the debug option and this is the result:
------------------------
Read Command Line options...
Copyright (C) VeryPDF.com
"LOCATION\pdfprint.exe" "-debug" "-printer" PRINTER "FILETOPRINT"
You have 99 times to evaluate "VeryPDF PDFPrint Command Line" product, you may purchase a full version from http://www.verypdf.com/app/pdf-print-cmd/index.html to remove restrictions.
Version Build Date: Jun 21 2018
Try to load 'WINSPOOL.DRV' file...
Load 'WINSPOOL.DRV' file OK.
Current default printer is 'Microsoft Print to PDF'.
AddPrinterConnection to 'PRINTER' printer, return code = 0.
AddPrinterConnection return an error code (87).

Can't locate the PRINTER printer in this computer, please double check the printer name and to try again.

------------------------

However, if launch the same command directly in ms-dos console, it works fine.

I would like to use this tool because I could set the tray to print with "papersource" option, and with copy command this is not possible.

Please, can you help me?

Thanks a lot in advance.
Customer
====================================================
Sorry for this matter, the error message is,

-----------------------

Can't locate the PRINTER printer in this computer, please double check the printer name and to try again.

-----------------------

When you can call pdfprint.exe from ASP.NET code, the ASP.NET and pdfprint.exe are run inside SYSTEM user account, the physical printer can't be accessed from SYSTEM user account, this is the reason why pdfprint.exe can not access to this physical printer.

You need to set your ASP.NET run inside an interactive user account instead of default SYSTEM user account, if so, pdfprint.exe will able to access to the physical printer properly.

You may look at following web page for more information about "Application Pool Identities",

-- Application Pool Identities

https://docs.microsoft.com/en-us/iis/manage/configuring-security/application-pool-identities

-- How do I configure the user account for an application pool in IIS?

You can change which user account is being used by right clicking "Application Pool" > "Advanced Settings" > Under "Identity", you can click the "…" and look for a different user account.

Whenever a new application pool is created in IIS, it will use an account defined by IIS (usually it’s called "ApplicationPoolIdentity") which is under the "Identity" section. Identities are similar to a "account" you would use to log into your window account example. This defines what users are allows to run that specific application.

User accounts could be restrictive and prevent the "ApplicationPoolIdentity" from running the Activate mobile application (either it’s under the default application pool or another application pool). You can change which user account is being used by right clicking "Application Pool" > Advanced Settings > Under "Identity", you can click the "…" and look for a different user account.

Application Pool Identity

image

You can either choose any of the service accounts on the server, or choose a specific user to run a specific application. When a user is chosen, click OK and restart the application pool.

-- How to find out which user account is running ASP.NET?

Use this code:

VB.NET

Response.Write("Windows Account which runs ASP.NET is: " & Environment.Username)

C#

Response.Write("Windows Account which runs ASP.NET is: " + Environment.Username);

If you debug your application in Visual Studio on localhost you'll get your user name. If you deploy ASP.NET web application on IIS 6.0 web server, you will probably get NETWORK SERVICE account, because that is default user running IIS.

VeryPDF

VN:F [1.9.20_1166]
Rating: 2.0/10 (1 vote cast)
VN:F [1.9.20_1166]
Rating: 0 (from 0 votes)
Problems to send the pdf to printer over asp.net source code, pdfprint.exe can not find the printer from ASP.NET source code, 2.0 out of 10 based on 1 rating

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *


Verify Code   If you cannot see the CheckCode image,please refresh the page again!