Hello, I'm sending a code that I found in the stackoverflow to print the document in pdf, if you can implement this option, thank you.
public bool PrintPDF(PdfDocument document , string printer, string paperName, string filename, int copies)
{
try
{
// Create the printer settings for our printer
var printerSettings = new PrinterSettings
{
PrinterName = printer,
Copies = (short)copies,
};
// Create our page settings for the paper size selected
var pageSettings = new PageSettings(printerSettings)
{
Margins = new Margins(0, 0, 0, 0),
};
foreach (PaperSize paperSize in printerSettings.PaperSizes)
{
if (paperSize.PaperName == paperName)
{
pageSettings.PaperSize = paperSize;
break;
}
}
// Now print the PDF document
using (var printDocument = document.CreatePrintDocument())
{
printDocument.PrinterSettings = printerSettings;
printDocument.DefaultPageSettings = pageSettings;
printDocument.PrintController = new StandardPrintController();
printDocument.Print();
}
return true;
}
catch (Exception)
{
return false;
}
}
var ret = PrintPDF(Renderer.Document,"Microsoft Print to PDF", "A4", dialog.FileName, 1);
Hello, I'm sending a code that I found in the stackoverflow to print the document in pdf, if you can implement this option, thank you.
public bool PrintPDF(PdfDocument document , string printer, string paperName, string filename, int copies)
{
try
{
// Create the printer settings for our printer
var printerSettings = new PrinterSettings
{
PrinterName = printer,
Copies = (short)copies,
};
var ret = PrintPDF(Renderer.Document,"Microsoft Print to PDF", "A4", dialog.FileName, 1);