用drawstring输出中文,设置了truetype中文字体字体,结果中文都是乱码。
还有,先用drawimage输出个照片,然后在这上面drawstring,也看不到文字
System.Drawing.Font font = new System.Drawing.Font("幼圆", 22, FontStyle.Regular);
PdfTrueTypeFont trueTypeFont = new PdfTrueTypeFont(font);
PdfSolidBrush brush = new PdfSolidBrush(Color.Black);
page.Canvas.DrawString("企业ID:", trueTypeFont, brush, BaseX, BaseY);
amy.zhao wrote:Hi,
为了帮助我们了解你的问题尽快的提供你解决方案,请提供你的完整代码和使用的图片,文本数据, 谢谢你的帮助。
Best Regards,
Amy
E-iceblue support team
amy.zhao wrote:Hi,
请使用 PdfTrueTypeFont trueTypeFont = new PdfTrueTypeFont(font,true).
Best Regards,
Amy
E-iceblue support team
PdfDocument doc = new PdfDocument();
PdfPageBase page = doc.Pages.Add();
Font font = new System.Drawing.Font("宋体", 25, FontStyle.Regular);
PdfTrueTypeFont trueTypeFont = new PdfTrueTypeFont(font, true);
PdfTilingBrush brush= new PdfTilingBrush(new SizeF(page.Canvas.ClientSize.Width / 2, page.Canvas.ClientSize.Height / 3));
brush.Graphics.SetTransparency(0.3f);
brush.Graphics.Save();
brush.Graphics.TranslateTransform(brush.Size.Width / 2, brush.Size.Height / 2);
brush.Graphics.RotateTransform(-45);
brush.Graphics.DrawString("宋培", trueTypeFont, PdfBrushes.Green, 0, 0, new PdfStringFormat(PdfTextAlignment.Center));
brush.Graphics.Restore();
brush.Graphics.SetTransparency(1);
page.Canvas.DrawRectangle(brush, new RectangleF(new PointF(0, 0), page.Canvas.ClientSize));
doc.SaveToFile("result.pdf", FileFormat.PDF);