c# – 将图像导出为PDF
发布时间:2020-12-15 21:29:21 所属栏目:百科 来源:网络整理
导读:我有一个项目必须将图像导出为PDF.图像和文本都需要导出为pdf.有没有办法通过使用silverPDF.dll和PdfReader来做到这一点? 代码在这里. private void btnOutlook_Click(object sender,System.Windows.RoutedEventArgs e) { XBrush xbrush; SaveFileDialog sa
我有一个项目必须将图像导出为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吗?我之前使用iTextSharp库在我以前的雇主做过类似的事情(否则我会粘贴示例代码)
iTextSharp-Working-with-images Download Link (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |