我需要竖排文本或者只是在ITextSharp中旋转ColumnText的一种方式。
(需要是绝对位置)
到目前为止,我已经尝试了很多不同的解决方案,但都没有成功。
下面是几个尝试:
1.
_cb.SetFontAndSize(BaseFont.CreateFont(), 12f);
_cb.ShowTextAligned(Element.ALIGN_CENTER, "Hello World", 50, 50, 90);2.
var vt = new VerticalText(_cb);
vt.SetVerticalLayout(50, 50, 400, 8, 30);
vt.AddText(new Chunk("asdasd",_sf.ChildBackPageTextOneFont()));
vt.Go();3.
System.Drawing.Drawing2D.Matrix foo = new System.Drawing.Drawing2D.Matrix();
foo.Rotate(90);
_cb.ConcatCTM(foo);我也试过用System.Drawing.Graphics画图,但画质很差。
有什么解决方案吗?谢谢。
发布于 2010-12-09 19:10:53
找到了答案:
使用类似如下的内容:
Imports System.Drawing, System.Drawing.Drawing2D
Dim transf as new Matrix
transf.RotateAt(30,New PointF(100,100), MatrixOrder.Append)
writer.DirectContent.Transform(transf)
transf.Invert()
writer.DirectContent.Transform(transf)旋转画布,写一些文字,再旋转回来。
发布于 2014-07-28 10:10:02
为了这个旋转问题,我尝试了很多网络上的方法。但它们都不起作用。最后我想出了一个简单的解决方案。也许我们可以这样做。我们可以画一个没有边框的表格,而且只有一个单元格。我们在单元格中添加文本,最后旋转单元格。那么一切都很好。
table = new PdfPTable(1);
table.TotalWidth = 72;
paragraph = new Paragraph("123");
cell = new PdfPCell(paragraph);
cell.Rotation = 270;
cell.BorderWidth = 0;
table.AddCell(cell);
table.WriteSelectedRows(0, -1, 72, 72, writer.DirectContent);此外,WriteSelectedRows方法可以定位此单元格。
发布于 2012-07-27 19:05:30
实际上,最简单的方法类似于您的第一次尝试。您只需要像这样添加一个对BeginText()和EndText()的调用
_cb.SetFontAndSize(BaseFont.CreateFont(), 12f);
_cb.BeginText();
_cb.ShowTextAligned(Element.ALIGN_CENTER, "Hello World", 50, 50, 90);
_cb.EndText();
_cb.Stroke();https://stackoverflow.com/questions/4389261
复制相似问题