PDFドキュメントをプログラムで保存

次のコードスニペットは、Aspose.Drawingライブラリでも動作します。

PDFドキュメントをファイルシステムに保存

DocumentクラスのSaveメソッドを使用して、作成または操作されたPDFドキュメントをファイルシステムに保存できます。 フォーマットタイプ(オプション)を指定しない場合、ドキュメントはAspose.PDF v.1.7(*.pdf)形式で保存されます。

// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void SaveDocument()
{
    // The path to the documents directory
    var dataDir = RunExamples.GetDataDir_AsposePdf();

    // Open PDF document
    using (var document = new Aspose.Pdf.Document(dataDir + "SimpleResume.pdf"))
    {
        // Make some manipation, i.g add new empty page
        document.Pages.Add();
        // Save PDF document
        document.Save(dataDir + "SimpleResume_out.pdf");
    }
}

PDFドキュメントをストリームに保存

Saveメソッドのオーバーロードを使用して、作成または操作されたPDFドキュメントをストリームに保存することもできます。

// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void SaveDocumentStream()
{
    // The path to the documents directory
    var dataDir = RunExamples.GetDataDir_AsposePdf();

    // Open PDF document
    using (var document = new Aspose.Pdf.Document(dataDir + "SimpleResume.pdf"))
    {
        // Make some manipation, i.g add new empty page
        document.Pages.Add();
        // Save PDF document
        document.Save(dataDir + "SimpleResume_out.pdf");
    }
}

詳細な説明については、Showcaseセクションをご覧ください。

PDF/AまたはPDF/X形式で保存

PDF/Aは、電子文書のアーカイブおよび長期保存のために使用されるポータブルドキュメントフォーマット(PDF)のISO標準化されたバージョンです。 PDF/Aは、フォントリンク(フォント埋め込みとは対照的)や暗号化など、長期保存に適さない機能を禁止している点でPDFとは異なります。PDF/AビューアのISO要件には、カラー管理ガイドライン、埋め込まれたフォントのサポート、および埋め込まれた注釈を読むためのユーザーインターフェースが含まれます。

PDF/XはPDF ISO標準のサブセットです。PDF/Xの目的はグラフィックス交換を促進することであり、そのため、標準PDFファイルには適用されない一連の印刷関連の要件があります。

いずれの場合も、Saveメソッドを使用してドキュメントを保存し、ドキュメントはConvertメソッドを使用して準備する必要があります。

// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void SaveDocumentAsPDFx()
{
    // The path to the documents directory
    var dataDir = RunExamples.GetDataDir_AsposePdf();

    // Open PDF document
    using (var document = new Aspose.Pdf.Document(dataDir + "SimpleResume.pdf"))
    {
        // Add page
        document.Pages.Add();
        // Convert a document to a PDF/X-3 format
        document.Convert(new Aspose.Pdf.PdfFormatConversionOptions(Aspose.Pdf.PdfFormat.PDF_X_3));
        // Save PDF document
        document.Save(dataDir + "SimpleResume_X3.pdf");
    }
}