简体   繁体   English

使用Aspose.Pdf库制作1层pdf

[英]Make 1 layer pdf with use Aspose.Pdf library

I'm using Aspose.Pdf for .NET. 我正在使用Aspose.Pdf for .NET。

What I'm trying to do is: 我想要做的是:

Make pdf with 1 layer (best solution would be if before generate pdf all used text and bacground image would be as picture and then generated pdf) I need it for prohibit changing content in my pdf simple secure pdf file isn't enough, because even online pdf to doc converters enable to change content. 制作pdf 1层(最好的解决方案是如果在生成pdf之前所有使用的文本和bacground图像将作为图片然后生成pdf)我需要它来禁止更改我的pdf中的内容简单的安全pdf文件是不够的,因为甚至在线pdf到doc转换器可以更改内容。

So is there a way to do this now? 那么现在有办法做到这一点吗? Or is there any way for make image from content before put it on site of pdf? 或者在将它放到pdf网站之前有没有办法从内容制作图像?

I was able to generate pdf but with multiple layers (2 in my scenario). 我能够生成pdf,但有多个层(在我的场景中为2)。

I've use dll version 5.0.0 for .net 4.0 Client. 我使用dll版本5.0.0 for .net 4.0 Client。

Thanks in advance:) 提前致谢:)

Using Aspose.Pdf, you can set several privileges on the PDF documents to control their use. 使用Aspose.Pdf,您可以在PDF文档上设置多个权限以控制其使用。 Specify the security options as follows using Aspose.Pdf and the Pdf document you have generated will behave as a readonly document which could not be edited: 使用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");

As far as creating the whole content of PDF as an embedded image, it is not directly supported in Aspose.Pdf. 至于将PDF的整个内容创建为嵌入图像,Aspose.Pdf不直接支持它。 You can however use some way around or some other component to generate image with your content and then can use this image to create Pdf file using Aspose.Pdf as follows: 但是,您可以使用某种方式或其他组件来生成包含内容的图像,然后可以使用此图像使用Aspose.Pdf创建Pdf文件,如下所示:

  • Generate PDF with your content (A multi layer PDF as you have created earlier) 使用您的内容生成PDF(您之前创建的多层PDF)
  • Export the PDF to image as described in " Working with Images " section of Aspose.Pdf documentation. 按照Aspose.Pdf文档的“ 使用图像 ”部分所述将PDF导出到图像。
  • Use exported image to create PDF as described in " Working with Images(Generator) " and distribute your document. 使用导出的图像创建PDF,如“ 使用图像(生成器) ”中所述并分发文档。

My name is Iqbal and I am developer evangelist at Aspose. 我的名字是伊克巴尔,我是Aspose的开发人员传道者。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM