Reputation: 960
I have working iTextsharp code for printing labels. Now the problem is, I have a requirement to print the labels in Continuous paper
which i am not able to select in iTextsharp configuration (iTextSharp.text.PageSize.A4
). Please advice how can i select the page size according to my current scenario.
Thanks
Upvotes: 0
Views: 687
Reputation: 77606
Your problem is related to PDF as a document format. In PDF, the content is distributed over different pages. You can define the size of such a page yourself. You mention iTextSharp.text.PageSize.A4
, but you can define the page size as a Rectangle
object yourself. See iTextsharp landscape document
If you want a long, narrow page, you could define the page size like this:
Document Doc = new Document(new Rectangle(595f, 14400f));
There are some implementation limits though. The maximum height or width of a page is 14,400 user units. See the blog post Help, I only see blank pages in my PDF!
However, I am pretty sure that you don't want to create a long narrow page. If you want to print labels on "continuous paper", you want to create a PDF document in which every page has the size of exactly one label. Your PDF will have as many pages as there are labels.
Suppose that the size of one label is 5 by 2 inch (width: 12.7cm; height: 5.08cm), then you should create a document like this:
Document Doc = new Document(new Rectangle(360, 144));
And you should make sure that all the content of a label fits on a single page. Your label printer should know that each page in the PDF should be printed on a separate label.
(Thank you @amedeeVanGasse for correcting my initial answer.)
Upvotes: 1