Free Support Forum - aspose.com

Tried to access printer when tring to print

In my application I try to use PdfViewer to directly print my pdf onto the printer (a network accessible printer).
The used method is printDocumentWithSettings.
I got un error :
Tried to access printer ‘\MWFRSRV04\MWFEPPR041’ with invalid settings.
Looking foreward in the stacktrace I see an erro coming from a getMargins method in the PrintPageSettings.
What’s the problem ?
Tks
Tullio

@AxiomaBo

Could you please share the complete sample code snippet that you are using the print the PDF. We will test the scenario in our environment and address it accordingly.

Here my printing method.

public void print(byte[] xpDocument, String xpPrinterName) throws IOException {
Document doc = new Document(new ByteArrayInputStream(xpDocument));
PdfViewer viewer = new PdfViewer(doc);
viewer.setPrintPageDialog(false);
if(xpPrinterName == null) {
viewer.printDocument();
} else {
PdfPrinterSettings settings = viewer.getDefaultPrinterSettings();
settings.setPrinterName(xpPrinterName);
viewer.printDocumentWithSettings(settings);
}
}

@AxiomaBo

We have tried your code snippet with one of our sample files by using a virtual printer. We did not notice any issue. Could you please share if you are facing this issue with every PDF document or with some specific ones? Also, please share the Printer Name, Model and Driver Details with us so that we can further proceed to assist you accordingly.

I need to print only one type of document and the problem comes out from every document of such type.
The printer is a “Kyocera TASKalfa 2552ci KX” on a remote system
I dont’ know wich kind of informations You need about the driver and how to find them.
I created a testcase and it works on my home printer.
It seem to work on PDF995 but doesn’t work on the remote printer I need to use.
I can provide You the testcase if You want but it’s quite large (120MB).
Tks
Tullio

@AxiomaBo

Sure, please provide the test case as it would surely help in investigating the scenario accordingly. In case the file size is larger than the upload limit, you can please upload it to Google Drive or Dropbox and share the link with us here. We will further proceed to assist you accordingly.

Tks for Your help, I solved (still under test).
It was a problem of case sensitiveness.
Tks Again

@AxiomaBo

It is good to know that you were able to sort your issue out. Please feel free to let us know in case you need further assistance.