如何将图像转换为单个pdf? [英] How to convert images to single pdf?
本文介绍了如何将图像转换为单个pdf?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在一个文件夹中有多个图像。我想在c#中找到该文件夹,然后所有图像都成为单个pdf。
我如何使用免费组件?
I have number of images in a folder.I want to address the folder in c# and then all the images become a single pdf.
How can I do it with free component?
推荐答案
试着看看
将图像文件转换为PDF [ ^ ]
我正在使用PDFSharp。如果您使用它,那么您可以尝试以下代码:
I am using PDFSharp. If you use it then you can try the following code:
using(PdfDocument doc = new PdfDocument())
{
using(Image myimage = Image.FromFile(ImageFilePath))
{
PdfPage page = new PdfPage();
page.Width = myimage.Width + 20;
page.Height = myimage.Height + 20;
doc.Pages.Add(page);
XGraphics xgr = XGraphics.FromPdfPage(doc.Pages[0]);
XImage img = XImage.FromFile(fileName);
xgr.DrawImage(img, 10, 10, myimage.Width, myimage.Height);
doc.Save(PathToSavePDFDoc);
doc.Close();
}
}
要获取有关PDFSharp的信息,请转到 http://www.pdfsharp.net/wiki/ [ ^ ]
这篇关于如何将图像转换为单个pdf?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文