padh
padh

Reputation: 95

How to print custom page size as portrait in itextsharp

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));

Upvotes: 1

Views: 1672

Answers (2)

Chetan Sanghani
Chetan Sanghani

Reputation: 2111

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

please try this.

Upvotes: 0

Bruno Lowagie
Bruno Lowagie

Reputation: 77528

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.

Upvotes: 1

Related Questions