我们希望以程序化的方式将大量图像转换为PDF。目前看来,我们将使用iTextSharp,但是我们在处理带有剪切路径的JPG图像时遇到了问题。在我们的测试中,我们正在使用以下代码:
在JPG图像中,剪辑路径似乎只是被丢弃了。有没有办法保留剪辑路径?此外,在调用AddImage时,有一个名为InlineImage的选项,有人知道这是什么吗?
using (FileStream fs = new FileStream(output, FileMode.Create, FileAccess.Write, FileShare.None))
{
using (Document doc = new Document())
{
using (PdfWriter writer = PdfWriter.GetInstance(doc, fs))
{
doc.Open();
iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(source);
image.SetAbsolutePosition(0, 0);
doc.SetPageSize(new iTextSharp.text.Rectangle(0, 0, image.Width, image.Height, 0));
doc.NewPage();
writer.DirectContent.AddImage(image,false);
doc.Close();
}
}
}
在JPG图像中,剪辑路径似乎只是被丢弃了。有没有办法保留剪辑路径?此外,在调用AddImage时,有一个名为InlineImage的选项,有人知道这是什么吗?