0
我需要在PDF页面上打印一行。我尝试设置绝对坐标这一点,但我的网页是空的:在PDF中打印行
Document doc = new iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 25, 25, 25, 25);
using (var writer = PdfWriter.GetInstance(doc, new FileStream(path + "Report.pdf", FileMode.Create, FileAccess.ReadWrite)))
{
string ttf = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "Futuris Cyrillic.TTF");
BaseFont baseFont = BaseFont.CreateFont(ttf, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
iTextSharp.text.Font font = new iTextSharp.text.Font(baseFont, iTextSharp.text.Font.DEFAULTSIZE, iTextSharp.text.Font.NORMAL);
doc.Open();
doc.NewPage();
doc.Add(new Paragraph("", font));
PdfContentByte cb = writer.DirectContent;
LowHatPrint(cb, 1);
doc.Close();
}
//.......
private void LowHatPrint(PdfContentByte cb, int number)
{
cb.SetLineWidth(4);
cb.SetGrayStroke(1);
cb.MoveTo(0, 0);
cb.LineTo(100, 100);
cb.Stroke();
}
什么是LowHatPrint
问题?
哪来你的页面上书写文本行的颜色? –
也许重复:https://stackoverflow.com/questions/5103404/problem-in-drawing-a-line-in-a-pdf-file-using-itextsharp – STORM
@YairHalberstadt在这一刻只需要线 –