我也跟着垂直文本的iText的樣品:iTextSharp的和VerticalText
http://1t3xt.info/examples/browse/?page=example&id=145
,創造了它這個C#版本:
PdfReader reader = new PdfReader("existing.pdf");
PdfStamper stamp = new PdfStamper(reader, new FileStream("stamped.pdf", FileMode.Create));
// change the content on top of page 1
PdfContentByte cb = stamp.GetOverContent(1);
Rectangle psize = reader.GetPageSize(1);
float width = psize.Width;
float height = psize.Height;
BaseFont bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
VerticalText vt = new VerticalText(cb);
vt.SetVerticalLayout(width/2, height/2, height, 1, 0);
vt.AddText(new Phrase("Test", new Font(bf, 20)));
vt.Go();
stamp.Close();
它在頁面上居中,好的,但它不是垂直的 - 而是水平的(實際上左對齊頁面中心水平)。
我在這裏做錯了什麼或者是iTextSharp行爲不當?
PS:示例已移動(或在其他位置替換):http://itextpdf.com/examples/iia.php?id=202 – 2010-12-21 17:50:04