It is not possible to merge existing PDFs together with PDFreactor without generating a PDF from an HTML source document. However, there is a workaround for that. You can convert an empty HTML document to PDF and then merge existing PDFs with it. This can be done using the following code:


Java

PDFreactor pr = new PDFreactor();
Configuration conf = new Configuration();

// An "empty" HTML document
conf.setDocument("<html>");

// Make the document really small so that the PDFs can overlay it
conf.setUserStyleSheets(new Resource().setContent("@page { size: 1in 1in; }"));

// Set merge mode to "Overlay" to overlay the "empty" page over the existing PDFs
conf.setMergeMode(MergeMode.OVERLAY);

// Merge the existing PDFs
conf.setMergeDocuments(
    new Resource().setUri("url/to/documentA.pdf"),
    new Resource().setUri("url/to/documentB.pdf"),
    new Resource().setUri("url/to/documentC.pdf"));

pr.convertAsBinary(conf);

C#

PDFreactor pr = new PDFreactor();
Configuration conf = new Configuration();

// An "empty" HTML document
conf.Document = "<html>";

// Make the document really small so that the PDFs can overlay it
conf.UserStyleSheets = new List<Resource>
{
    new Resource { Content = "@page { size: 1in 1in; }" }
};

// Set merge mode to "Overlay" to overlay the "empty" page over the existing PDFs
conf.MergeMode = MergeMode.OVERLAY;

// Merge the existing PDFs
conf.MergeDocuments = new List<Resource>
{
    new Resource { Uri = "url/to/documentA.pdf" },
    new Resource { Uri = "url/to/documentB.pdf" },
    new Resource { Uri = "url/to/documentC.pdf" }
};

pr.ConvertAsBinary(conf);

PHP

$pr = new PDFreactor();
$conf = array();

// An "empty" HTML document
$conf["document"] = "<html>";

// Make the document really small so that the PDFs can overlay it
$conf["userStyleSheets"] = array(
    array( "content" => "@page { size: 1in 1in; }" )
);

// Set merge mode to "Overlay" to overlay the "empty" page over the existing PDFs
$conf["mergeMode"] = MergeMode::OVERLAY;

// Merge the existing PDFs
$conf["mergeDocuments"] = array(
    array( "uri" => "url/to/documentA.pdf" ),
    array( "uri" => "url/to/documentB.pdf" ),
    array( "uri" => "url/to/documentC.pdf" )
);

$pr->convertAsBinary($conf);

JavaScript/Node.js

pr = new PDFreactor();
conf = {};

// An "empty" HTML document
conf.document = "<html>";

// Make the document really small so that the PDFs can overlay it
conf.userStyleSheets = [
    { content: "@page { size: 1in 1in; }" }
];

// Set merge mode to "Overlay" to overlay the "empty" page over the existing PDFs
conf.mergeMode = PDFreactor.MergeMode.OVERLAY;

// Merge the existing PDFs
conf.mergeDocuments = [
    { uri: "url/to/documentA.pdf" },
    { uri: "url/to/documentB.pdf" },
    { uri: "url/to/documentC.pdf" }
];

pr.convertAsBinary(conf);

Python

pr = PDFreactor()
conf = {}

# An "empty" HTML document
conf["document"] = "<html>"

# Make the document really small so that the PDFs can overlay it
conf["userStyleSheets"] = [
    { "content": "@page { size: 1in 1in; }" }
]

# Set merge mode to "Overlay" to overlay the "empty" page over the existing PDFs
conf["mergeMode"] = PDFreactor.MergeMode.OVERLAY

# Merge the existing PDFs
conf["mergeDocuments"] = [
    { "uri": "url/to/documentA.pdf" },
    { "uri": "url/to/documentB.pdf" },
    { "uri": "url/to/documentC.pdf" }
]

pr.convertAsBinary(conf)

Ruby

pr = PDFreactor.new()
conf = {}

# An "empty" HTML document
conf["document"] = "<html>"

# Make the document really small so that the PDFs can overlay it
conf["userStyleSheets"] = [
    { content: "@page { size: 1in 1in; }" }
]

# Set merge mode to "Overlay" to overlay the "empty" page over the existing PDFs
conf["mergeMode"] = PDFreactor::MergeMode::OVERLAY

# Merge the existing PDFs
conf["mergeDocuments"] = [
    { uri: "url/to/documentA.pdf" },
    { uri: "url/to/documentB.pdf" },
    { uri: "url/to/documentC.pdf" }
]

pr.convertAsBinary(conf)

Perl

$pr = PDFreactor->new();
$conf = {};

# An "empty" HTML document
$conf["document"] = "<html>";

# Make the document really small so that the PDFs can overlay it
$conf["userStyleSheets"] = [
    { "content" => "@page { size: 1in 1in; }" }
];

# Set merge mode to "Overlay" to overlay the "empty" page over the existing PDFs
$conf["mergeMode"] = PDFreactor::MergeMode->OVERLAY;

# Merge the existing PDFs
$conf["mergeDocuments"] = [
    { "uri" => "url/to/documentA.pdf" },
    { "uri" => "url/to/documentB.pdf" },
    { "uri" => "url/to/documentC.pdf" }
];

$pr->convertAsBinary($conf);

REST

{ "document": "<html>", "userStyleSheets": [{ "content": "@page { size: 1in 1in; }" }], "mergeMode": "OVERLAY", "mergeDocuments": [{ "uri": "url/to/documentA.pdf" }, { "uri": "url/to/documentB.pdf" }, { "uri": "url/to/documentC.pdf" }] }