So i'm creating a form, on the form is a panel (panel1) which holds all data, pictures etc... This is then to be made into a bmp for professional printing (ie 300dpi).

A4 @ 300dpi = 2480 x 3508;

i am able to create the image at the panel's height and width. and i have also recently got it to create a document 2480x3508, but the panel is being shown in the top left corner with a whole lot of white space.. what am i doing wrong?.. is there a Better way to create this image, as quality is a factor?.. this is my code below..

panel1.width = 826;
panel1.height = 1168;

Apologies if i sound noob.. ....but i am, have only just started with C#... thanks all.

Bitmap objBmpImage = new Bitmap((2480), (3508)); //create image
            objBmpImage.SetResolution(300, 300); // set resolution to 300 dpi

            Graphics objGraphics = Graphics.FromImage(objBmpImage); //create graphics object

            panel1.DrawToBitmap(objBmpImage, new System.Drawing.Rectangle(0,0, 2480, 3508)); //draw panel onto image 
             using (SaveFileDialog dlgSave = new SaveFileDialog()) //SFD for user to select destination...  which isnt working correctly either, but thats another issue
                dlgSave.Title = "Save Image";
                dlgSave.Filter = "Bitmap Images (*.bmp)|*.bmp|All Files (*.*)|*.*";
//make high quality
                    objGraphics.SmoothingMode = SmoothingMode.AntiAlias;
                    objGraphics.CompositingMode = CompositingMode.SourceCopy;
                    objGraphics.CompositingQuality = CompositingQuality.HighQuality;
                    objGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
//draw image
                    objGraphics.DrawImage(objBmpImage, 0, 0, 2480, 3508);

Edited 5 Years Ago by walid86: add more information

After you create the objGraphics object, maybe you need to fill it with som content.

An example from Jayman in

Dim bmp As New Bitmap("bitmap filename")

Dim gr As Graphics = Graphics.FromImage(bmp)

Dim p1 As New Pen(Color.Blue)

gr.DrawLine(p1, x1, y1, x2, y2)

Dim bmp As New Bitmap(width, height, gr)

bmp.Save("bitmap filename")

Hope this helps

Thanks, i've got the image outputting as required, just having a few issues using abcpdf to output to an A4 document.

It outputs to a letter sized document all fine and correctly, ( but not helpful for printing), but upon changing document size to A4, the output is distorted..

ie, picture starts 50pixels or so from the top, and is wider than the page.

anyone ever use abcpdf and come accros this? any tips, or ideas?..

Did you change the document size after got the image?

IMO you need to setup the page size before abcpdf creates the result.

Hope this helps

i fixed the issue. Turns out putting..

Doc myDoc = new Doc();
myDoc.MediaBox.String = "A4";
myDoc.Rect.String = myDoc.MediaBox.String; // <- this line fixes the issue Important
myDoc.Page = myDoc.AddPage();

It's asif the page size was not set for that page, think you need to assign it the string so it creates that size page, before you add it to the document..

Hope that made sense.. but code and printing works fine with this code now..

btw: ABCpdf is like $400+ for a license?? pricey isnt it?...

Thanks to all posters!.

Happy coding...

This question has already been answered. Start a new discussion instead.