Click here to Skip to main content
Sign Up to vote bad
good
See more: C#2.0
Printing image is fine with " Send To Notebook 2007 " and some printer of Hp
. But while printing with Microsoft Xp Document viewer and Hp Deskjet F4200 series Image get compresseed or 1/4 Of real image size.
Code Of printing Image is below. It works fine with Some Printer and not work with Hp f4200 sieris.
 

Problem what i Found:
1. while priniting with Send Notebook 2007 the DPIX & DPIY value is 300.
2. while printing with Microsoft Xp Document and Hp F4200 The DPIX and DPIY value is 600. I want reduce Dpix nad DPiy value,. Please Help me .
 

    private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
        {
            try
            {
                if (dataGridView1.Rows.Count > 1)
                {
                    try
                    {
 
                        System.Drawing.Font font = new System.Drawing.Font("Arial", 10);
                        e.Graphics.PageUnit = GraphicsUnit.Pixel;
                        e.Graphics.PageScale = 1.0F; ;
                     
                        
                        float x = e.MarginBounds.Left;
                        float y = e.MarginBounds.Top;
                        e.Graphics.TextContrast = 5;
                        e.Graphics.Clear(System.Drawing.Color.White);
                        e.Graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
                        e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
                        e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                        e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
                        e.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
                  
 

 
                        if (pageindex < 5)
                        {
                           
                          
                              
                            
                            e.Graphics.DrawImage(finalimage[pageindex], Convert.ToInt32(numericUpDown14.Value), Convert.ToInt32(numericUpDown13.Value),finalimage[pageindex].Width, finalimage[pageindex].Height);
                            pageindex++;
                            e.HasMorePages = (pageindex < 5);
                        }
 
                    }
                    catch
                    {
                    }
                }
                else
                {
                    System.Drawing.Font font = new System.Drawing.Font("Arial", 10);
 

                    float x = e.MarginBounds.Left;
                    float y = e.MarginBounds.Top;
                    e.Graphics.DrawImage(pictureBox2.Image, 200, 250);
 
                }
            }
            catch
            {
            }
 

        }
 

[edit]Code block added - OriginalGriff[/edit]
Posted 16 Jun '12 - 2:50
Edited 16 Jun '12 - 3:08


1 solution

Probably, your problem is your unit selection:
e.Graphics.PageUnit = GraphicsUnit.Pixel;
Since the size of a pixel will be dependant on the output resolution of the device, I would expect the size to change between devices. Try using a device independant unit instead: try Point, Inch, Document or Millimeter instead - whichever you are comfortable with.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 OriginalGriff 315
1 Aarti Meswania 250
2 Slacker007 240
3 Sergey Alexandrovich Kryukov 219
4 Ron Beyer 190
0 Sergey Alexandrovich Kryukov 8,743
1 OriginalGriff 7,124
2 CPallini 3,678
3 Rohan Leuva 3,011
4 Maciej Los 2,403


Advertise | Privacy | Mobile
Web04 | 2.6.130516.1 | Last Updated 16 Jun 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid