0

Printer resolutions are generally 5-6 times greater than a screen's resolution. A printer's resolution can be around 6600 x 5100 as opposed to a full HD screen's resolution: 1920 x 1080.

An 1920 x 1080 image looks great on a screen but to avoid pixelation, one should ideally render a much higher resolution image to the printer, for example, a 6600 x 5100 image.

I am trying to print a high definition image (6600 x 5100) to my high definition printer (600 dpi), but I find that the available print area is only 850 x 1100 as specified by e.PageBounds; see the code below:

Bitmap bitmapToPrint;
    public void printImage()
    {
        bitmapToPrint = new Bitmap(1700,2200);
        Font font = new Font(FontFamily.GenericSansSerif, 60, FontStyle.Regular);
        string alphabet = "abcdefghijklmnopqrstuvwxyz";
        Graphics graphics = Graphics.FromImage(bitmapToPrint);
        graphics.DrawString(alphabet, font, System.Drawing.Brushes.Black, 0, 0);
        graphics.DrawString(alphabet, font, System.Drawing.Brushes.Black, 0, 1000);

        PrintDocument pd = new PrintDocument();
        pd.PrinterSettings.PrinterName = "Microsoft XPS Document Writer";
        pd.PrinterSettings.PrintToFile = true;
        pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
        pd.Print();
    }
    void pd_PrintPage(object sender, PrintPageEventArgs e)
    {
        e.Graphics.DrawImage(bitmapToPrint, new PointF(0, 0));
        //Have a look at e.PageBounds, the dimensions are only 850x1100
    }
Zoe
  • 27,060
  • 21
  • 118
  • 148
  • 1
    PageBounds is specified in hundredths of an inch in this case (8.5" x 11" = 850 x 1100) and has nothing to do with printer resolution. If your image is already high resolution then you shouldn't need to do anything else except call `DrawImage` with the desired destination rectangle. Just make sure your destination rectangle is specified in the same units as the page bounds. – RogerN Jul 10 '15 at 19:25
  • I just tested with a 1700 x 2200 Bitmap, and it only printed the 850 x 1100 area at the top left. – Marco-Hans Van Der Willik Jul 10 '15 at 19:42
  • Please edit your question to include the exact code that you used to perform your test. I suspect that you have not provided a destination size for the image. – RogerN Jul 10 '15 at 19:48
  • Ok, I have updated my question with the exact code. – Marco-Hans Van Der Willik Jul 10 '15 at 20:09
  • You need to specify a destination size for the image: e.Graphics.DrawImage(bitmapToPrint, new RectangleF(0.0f,0.0f,850.0f,1100.0f)); but note that you may also need to account for page margins, which cannot always be printed – RogerN Jul 10 '15 at 20:14
  • Ok, perfect, that fixed it. – Marco-Hans Van Der Willik Jul 10 '15 at 20:32
  • If you give this as an answer, then I can mark your answer as correct. – Marco-Hans Van Der Willik Jul 10 '15 at 20:33

0 Answers0