【发布时间】:2012-01-16 05:00:39
【问题描述】:
我有一个项目必须将图像导出为 PDF。需要将图像和文本等导出为 pdf。有没有办法通过使用 silverPDF.dll 和 PdfReader 来做到这一点?
代码在这里。
private void btnOutlook_Click(object sender, System.Windows.RoutedEventArgs e)
{
XBrush xbrush;
SaveFileDialog savePDF = new SaveFileDialog();
savePDF.Filter = "PDF file format | *.pdf";
if (savePDF.ShowDialog() == true)
{
PdfDocument document = new PdfDocument();
PdfPage page = document.AddPage();
XGraphics gfx = XGraphics.FromPdfPage(page);
XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);
XFont font = new XFont("Huxtable", 20, XFontStyle.Bold, options);
for (int x = 0; x < 10; x++)
{
if (x % 2 == 0)
{
xbrush = XBrushes.Red;
}
else
xbrush = XBrushes.Black;
gfx.DrawString(string.Format("{0}", stringArray[x]), font, xbrush, new XRect(0, (x * 20), page.Width, page.Height), XStringFormats.TopLeft);
}
document.Save(savePDF.OpenFile());
}
}
我可以在这段代码中的什么位置插入将其插入 pdf 的图像?有什么办法吗?感谢所有回复。
【问题讨论】:
-
我对 SilverPDF 一无所知,但是网上有几个使用其他实用程序类的教程。 Here's 一个。
标签: c# pdf silverlight-5.0