1

We are using rotativa wkhtmltoPDF to generate PDF in asp.net MVC C#. We were able to achieve all the required formating and indexing. All good..

What we need is to have mixed orientation. Our some of the pages are portrait and some of them landscape. wkhtmltoPDF only support single orientation.

Is there any way, we can use mixed orientation or any other library which we can use to achieve?

Here is the code which we are using

string tocXslPath = Server.MapPath("/Rotativa/toc.xsl");
string customSwitches = string.Format("--print-media-type --enable-smart-shrinking --header-html {0} --header-spacing \"4\" --footer-html {1} --footer-spacing \"4\" cover {2} cover {3} " + coverPages + " toc --xsl-style-sheet " + tocXslPath + " ", Url.Action("Header", "Home", new { area = "" }, "http"), Url.Action("Footer", "Home", new { area = "" }, "http"), Url.Action("CoverTitle", "Home", new { area = "" }, "http"), Url.Action("CoverAll", "Home", new { area = "" }, "http"), Url.Action("EmptyCover", "Home", new { area = "" }, "http"));

  return new Rotativa.ViewAsPdf("ProjectPdf")
  {
      FileName = "Project.pdf",
      CustomSwitches = customSwitches,
      PageMargins = { Top = 15, Bottom = 15 }
  };

Here is the command which we are using for orientation

--orientation landscape
it made all pages landscape.
Muhammad Akhtar
  • 51,913
  • 37
  • 138
  • 191

1 Answers1

0

Mixed orientation is not a supported feature of the underlying library. You can read / comment on the feature request here: https://github.com/wkhtmltopdf/wkhtmltopdf/issues/1564

There have been some workarounds posted, like this one using CSS (Mixing page orientations in wkhtmltopdf) or by creating two or more PDFs and then combining them in a separate function.

kerrin
  • 3,376
  • 1
  • 26
  • 36