Skip to main content
Skip table of contents

How to add a full line break?

I use itextsharp and I need to draw a dotted line break from the left to the right of the page (100% width) but I don't know how to do this. The document always has a margin to the left and the right.

Chunk linebreak = new Chunk(new DottedLineSeparator());
doc.Add(linebreak);  

 

Posted on StackOverflow on Nov 27, 2013 by nam vo

Please take a look at the example FullDottedLine.

You're creating a DottedLineSeparator of which the width percentage is 100% by default. This 100% is the full available width withing the margins of the page. If you want the line to exceed the available width, you need a percentage that is higher than 100%.

In the example, the default page size (A4) and the default margins (36) are used. This means that the width of the page is 595 user units and the available width equals 595 - (2 x 36) user units. The percentage needed to span the complete width of the page equals 100 x (595 / 523).

Take a look at the resulting PDF file full_dotted_line.pdf and you'll see that the line now runs through the margins.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.