use versin width System.Drawing.Printing dependency like 23.5
2.update to 24.8
end
I use System.Drawing.Printing.PrinterSettings and System.Drawing.Printing.PageSettings
i set paper source by name and use ToAsposePageSettings and ToAsposePrinterSettings funtion to Convert type for PrintDocumentWithSettings
but paper source not work
I tried to use a paperless tray for printing,normally the printer should not print,And when I use System.Drawing.Printing.PrintDocument to do it, it doesn’t print either
When I print with PdfViewer, it prints from other tray that have paper
Aspose.Pdf version:24.6.0
PdfViewer viewer = new PdfViewer();
foreach (var filePath in filePaths)
{
viewer.BindPdf(filePath);
viewer.PrinterJobName = Path.GetFileName(filePath);
viewer.Resolution = 110;
viewer.AutoResize = true;
viewer.AutoRotate = false;
viewer.PrintPageDialog = false;
PrinterSettings ps = new PrinterSettings
{
PrinterName = deviceName
};
PageSettings pgs = new();
ps.Duplex = GetPrinterDuplexMode(mode);
pgs.PaperSize = PrinterPrintPaperSizes.A4;
PaperSource? source = null;
foreach (PaperSource p in ps.PaperSources)
{
if (p.SourceName.Trim() == "Tary 1")
{
source = p;
break;
}
}
if (source == null)
throw new NotSupportedException("Tary 1");
pgs.PaperSource = source;
ps.DefaultPageSettings.PaperSource = source;
viewer.PrintDocumentWithSettings(pgs.ToAsposePageSettings(), ps.ToAsposePrinterSettings());
if (viewer.PrintStatus != null)
{
if (viewer.PrintStatus is Exception ex)
{
throw ex;
}
}
It seems you are experiencing issues with selecting the correct paper source when printing PDFs using Aspose.Pdf. This problem may have arisen after upgrading to a newer version of the library, which has changed how tray selection is handled.
Here are some steps and considerations that might help you resolve the issue:
Check Paper Source Availability: Ensure that the paper source you are trying to select (e.g., “Tray 1”) is available on the printer. You can list all available paper sources using the PrinterSettings class to confirm that “Tray 1” is indeed present.
Use Aspose.Pdf.Printing Classes: Since you are using Aspose.Pdf, make sure you are utilizing the Aspose.Pdf.Printing.PrinterSettings and Aspose.Pdf.Printing.PageSettings classes instead of the standard System.Drawing.Printing classes. This is important as the newer versions of Aspose.Pdf may have specific implementations for handling printing.
Setting Paper Source: When setting the paper source, ensure that you are correctly assigning it to both the PageSettings and the PrinterSettings. Here’s a code snippet that demonstrates how to set the paper source correctly:
// Create printer and page settings
Aspose.Pdf.Printing.PrinterSettings ps = new Aspose.Pdf.Printing.PrinterSettings();
Aspose.Pdf.Printing.PageSettings pgs = new Aspose.Pdf.Printing.PageSettings();
// Set printer name
ps.PrinterName = deviceName;
// Set paper size and source
pgs.PaperSize = new Aspose.Pdf.Printing.PaperSize("A4", 827, 1169); // Example for A4 size
pgs.PaperSource = GetPaperSource(ps, "Tray 1"); // Custom method to get the paper source
// Print document
viewer.PrintDocumentWithSettings(pgs, ps);
Custom Method for Paper Source: You may need a method to retrieve the correct paper source based on the printer settings. Here’s an example of how you might implement this:
private static Aspose.Pdf.Printing.PaperSource GetPaperSource(Aspose.Pdf.Printing.PrinterSettings printerSettings, string trayName)
{
foreach (var source in printerSettings.PaperSources)
{
if (source.SourceName.Equals(trayName, StringComparison.OrdinalIgnoreCase))
{
return source;
}
}
throw new NotSupportedException($"Paper source '{trayName}' not found.");
}
Testing with Different Versions: If the issue persists, consider testing with different versions of Aspose.Pdf to see if the problem is specific to the version you are currently using.
If you continue to face issues, it may be helpful to check the Aspose documentation or community forums for any updates or similar issues reported by other users.
Is there way to save the PDF with tray selection for printing it later?
Let’s say, I have a PDF with 30 pages and I want to print every even number page with “Tray 1” and every odd number page with “Tray 2”. However, I want to save the pdf with those PaperSource(Tray selection) option and print it later manually expecting it to choose the Trays as per our config.
I hope, I made my question clear?
Please let me know whether Aspose supports this. Thanks in advance.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): PDFNET-59119
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
Can you please confirm if the above mentioned scenario is possible using Aspose. Can we save the pdf with the Tray selections for printing it later manually?
We are afraid that this feature needs to be investigated yet which is why the ticket has been generated. As soon as we have some updates about it, we will let you know. Please spare us some time.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.