问题
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