Note that there are some explanatory texts on larger screens.

plurals
  1. POITextSharp, Positioning text
    primarykey
    data
    text
    <p>We're using ITextSharp for reasons I do not understand and we dont have the book yet and I have an annoying problem that I'd appreciate help with. </p> <p>I'm working with a footer and I can not get it to align as I want it.</p> <p>The function I have takes a list of strings, but it's generally 4 strings I want on a row each. It does not seam like itextsharp can handle strings with linebreaks so that's the reason for the list.</p> <p>Now this does not position correctly for me, the first string looks ok, but then the second string is a bit longer and it's half outside the document as is the third string and the 4th is not even visible even thou there is 1 cm of space left.</p> <p>Thanks for help!</p> <pre><code>public PdfTemplate AddPageText(IList&lt;string&gt; stringList, PdfWriter writer) { var cb = writer.DirectContent; PdfTemplate footerTemplate = cb.CreateTemplate(450, 120); //55); footerTemplate.BeginText(); BaseFont bf2 = BaseFont.CreateFont(BaseFont.TIMES_ITALIC, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED); footerTemplate.SetFontAndSize(bf2, 9); footerTemplate.SetColorStroke(BaseColor.DARK_GRAY); footerTemplate.SetColorFill(BaseColor.GRAY); footerTemplate.SetLineWidth(3); footerTemplate.LineTo(50, footerTemplate.YTLM); int y = 10; foreach (string text in stringList) { float widthoftext = 500.0f - bf2.GetWidthPoint(text, 9); footerTemplate.ShowTextAligned(PdfContentByte.ALIGN_RIGHT, text, widthoftext, 50 - y, 0); y += y; } footerTemplate.EndText(); return footerTemplate; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload