2013-03-19 30 views
1

我使用Aspose.Pdf for .NET。使用Aspose.Pdf庫製作1層pdf

我試圖做的是:

與1層製作PDF(最好的解決辦法是,如果之前生成PDF所有使用的文本和圖像bacground將如圖片,然後生成的PDF) 我需要它禁止更改我的pdf內容簡單安全的PDF文件是不夠的,因爲即使在線PDF到DOC轉換器可以改變內容。

那麼現在有辦法做到這一點嗎? 或者是否有任何方法可以使圖像從內容製作成PDF之前?

我能夠生成pdf,但有多個圖層(在我的場景中爲2)。

我對.net 4.0客戶端使用dll版本5.0.0。

感謝提前:)

回答

4

使用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如前所述)
  • 將PDF導出爲圖像,如Aspose.Pdf文檔的「Working with Images」部分所述。
  • 使用導出的圖像創建PDF,如「Working with Images(Generator)」中所述,並分發您的文檔。

我的名字是Iqbal,我是Aspose的開發者傳道人。

+0

但你說關於最新版本。我使用舊的5.0.0。我指出,在我的問題:( – harry180