HiI use this code to print a pdf file to a virtual printer.
private void printPdfDocument(string pdfDocument)
{
//create PdfViewer object
PdfViewer viewer = new PdfViewer();
//open input PDF file
viewer.OpenPdfFile(pdfDocument);
//set attributes for printing
viewer.AutoResize = true; //print the file with adjusted size
viewer.AutoRotate = true; //print the file with adjusted rotation
viewer.PrintPageDialog = false; //do not produce the page number dialog when printing
//create objects for printer and page settings and PrintDocument
System.Drawing.Printing.PrinterSettings ps = new System.Drawing.Printing.PrinterSettings();
System.Drawing.Printing.PageSettings pgs = new System.Drawing.Printing.PageSettings();
System.Drawing.Printing.PrintDocument prtdoc = new System.Drawing.Printing.PrintDocument();
//set printer name
//ps.PrinterName = prtdoc.PrinterSettings.PrinterName;
ps.PrinterName = "PDF-XChange Conversion System";
//set PageSize (if required)
pgs.PaperSize = new System.Drawing.Printing.PaperSize("A4", 827, 1169);
//set PageMargins (if required)
pgs.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);
//print document using printer and page settings
viewer.PrintDocumentWithSettings(pgs, ps);
//close the PDF file after priting
viewer.ClosePdfFile();
} private void printPdfDocument(string pdfDocument)
{
//create PdfViewer object
PdfViewer viewer = new PdfViewer();
//open input PDF file
viewer.OpenPdfFile(pdfDocument);
//set attributes for printing
viewer.AutoResize = true; //print the file with adjusted size
viewer.AutoRotate = true; //print the file with adjusted rotation
viewer.PrintPageDialog = false; //do not produce the page number dialog when printing
//create objects for printer and page settings and PrintDocument
System.Drawing.Printing.PrinterSettings ps = new System.Drawing.Printing.PrinterSettings();
System.Drawing.Printing.PageSettings pgs = new System.Drawing.Printing.PageSettings();
System.Drawing.Printing.PrintDocument prtdoc = new System.Drawing.Printing.PrintDocument();
//set printer name
//ps.PrinterName = prtdoc.PrinterSettings.PrinterName;
ps.PrinterName = "PDF-XChange Conversion System";
//set PageSize (if required)
pgs.PaperSize = new System.Drawing.Printing.PaperSize("A4", 827, 1169);
//set PageMargins (if required)
pgs.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);
//print document using printer and page settings
viewer.PrintDocumentWithSettings(pgs, ps);
//close the PDF file after priting
viewer.ClosePdfFile();
}
But when I do the output is printed as an image. My virtual printer scans for text so since it's an image it can't do this. For instance If I use Acrobat reader to print a pdf to this printer it works fine, but If i use Aspose.PDF to print it can't scan the text since it's printed as an image.Is there way to change the settings in the API, so when you print it it's printed with characters not glyphs.
See the example i've attached, the "original Letter.pdf" you can select text in acrobat reader, but "Aspose Printed Letter.pdf" is printed as an image, and you can't select any text.
Please let me know if there's a way to fix this in code?