We have Infragistics 2009 v2. Old I know, but we are upgrading soon.
I am using the Infragistics.Documents.Reporting. I have looked through the knowledge base and haven't seen any bug fixes listed for this so I thought I would post it.
Consider the following Code
Report rpt = new Report(); Infragistics.Documents.Report.Section.ISection section = rpt.AddSection(); section.PageSize = Infragistics.Documents.Report.PageSizes.Letter; Infragistics.Documents.Report.ISite site = section.AddSite(); Infragistics.Documents.Report.ICanvas canvas = site.AddCanvas(0F, 0F); Graphics gpx = canvas.CreateGraphics(); gpx.PageUnit = GraphicsUnit.Pixel;
At this point if you check gpx.DpiX and Y they are both 96. PageSize is Letter. I would think that the canvas then should be 96 * 8.5 = 816 pixels across. This is not the case. Using the following code to draw a few lines (the pens are colored and 1 pixel wide).
gpx.DrawLine(pRed, new Point(610, 0), new Point(610, 100)); gpx.DrawLine(pGreen, new Point(611, 0), new Point(611, 100)) gpx.DrawLine(pBlue, new Point(612,0), new Point(612, 100)); gpx.DrawLine(pBlack, new Point(620, 0), new Point(620, 100));
rpt.Publish(@"C:\InfraReport_PDF.pdf",FileFormat.PDF);
On the resulting PDF I can just make out the Green line at 611 and if I zoom in I can see what appears to be 1/2 the Blue line. I would have thought that 816 would have been the right hand boundary since I created the canvas at 0,0. I can easily put a mark at 1,1.
What am I missing? Is this a bug, or just a lack of understanding?
Hi,
The Graphics object in the documents engine is just a proxy. It's basically a very simple proxy object and it really doesn't support a whole lot of the thing that the System.Drawing.Graphics object supports.
In this case, the DpiX and the PageUnit are not honored. The units for DrawRectangle are always in twips, and the values you specify are written directly to the PDF document with no translation.
Thanks Mike, that makes sense. We were starting to come to that conclusion.
For anyone else following this thread, by using a ScaleTransform you can scale your canvas to the size needed for the PDF.
The following converts from 96 dpi to 72dpi:
graphics.ScaleTransform(.75F, .75F);