我正在使用 Aspose.Pdf for .NET。
我想做的是:
用 1 层制作 pdf(最好的解决方案是,如果在生成 pdf 之前,所有使用的文本和背景图像都将作为图片,然后生成 pdf) 我需要它来禁止更改我的 pdf 中的内容,简单的安全 pdf 文件是不够的,因为即使是在线 pdf 到 doc 转换器也可以更改内容。
那么现在有办法做到这一点吗? 或者有什么方法可以在将内容放到 pdf 站点之前从内容中制作图像?
我能够生成 pdf,但有多个层(在我的场景中为 2 个)。
我为 .net 4.0 客户端使用了 5.0.0 版的 dll。
提前致谢:)
请您参考如下方法:
使用Aspose.Pdf,您可以对PDF文档设置多个权限来控制它们的使用。使用 Aspose.Pdf 指定安全选项如下,您生成的 Pdf 文档将表现为无法编辑的只读文档:
//Instantiate Pdf instance by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
//Assign a security instance to Pdf object
pdf1.Security = new Aspose.Pdf.Generator.Security();
//Restrict annotation modification
pdf1.Security.IsAnnotationsModifyingAllowed = false;
//Restrict contents modification
pdf1.Security.IsContentsModifyingAllowed = false;
//Restrict copying the data
pdf1.Security.IsCopyingAllowed = false;
//Allow to print the document
pdf1.Security.IsPrintingAllowed = true;
//Restrict form filling
pdf1.Security.IsFormFillingAllowed = false;
//Add a section in the Pdf
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
//Create a text paragraph and set top margin
Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text(sec1,"this is text content");
text1.Margin.Top = 30;
//Add image
Aspose.Pdf.Generator.Image img = new Aspose.Pdf.Generator.Image();
img.ImageInfo.File = "asposelogo.png";
img.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Png;
//Add the text paragraph and image to the section
sec1.Paragraphs.Add(text1);
sec1.Paragraphs.Add(img);
//Save the Pdf
pdf1.Save("test.pdf");
就创建 PDF 的全部内容作为嵌入图像而言,Aspose.Pdf 不直接支持它。但是,您可以使用某种方式或其他组件来生成包含您的内容的图像,然后可以使用此图像使用 Aspose.Pdf 创建 Pdf 文件,如下所示:
- 使用您的内容生成 PDF(您之前创建的多层 PDF)
- 按照 Aspose.Pdf 文档的“Working with Images”部分所述将 PDF 导出为图像。
- 按照“Working with Images(Generator)”中的说明使用导出的图像创建 PDF 并分发您的文档。
我叫 Iqbal,是 Aspose 的开发人员布道师。
