Hi,
We do use the PDFTron’s PDFNet SDK to print PDFs. We are having issues with the printing where it is cutting off at the right and bottom margin. I have tried all possible solution that is out there on the site. I have pasted the code that we use currently. I would appreciate if anyone could help me identify what I am doing wrong.
static void PrintPage(object sender, PrintPageEventArgs ev)
{
Graphics gr = ev.Graphics;
gr.PageUnit = GraphicsUnit.Inch;
Rectangle rectPage = ev.PageBounds; //print without margins
//Rectangle rectPage = ev.MarginBounds; //print using margins
//RectangleF rectPage = GetBestRectangle(ev);
//Rectangle rectPage = GetRealPageBounds(ev, 2); //Option 1 or Option 2
float dpi = gr.DpiX;
if (dpi>300) dpi = 300;
double left, right, top, bottom;
left= rectPage.Left / 100.0;
right = rectPage.Right / 100.0;
top = rectPage.Top / 100.0;
bottom= rectPage.Bottom / 100.0;
LogUtil("rectPage.Left " + left.ToString(), verboseLogs);
LogUtil("rectPage.right " + right.ToString(), verboseLogs);
LogUtil("rectPage.top " + top.ToString(), verboseLogs);
LogUtil("rectPage.bottom " + bottom.ToString(), verboseLogs);
// One page unit is 1/72 of an inch.
// For a ‘letter’ size page (8.5 x 11 inches) the dimensions will be:
// width = 612 units = 612 * 1/72 = 8.5 inches
// height = 792 units = 792 * 1/72 = 11 inches
// ============================================================
// The above page dimensions are in inches. We need to convert the page
// dimensions to PDF units (or points). One point is 1/72 of an inch.
var rect = new pdftron.PDF.Rect(left72, bottom72, right72, top72);
try
{
pdfdraw.SetDPI(dpi);
pdfdraw.DrawInRect(pageitr.Current(), gr, rect);
}
catch (Exception ex)
{
LogUtil("PDF printing Error: " + ex.ToString());
}
pageitr.Next(); // Move to the next page, if any
ev.HasMorePages = pageitr.HasNext();
}
Thanks,
Vinod Shenoy H.N.
Sr. Application Developer
Output Solutions
Fiserv
Direct: 314-387-2553
Cell: 314-363-3287
Fax: 314-387-2700
Email: vinod.shenoy@fiserv.com
P Please consider the environment before printing this email.