C# 背景图像的大小比oryginal*.png大约130%
我正在尝试使用aspose.pdf为.NET 5.0.0版制作一个pdf文件 我的代码如下所示:C# 背景图像的大小比oryginal*.png大约130%,c#,pdf-generation,aspose,C#,Pdf Generation,Aspose,我正在尝试使用aspose.pdf为.NET 5.0.0版制作一个pdf文件 我的代码如下所示: var license = new License(); license.SetLicense("path/My.lic"); var document = new Pdf(); document.Security = new Security(); document.Security.IsAnnotationsMod
var license = new License();
license.SetLicense("path/My.lic");
var document = new Pdf();
document.Security = new Security();
document.Security.IsAnnotationsModifyingAllowed = false;
//Restrict contents modification
document.Security.IsContentsModifyingAllowed = false;
//Restrict copying the data
document.Security.IsCopyingAllowed = false;
//Allow to print the document
document.Security.IsPrintingAllowed = true;
//Restrict form filling
document.Security.IsFormFillingAllowed = false;
document.GraphInfo.Flatness = 1;
Section mainSection = document.Sections.Add();
//var signature = new Image(mainSection);
//signature.ImageInfo.File = "path/MyBackgroundImage.png";
//signature.ImageInfo.ImageFileType = ImageFileType.Png;
mainSection.BackgroundImageFile = "path/MyBackgroundImage.png";
mainSection.BackgroundImageType = ImageFileType.Png;
mainSection.PageInfo.PageWidth = 1052*72*32;//PageSize.A4Width;
mainSection.PageInfo.PageHeight = 744 * 72 * 32;//PageSize.A4Height;
document.SetUnicode();
document.Save("path/Name.pdf");
问题是,即使我以精确的点值传递PageWidth
和PageHeight
值,也会调整应该作为背景图像传递的图像的大小(我发现aspose的大小是以点为单位,而不是以像素为单位。转换取决于图片的dpi,在我的情况下,dpi等于每英寸32,所以:points=pixels*72*32
)
我的图片大小为1052像素宽*744像素,扩展名为32 dpi*.png
我应该在我的代码中做些什么来让它正常工作
如果需要任何进一步的信息,请询问
高级感谢:)您如何知道您的DPI?它是PDF和PNG的一个属性。它们应该匹配。我在png文件的浏览器属性中检查它。Pdf文件不包含dpi这样的值:(