How to print custom page size as portrait in itextsharp

点点圈 提交于 2020-02-05 03:53:49

问题


Below is my code to create custom page size in ItextSharp. Page is now printing in landscape mode. I want print in Portrait.

document = new Document(new iTextSharp.text.Rectangle(410f, 288f));

回答1:


Replace:

document = new Document(new iTextSharp.text.Rectangle(410f, 288f));

With:

document = new Document(new iTextSharp.text.Rectangle(410f, 288f).Rotate());

And the custom page will be rotated by 90 degrees, if that's what you want.




回答2:


  Document document = new Document(default(iTextSharp.text.Rectangle));
  document.SetPageSize(new iTextSharp.text.Rectangle(410f, 288f).Rotate());

please try this.



来源:https://stackoverflow.com/questions/41422403/how-to-print-custom-page-size-as-portrait-in-itextsharp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!