Rank: Newbie
Groups: Registered
Joined: 2/16/2016(UTC) Posts: 1 
|
Hi, I am trying to print a simple PDF page to the printer. It printed 5mm off from the top and 5mm from left. The same PDF file was printed correctly with Adobe Reader, Foxit Reader, etc. I have try OriginAtMargins but no effect. Here is the test code: Code:
public void PrintDocument(PdfDocument pdf)
{
//.Net Framework class from System.Drawing.Printing namespace
PrintDocument pd = new PrintDocument();
int pageForPrint = 0;
pd.PrintPage += (s, e) =>
{
pd.PrinterSettings.FromPage = 1;
pd.PrinterSettings.ToPage = 1;
//set paper size and orientation
e.PageSettings.PaperSize.RawKind = (int)PaperKind.Letter;
e.PageSettings.Landscape = false;
pd.OriginAtMargins = true;
e.PageSettings.Margins.Top = 0;
e.PageSettings.Margins.Left = 0;
e.PageSettings.Margins.Bottom = 0;
e.PageSettings.Margins.Right = 0;
//Calculate actual size in pixels that depends on current printer's DPI
int actualWidth = (int)(e.Graphics.DpiX * 8.5f);
int actualHeight = (int)(e.Graphics.DpiY * 11);
//Render to PdfBitmap using page's Render method with FPDF_PRINTING flag
pdf.Pages[pageForPrint].Render
(e.Graphics,
0,
0,
actualWidth,
actualHeight,
Patagames.Pdf.Enums.PageRotate.Normal, Patagames.Pdf.Enums.RenderFlags.FPDF_PRINTING);
//Print next page
if (pageForPrint < pdf.Pages.Count - 1)
{
pageForPrint++;
e.HasMorePages = true;
}
};
//start printing routine
pd.Print();
}
}
}
Thanks. Edited by moderator Wednesday, February 17, 2016 12:31:40 AM(UTC)
| Reason: [code=cs]
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,115
Thanks: 8 times Was thanked: 130 time(s) in 127 post(s)
|
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The Patagames Software Support Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close