/ / Aspose.Pdfライブラリを使用して1層のPDFにする - c#、pdf-generation、aspose

Aspose.Pdfライブラリを使用して1層のPDFを作成する - c#、pdf-generation、aspose

私はAspose.Pdf for .NETを使用しています。

私がしようとしているのは、

1層でPDFを作成する(最良の解決方法はifpdfを生成する前に、すべての使用されているテキストと背景画像が画像として表示され、pdfが生成されます) 私はpdf簡単な安全なpdfファイルでコンテンツを変更することを禁止するために必要なのは、オンラインのpdfからdocへのコンバータでさえ、コンテンツを変更できるので十分ではありません。

今これを行う方法はありますか? それとも、pdfのサイトに置く前にコンテンツから画像を作るための方法はありますか?

私はpdfを生成することができましたが、複数のレイヤーを使用することができました(私のシナリオでは2つ)。

私は、.net 4.0クライアント用にdllバージョン5.0.0を使用しています。

前もって感謝します:)

回答:

回答№1は4

Asposeを使う。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のドキュメントのセクションを参照してください。
  • エクスポートされたイメージを使用してPDFを作成するには、イメージの操作(ジェネレータ)あなたの文書を配布してください。

私の名前はIqbalで、私はAsposeの開発者エバンジェリストです。