使用 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 文件,如下所示:
我叫 Iqbal,是 Aspose 的开发人员布道师。