I am trying to print a pdf document and save it to a file when I receive the prompt to save the document. The file is generated with the right number of pages but all pages are blank. What am I missing in the PrintPage handler below? Thanks for any advice.
var ctrl = new StandardPrintController();
using (PrintDocument doc = new PrintDocument())
{
doc.PrintController = ctrl;
doc.PrinterSettings.PrinterName = "CutePDF Writer";
doc.PrinterSettings.PrintFileName = fileName;
doc.PrintPage += (s, e) =>
{
pageNo++;
if (pageNo < frameCount)
{
e.HasMorePages = true;
}
else
{
e.HasMorePages = false;
}
};
doc.Print();
}