Merging documents

The merge operation element can be used to merge documents.

 

hint

When a "merge" operation is performed, the pages will not be the only thing merged. Structure elements such as outlines and tags will be merged as well. This can result in name conflicts that prevent a "merge" operation. This behaviour can be controlled with "ignoreConflicts."

 

hint

As of this writing, attempts to "merge" signed PDF documents or PDF/A documents will fail, as this would render the documents (the signature or the PDF/A status) invalid.

 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<operation xmlns="http://schema.webpdf.de/1.0/operation">
<merge mode="afterPage"

        page="1"

        sourceIsZip="true"

        resetMetadata="true"

        outlineName="A/B/a.pdf"

        removeStaticXFA="true">
  <data format="pdf"

         outlineName="A/C/b.pdf">a29J60iOHFQkrn01...JUVPRg0K</data>
</merge>
</operation>

{
"merge": {
  "mode": "afterPage",
  "page": 1,
  "sourceIsZip": true,

   "resetMetadata": true,

   "outlineName": "A/B/a.pdf",

   "removeStaticXFA": true,
  "data": {
    "format": "pdf",
    "value": "a29J60iOHFQkrn01...JUVPRg0K",

     "outlineName": "A/C/b.pdf"
   }
 }
}

 

 

merge element

 

<merge mode="afterPage"

      page="1"

      sourceIsZip="true"

      resetMetadata="true"

      outlineName="A/B/a.pdf"

      removeStaticXFA="true">
  ...
</merge>

"merge": {
"mode": "afterPage",
"page": 1,
"sourceIsZip": true,

 "resetMetadata": true,

 "outlineName": "A/B/a.pdf",

"removeStaticXFA": true,
 ...

}

 

mode (default: "atTheEnd")

Defines the mode used to merge the PDF documents. The PDF document passed with the "data" element will be appended to the current PDF document or inserted at a specific point.

The following modes define the position where the documents will be inserted. Instead of a single base document, the "portfolio" mode always expects a ZIP archive. The elements in this archive will be added, all with identical permissions, to the resulting portfolio (the data element is not required at all for "portfolio”).

 

atTheEnd = At the end of the PDF document

atTheBeginning = At the beginning of the PDF document

afterPage = After a page (please refer to the "page" attribute) in the PDF document

beforePage = Before a page (please refer to the "page" attribute) in the PDF document

 

page (default: 1)

Used to define the page number where the PDF document should be inserted.

 

outlineName (Default: "")

Used to define the basic path that should be selected for the source document’s outlines – this parameter can contain a path and should ideally end with the name of the document (“A/B/filename"). If this parameter is not set, all outlines will be appended to the root element.

 

resetMetadata (Default: false)

If you enable this parameter, new default metadata will be generated for the resulting document instead of the source document’s metadata being carried over.

 

sourceIsZip (Default: false)

If this parameter is enabled, the system will expect for a ZIP archive with the documents being merged to be passed instead of a single base document. In this case, the data element is not required. The first element in the ZIP archive will be used as a base document to which all the other documents in the ZIP archive will be appended.

This option must be used for the "portfolio" mode. All the documents in the ZIP archive will be added to the portfolio with identical permissions.

 

removeStaticXFA (Default: false)

If this parameter is enabled, all entries related to static XFA documents and all connected extended permission settings will be removed from the document. Using this parameter it is possible to merge static XFA documents with other documents, which is normally forbidden by default.

 

hint

Although this parameter allows the merging of static XFA documents, this will not create a valid static XFA document as a result. All structures qualifying a document as a static XFA document will be removed. The resulting document will contain a pure Acroform and will not be recognized as a XFA form by applications for XFA creation/editing. Also, all extended access- and write permissions will be removed (That normally can expected to be found in a static XFA document).

 

 

data element

Contains the file that should be inserted or appended. The file needs to be "BASE64 encoded." The "format" attribute is used to define whether the file is a single PDF document, a ZIP file containing multiple PDF documents or a list of documents references by ID.

 

If a ZIP archive is passed as base document in the Web servirce request, this element can be omitted. The parameter "sourceIsZip" must be set to "true".

 

<data format="pdf"

    outlineName="A/C/b.pdf">a29J60iOHFQkrn01...JUVPRg0K</data>
 

"data": {
"format": "pdf",
"value": "a29J60iOHFQkrn01...JUVPRg0K",

 "outlineName": "A/C/b.pdf"
}

 

format

Specifies the format how to pass the documents to be used for merging.

pdf = A single PDF file

zip = It is a ZIP file that contains one or more PDF documents.

id = It is a semicolon separated list of document ID's referencing documents already on the server (REST API only).

 

hint

The "id" parameter can be used only with REST API. Each document that has been uploaded to the server via REST API has a unique ID. This ID can be used to reference the document. In the content of the "data" element, the list is passed as BASE64 content.

 

Example for two documents:

List of documents: 3bde686a47284a2da3bfce62bd6bb8bd;f5c2b314d0c74fd0878d1f4ca310b0ad

BASE64 encoded: M2JkZTY4NmE0NzI4NGEyZGEzYmZjZTYyYmQ2YmI4YmQ7ZjVjMmIzMTRkMGM3NGZkMDg3OGQxZjRjYTMxMGIwYWQ=

 

 

 

outlineName (Default: "")

Used to define the basic path that should be selected for the outlines of the document being appended – this parameter can contain a path and should ideally end with the name of the document (“A/B/filename"). If this parameter is not set, all outlines will be appended to the root element.