PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
How to Add/Draw a table for a heading into an imported doc? https://forum.pdfsharp.net/viewtopic.php?f=2&t=3537 |
Page 1 of 1 |
Author: | Jonathan [ Fri Feb 03, 2017 11:03 am ] |
Post subject: | How to Add/Draw a table for a heading into an imported doc? |
Hi all this is my first post loving your work I'm generating multiple GraphViz PDF's in memory and importing the pages from these pdf's into a master PdfDocument. The code does this successfully all that remains is I wish to add a header to each page (variable name 'pageToAddOrDrawTableHeader') before adding to master PdfDocument how would I acheive this? Idea 1 Is it possible to add a header (table - 3 columns 1 row - 2 images either side and text in the center) to the master PdfDocument which will automatically add to all pages? If so how? Idea2 Create an XGraphics object of the imported page and draw onto a new page of the master document and draw/add header table? If so how? Idea3 Is it possible to create an XImage from an XGraphics object and add the XImage to the imported page? If so how? Code: private byte[] MergePdfDocuments(List<string> dotList) { var masterDoc = new PdfDocument(); // Init GraphViz Wrapper var gvwGetStartProcessQuery = new GetStartProcessQuery(); var gvwGetProcessStartInfoQuery = new GetProcessStartInfoQuery(); var gvwRegisterLayoutPluginCommand = new RegisterLayoutPluginCommand(gvwGetProcessStartInfoQuery, gvwGetStartProcessQuery); var gvWrapper = new GraphGeneration(gvwGetStartProcessQuery, gvwGetProcessStartInfoQuery, gvwRegisterLayoutPluginCommand); foreach (var dot in dotList) { var graphVizPdfByteArray = gvWrapper.GenerateGraph(dot, Enums.GraphReturnType.Pdf); var graphVizPdfStream = new MemoryStream(graphVizPdfByteArray); var graphVizPdf = PdfReader.Open(graphVizPdfStream, PdfDocumentOpenMode.Import); for (int i = 0; i < graphVizPdf.Pages.Count; i++) { var pageToAddOrDrawTableHeader = graphVizPdf.Pages[i]; masterDoc.AddPage(pageToAddOrDrawTableHeader); } } var renderDoc = new Document(); var renderer = new DocumentRenderer(renderDoc); var pdfRenderer = new PdfDocumentRenderer(false, PdfFontEmbedding.Always) { PdfDocument = masterDoc, DocumentRenderer = renderer }; var ms = new MemoryStream(); pdfRenderer.PdfDocument.Save(ms, true); ms.Flush(); return ms.ToArray(); } Any help would be much appreciated I'm so close to acheiving my goal Thanks for reading. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |