Print dialog

hi I have a code below that does the silent PDF print.



how can I have a print dialog so they user can choose the printer name.



public void PrintWithAspose() {

var license = new License();

license.SetLicense(“Aspose.Pdf.lic”);



// open input PDF file

_pdfviewer.BindPdf(_filePath);



// set attributes for printing

_pdfviewer.AutoResize = true; // Print the file with adjusted size

_pdfviewer.AutoRotate = true; // Print the file with adjusted rotation

_pdfviewer.PrintPageDialog = false; // Do not produce the page number dialog when printing



// Create objects for printer and page settings and PrintDocument

var ps = new PrinterSettings();

var pgs = new PageSettings();

var prtdoc = new PrintDocument();



// Set printer name to user default printer

ps.PrinterName = prtdoc.PrinterSettings.PrinterName;



// Set PageSize (if required)

pgs.PaperSize = new PaperSize(“A4”, 827, 1169);



// Set PageMargins (if required)

pgs.Margins = new Margins(0, 0, 0, 0);



// Print document using printer and page settings

_pdfviewer.PrintDocumentWithSettings(pgs, ps);



// Close the PDF file after priting

_pdfviewer.Close();

}

Hi Nermin,


Thanks for your inquiry. Please use PrintDialog object to invoke Print dialog for printer selection. Please check following code snippet for the purpose. Hopefully it will help you to accomplish the task.

System.Windows.Forms.PrintDialog
printDialog = new System.Windows.Forms.PrintDialog();<o:p></o:p>

if (printDialog.ShowDialog() == DialogResult.OK)<o:p></o:p>

{<o:p></o:p>

// Document printing code goes here <o:p></o:p>

// Print document using printer and page settings <o:p></o:p>

_pdfviewer.PrintDocumentWithSettings(pgs,
ps); <o:p></o:p>

}<o:p></o:p>

.....


Please feel free to contact us for any further assistance.


Best Regards,