PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Jan 22, 2021 1:29 pm

All times are UTC

Forum rules

Please read this before posting on this forum: Forum Rules

Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Fri Feb 03, 2017 11:03 am 

Joined: Fri Feb 03, 2017 10:10 am
Posts: 1
Hi all this is my first post loving your work 8)

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?

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?

Is it possible to create an XImage from an XGraphics object and add the XImage to the imported page? If so how?

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];
    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);

    return ms.ToArray();

Any help would be much appreciated I'm so close to acheiving my goal :D

Thanks for reading.

Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC

Who is online

Users browsing this forum: Google [Bot] and 17 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group