I am trying to print a rectangle with 20mm width and 8mm height with top magin 22mm and left margin 8.8mm.
"HP LaserJet P2035n" Printer showing correct measures after printing. But, "Canon iR2020 PCL5e" printer showing correct measures except TOP Margin. I am not sure where i am doing worng? Is there anything i should consider the printers like DPI.. etc?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Printing;
namespace ConsoleApplication6
{
class DrawShape
{
public static void DrawRec()
{
PrintDocument doc = new PrintDocument();
doc.PrintPage += doc_PrintPage;
doc.Print();
}
static void doc_PrintPage(object sender, PrintPageEventArgs e)
{
Graphics g = e.Graphics;
PageSettings PageSet = new PageSettings();
float MarginX = PageSet.PrintableArea.X;
float MarginY = PageSet.PrintableArea.Y;
float x = (float)(8.8-((MarginX/100)*25.4));
float y = (float)(22-((MarginY/100)*25.4));
g.PageUnit = GraphicsUnit.Millimeter;
g.DrawRectangle(Pens.Black, x, y, 20, 8);
}
} }
Thanks,
Ramana