1. Home
  2. /
  3. GroupDocs.Merger.LowCode
  4. /
  5. Developer Guide
  6. /
  7. Saving Output Documents

Saving Output Documents

Every plugin has one method, Save, which performs the operation and writes the result to the output path you pass. Missing folders in the output path are created, and existing files are overwritten.

Save a Document to a File

The merge plugins and RemovePagesPdf write one document. The following example saves a merged document to a folder that is created automatically.

using System;
using GroupDocs.Merger.Domain.Options;
using GroupDocs.Merger.LowCode;

// Load license keys
var publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY");
var privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY");

// Apply the license
License.Set(publicKey, privateKey);

// Append the second chapter to the first one
var merger = new JoinPdf("chapter-1.pdf", new[] { "chapter-2.pdf" }, new JoinOptions());

// Save to a folder that doesn't exist yet
merger.Save("output/merged/chapters-1-2.pdf");
Imports System
Imports GroupDocs.Merger.Domain.Options
Imports GroupDocs.Merger.LowCode

Module Program
    Sub Main()
        ' Load license keys
        Dim publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")
        Dim privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")

        ' Apply the license
        License.Set(publicKey, privateKey)

        ' Append the second chapter to the first one
        Dim merger As New JoinPdf("chapter-1.pdf", {"chapter-2.pdf"}, New JoinOptions())

        ' Save to a folder that doesn't exist yet
        merger.Save("output/merged/chapters-1-2.pdf")
    End Sub
End Module
open System
open GroupDocs.Merger.Domain.Options
open GroupDocs.Merger.LowCode

[<EntryPoint>]
let main _ =
    // Load license keys
    let publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")
    let privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")

    // Apply the license
    License.Set(publicKey, privateKey)

    // Append the second chapter to the first one
    let merger = JoinPdf("chapter-1.pdf", [ "chapter-2.pdf" ], JoinOptions())

    // Save to a folder that doesn't exist yet
    merger.Save("output/merged/chapters-1-2.pdf")
    0

Expected output: Download chapters-1-2.pdf (12 pages)

Name the Parts of a Split

The split plugins write one document per part, and the output path determines the names of the parts:

  • A plain path. The part number is added to the file name, before the extension: output/business-plan.pdf produces output/business-plan_2.pdf, output/business-plan_4.pdf, and so on.
  • A {0} template. When the file name contains {0}, the part number replaces it: output/page-{0}.pdf produces output/page-2.pdf, output/page-4.pdf, and so on. A {1} in the template is replaced with the extension of the source document.

When you split out specific pages or a range of pages, each part is numbered after the source page it holds. When you split a document at specific pages with SplitMode.Interval, the parts are numbered from 0.

Add the Part Number to the File Name

using System;
using GroupDocs.Merger.LowCode;

// Load license keys
var publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY");
var privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY");

// Apply the license
License.Set(publicKey, privateKey);

// Select pages 2 and 4
var splitter = new SplitPdf("business-plan.pdf", new[] { 2, 4 });

// Save business-plan_2.pdf and business-plan_4.pdf
splitter.Save("output/business-plan.pdf");
Imports System
Imports GroupDocs.Merger.LowCode

Module Program
    Sub Main()
        ' Load license keys
        Dim publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")
        Dim privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")

        ' Apply the license
        License.Set(publicKey, privateKey)

        ' Select pages 2 and 4
        Dim splitter As New SplitPdf("business-plan.pdf", {2, 4})

        ' Save business-plan_2.pdf and business-plan_4.pdf
        splitter.Save("output/business-plan.pdf")
    End Sub
End Module
open System
open GroupDocs.Merger.LowCode

[<EntryPoint>]
let main _ =
    // Load license keys
    let publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")
    let privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")

    // Apply the license
    License.Set(publicKey, privateKey)

    // Select pages 2 and 4
    let splitter = SplitPdf("business-plan.pdf", [| 2; 4 |])

    // Save business-plan_2.pdf and business-plan_4.pdf
    splitter.Save("output/business-plan.pdf")
    0

Expected output: Download plain-names.zip (2 documents)

Use a File Name Template

using System;
using GroupDocs.Merger.LowCode;

// Load license keys
var publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY");
var privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY");

// Apply the license
License.Set(publicKey, privateKey);

// Select pages 2 and 4
var splitter = new SplitPdf("business-plan.pdf", new[] { 2, 4 });

// Save page-2-of-business-plan.pdf and page-4-of-business-plan.pdf
splitter.Save("output/page-{0}-of-business-plan.pdf");
Imports System
Imports GroupDocs.Merger.LowCode

Module Program
    Sub Main()
        ' Load license keys
        Dim publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")
        Dim privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")

        ' Apply the license
        License.Set(publicKey, privateKey)

        ' Select pages 2 and 4
        Dim splitter As New SplitPdf("business-plan.pdf", {2, 4})

        ' Save page-2-of-business-plan.pdf and page-4-of-business-plan.pdf
        splitter.Save("output/page-{0}-of-business-plan.pdf")
    End Sub
End Module
open System
open GroupDocs.Merger.LowCode

[<EntryPoint>]
let main _ =
    // Load license keys
    let publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")
    let privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")

    // Apply the license
    License.Set(publicKey, privateKey)

    // Select pages 2 and 4
    let splitter = SplitPdf("business-plan.pdf", [| 2; 4 |])

    // Save page-2-of-business-plan.pdf and page-4-of-business-plan.pdf
    splitter.Save("output/page-{0}-of-business-plan.pdf")
    0

Expected output: Download template-names.zip (2 documents)

Relative Output Paths

Use an output path that contains a folder, as the examples in this documentation do, or an absolute path. A relative path that contains a folder, such as output/merged.pdf, is resolved against the current directory.

Note
When the output path is only a file name, such as merged.pdf, the plugins save the result to different places: the merge plugins and RemovePagesPdf save it to an Output folder in the application base directory (for example, bin/Debug/net8.0/Output/merged.pdf), while the split plugins save the parts to the current directory.