【问题标题】:Export Images to PDF将图像导出为 PDF
【发布时间】: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


【解决方案1】:

必须是 SilverPDF 吗?正如我之前在我以前的雇主使用 iTextSharp 库做过类似的事情(否则我会粘贴示例代码)

iTextSharp-Working-with-images

Download Link

【讨论】:

  • 我不能使用它们,它们不是针对 Silverlight 运行时构建的。对我来说是个大问题。
  • 我现在正在使用它们。我刚刚在 .Web 应用程序中创建了项目,然后将其按字节传递给 Silverlight 应用程序进行保存。感谢您的帮助!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-12-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-09-05
相关资源
最近更新 更多