I'm using the iText library for .NET to generate a PDF. I need to output a PDF with an image, which has three text strings positions centered vertically, but absolute Y positions. Each string uses a different font. I've been struggling for hours to find a way to do this, I can get the first line on Ok using SetSimpleColumn(), but further attempts have been fruitless.
Is there a way to do thi开发者_如何学编程s?
I have never used either iText
or iTextSharp
, which I think you're referencing to. Despite, I have used PDF Sharp
which offered a MeasureString()
method. This method, given a Font
and a string is able to measure the string from its XGraphics
class which has the information about DPI, etc.
I guess that if you took an eye out to the equivalent class and method with iText
, you should be able to do something, if it even exists.
I know it's not much help, but I hope to have given you some idea for a workaround.
I eventually got this working with:
int y_offset = 20;
Phrase fullTitle = new Phrase("Some string", myFont);
ColumnText.ShowTextAligned(cb, Element.ALIGN_CENTER, fullTitle, center, y_offset, 0);
精彩评论