I would like to draw 2 texts onto my PDF.
The first text should be aligned to the top left corner.
This works fine.
canvas = stamper.GetOverContent(i)
watermarkFont = iTextSharp.text.pdf.BaseFont.CreateFont(iTextSharp.text.pdf.BaseFont.HELVETICA, iTextSharp.text.pdf.BaseFont.CP1252, iTextSharp.text.pdf.BaseFont.NOT_EMBEDDED)
watermarkFontColor = iTextSharp.text.BaseColor.RED
canvas.MoveTo(0, 0) 'I think the canvas is the space that we draw onto. My documents always start at position X=0 and Y=0, so move to 0,0 should be fine
canvas.ShowTextAligned(Element.ALIGN_TOP, uText, 0, 830, 0) 'is 830 the width of the available space?
canvas.MoveTo(0, 100) 'let's draw the second text at X=100, Y=100
canvas.ShowTextAligned(Element.ALIGN_CENTER, uBewirtung, 0, 830, 0)
MoveTo() method is meant for drawing paths (lines amd shapes in graphics state), not text (in text state). It adds an
m operator to the content stream. If you are a PDF specialist, you should use the
SetTextMatrix() method inside your
ET text block: What does setTextMatrix of contentByte class in iText do?
Note the if; it is important. If you are not a PDF specialist, you shouldn't be toying around with those methods. You should use
ColumnText.ShowTextAligned() instead of
EndText() and all of the lines you added in-between. Those methods are meant for people who speak PDF syntax.