W.D Posted August 6, 2007 Report Share Posted August 6, 2007 Hi, I need to write chart into PDF. What I'm doing now is to create a Chart object dynamically and then Export chart to Bitmap and then import the bitmap to PDF using iText. But the quality of the image is not good enough. The DPI is 96. I read some the post saying use Paint() will help to increase DPI. But I'm not quite sure how to do this programtically. Is there any sample code? Thanks, W.D Quote Link to comment Share on other sites More sharing options...
Frank Posted August 7, 2007 Report Share Posted August 7, 2007 The follwoing code exports the chart to a 300 x 300 DPI bitmap: Rectangle r = new Rectangle(0,0,(chart1.Width * 300) / 96,(chart1.Height * 300) / 96); // 96 is the screen resolution Bitmap bmp = new Bitmap(r.Width,r.Height); bmp.SetResolution(300,300);Graphics g = Graphics.FromImage(bmp); chart1.Paint(g,r,PaintStyles.Background | PaintStyles.Border | PaintStyles.Print);bmp.Save(@"c:\temp\cfxdpi.bmp"); g.Dispose(); bmp.Dispose(); Quote Link to comment Share on other sites More sharing options...
W.D Posted August 12, 2007 Author Report Share Posted August 12, 2007 Thanks Frank, it's works. Great. Quote Link to comment Share on other sites More sharing options...
Smartie Posted December 23, 2010 Report Share Posted December 23, 2010 Hey, I'm using the above code to add a 300 dpi image to a PDF. Everythings great other than the file size. The PDF is over 2mb in size. When I previously used the chart fx png export it was under 100k. I am aware the image is now larger, so a file size increase would be expected, but this is way too big. If I copy this image from the PDF and paste it into fireworks, it's 2700 x 1800 pixels. A quick export preview as gif gives a file size of still under 100k. Please can you advise me how to output a 300 dpi PNG file? Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.