Hi,
I'm quite exited about stumbeling over PDFsharp! However I'm having difficulty understanding the concepts.
In the examples there is always an XGraphics class used for drawing stuff. Why is there a difference between GDI and WPF versions if you have your own XGraphics class that does all the drawing? Somehow I think I'm missing a point?
What is the way to convert WPF pages to Pdf ones? Since there is a special WPF version it seems illogical that I would need to iterate through all visuals and convert each type one by one to an XGraphics equivilent?
For example, if I used a flowdocument and generated pages using the paginator, I'd like to call a function like this:
Code:
public static PdfSharp.Pdf.PdfDocument CreatePdf(System.Windows.Documents.DocumentPaginator paginator) {
if(!paginator.IsPageCountValid) paginator.ComputePageCount();
PdfSharp.Pdf.PdfDocument doc = new PdfSharp.Pdf.PdfDocument();
for(int t = 0; t < paginator.PageCount; t++) {
PdfSharp.Pdf.PdfPage pdfPage = doc.AddPage();
System.Windows.Documents.DocumentPage page = paginator.GetPage(t);
PdfSharp.Drawing.XGraphics gfx = PdfSharp.Drawing.XGraphics.FromPdfPage(pdfPage); // <-- do I really need that?
// will I have to recursively convert all "page" contents to "XGraphics" equivelents here?
// Is there WPF specific stuff that will do all that for me?
}
return doc;
}
I took a peek into the XPS converter code, but there it looks like it is also iterating through each visual element.
Keep up the good work!
Cheers,
Louis