I am setting the LogicalPageLayoutInfo as shown below to FitWidthToPage and it shows correctly in the Preview window but the right side of the physical print out gets cutoff. The HP printer allows the left and right margins to be set to .25".
Am I missing a setting?
private void dgBallotReceipts_InitializePrintPreview(object sender, CancelablePrintPreviewEventArgs e)
{ // Set page margins e.PrintDocument.DefaultPageSettings.Margins.Bottom = 50; e.PrintDocument.DefaultPageSettings.Margins.Top = 50; e.PrintDocument.DefaultPageSettings.Margins.Left = 25; e.PrintDocument.DefaultPageSettings.Margins.Right = 25; // Horizontally fit everything in a single page. e.DefaultLogicalPageLayoutInfo.FitWidthToPages = 1;
Did you check the HardMarginX like I suggested?
The margin units are in 1/100 of an inch, according to the Infragistics documentation.
I verified with a Word document that the printer will print as close as .25" to the left and right edges.
Somehow the print command from print preview, which correctly shows a fitted grid with .25" margins, is adding approximately .25" to the left margin before it prints.
I just tried setting the left margin to 0 and the right margin to 50 and that printed with a .25" margin on each side of the paper. The preview is shoved over but the printout is now correct.
I'm not sure whether to call this a fix or a bug work around.
I'm not sure what units the Margins are in off the to of my head, but you might want to check:
e.PrintDocument.DefaultPageSettings.HardMarginX and HardMarginY.
Those will give you the minimum allowable margins for your printer.