gpt4 book ai didi

c# - 将图像导出为 PDF

转载 作者:太空狗 更新时间:2023-10-29 23:47:37 24 4
gpt4 key购买 nike

我有一个项目必须将图像导出为 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

关于c# - 将图像导出为 PDF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8875946/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com