我正在尝试将图像文件转换为具有定义页面大小(字母大小)的 PDF 文档。
当前,我能够将图像转换为 PDF 文档而无需定义任何页面尺寸(PDF 的默认尺寸是图像大小)。我想在创建文档时定义页面尺寸,并将图像放在该页面上(可能带有边距)。
以下代码片段显示了我当前如何在不为页面设置任何尺寸的情况下将图像文件转换为 PDF 文档:
async static Task<bool> ConvertImageToPDF(TestFile file)
{
pdftron.PDF.PDFDoc pdfdoc = new PDFDoc(); //Initialize a new PDF document
pdftron.PDF.Convert.ToPdf(pdfdoc, file.InputFile); //Use the Convert.ToPdf to generate the file from the image file
await pdfdoc.SaveAsync(file.OutputFile, SDFDocSaveOptions.e_linearized); //Save the PDF document generated from the conversion
pdfdoc.Destroy();
pdfdoc = null;
}
任何有关为 PDF 页面分配尺寸(字母大小)以及在该页面中插入图像文件的帮助或指导都将受到欢迎。