8

I am using PDFSharp to generate PDF from html source.

PdfGenerator.GeneratePdf(html, PageSize.A4);

Generate to pdf works well, but I dont know how I can change page orientation to landscape?

jww
  • 97,681
  • 90
  • 411
  • 885
Marek
  • 372
  • 5
  • 15
  • Wrong tag: PdfGenerator is not part of PDFsharp. – I liked the old Stack Overflow Dec 18 '14 at 21:26
  • Yes, but I cant use right tag htmlrenderer. – Marek Dec 19 '14 at 06:24
  • Did you manage to find a solution for this as I require landscape mode when using `PdfGenerator.GeneratePdf`? Also looks like HtmlRenderer.PdfSharp is no longer supported so unless someone has managed to implement landscape mode when generating Pdf's from HTML I may have to grab the source code and make the changes myself. – Intrepid Mar 13 '15 at 15:19
  • Unfortunately no, I had to manual create this page by MigraDoc. – Marek Mar 18 '15 at 09:40

1 Answers1

17

the following code could be usefull for you:

        var config = new PdfGenerateConfig();
        config.PageOrientation= PageOrientation.Landscape;
        config.PageSize = PageSize.A4;

        PdfDocument pdf = PdfGenerator.GeneratePdf(documentHtmlContent, config);

        pdf.Save(FILE_OUT_PATH);

        Process.Start(FILE_OUT_PATH);
daniel
  • 731
  • 1
  • 7
  • 13