public void print() { PrintDialog pd = new PrintDialog(); PrintDocument pdoc = new PrintDocument(); int w=Convert.ToInt32(Length/2.54)*100; int h = Convert.ToInt32(Width / 2.54) * 100; //pdoc.DefaultPageSettings.Landscape = true; PaperSize psize = new PaperSize("Custom", w, h); pdoc.DefaultPageSettings.PaperSize = psize; pd.Document = pdoc; pdoc.PrintPage += new PrintPageEventHandler(pdoc_PrintPage); DialogResult result = pd.ShowDialog(); if (result == DialogResult.OK) { PrintPreviewDialog ppd = new PrintPreviewDialog(); ppd.Document = pdoc; ppd.PrintPreviewControl.Zoom = 1.0; ((Form)ppd).WindowState = FormWindowState.Maximized; DialogResult ppdResult = ppd.ShowDialog(); // if i comment the above line and uncomment pdoc.Print(); i can save the print as pdf. // pdoc.Print(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)