Search code examples
c#asp.net-mvcasp.net-mvc-3model-view-controllermigradoc

Print Migradoc document with MVC 3


In my application ,I need to be able to create a PDF report, with header/footer, pictures, text and so on. Right now I have found a librabry migradoc, and i can't figure out atm. how to print/show the file which is getting created when user push "Create" button?

In PdfSharp I can just say document.Save(Url) and Process.Start(url), but I can't do the same with Migradoc.


Solution

  • MigraDoc uses PDFsharp. You just have to call Save and Start, just like you do with PDFsharp:

    // Save the document...
    const string filename = "HelloWorld.pdf";
    pdfRenderer.PdfDocument.Save(filename);
    // ...and start a viewer.
    Process.Start(filename);
    

    Code snippet from the HelloWorld sample that comes with MigraDoc. See also:
    http://www.pdfsharp.net/wiki/MigraDocHelloWorld-sample.ashx