I have found that one of the Microsoft Reporting controls (the Chart) is inadequate for my needs. Since these controls aren’t extensible, I’ve extended the functionality of a WPF control and am saving the control as a graphic. Unfortunately, ReportViewer’s image control doesn’t support vector graphics, either. Therefore my goal is to generate the PDF from ReportViewer with certain “placeholders” (e.g. a rectangle item), and then come behind with iTextSharp and add the vector graphic on top of these placeholders. Since the report length flows based on the input data, I can’t know the coordinates of these placeholders before getting them.
I can’t think of a way to include a PDF field in the RDLC, which would be nice since iText has the GetFieldPosition() method. Furthermore I know there is iText’s PDFWriter.GetVerticalPosition() method, but this is really only useful if you’ve moved the cursor to that location in the PDFWriter. Truth is, I’m still trying to get my head around iText and PDF. It is vast.
So my two questions that refer to each other:
- What kind of placeholder should I use in the RDLC designer that can be systematically identified afterwards and have its position queried?
- How would I go about getting this position?
Thanks in advance!
-Brandon
My imperfect, but working solution is to use text item placeholders that match the background to mark the positions in the .RDLC report. After generating the PDF, these are identified by way of inheriting iTextSharp’s LocationTextExtractionStrategy (as per this entry by greenhat). In my current test environment the above is copy-pasted verbatim and only deviates in the RenderText() override, which does not add the TextChunk to the list unless
info.GetText()is an appropriate placeholder string.Snippet of placeholder extraction:
The native vector image type is WMF, and can be inserted at the absolute location of the placeholder text. To do so for the first placeholder in the list, then:
Thanks to mkl and VahidN for your valuable input!