SaveDocumentVPDF

Description

Saves the PDF document.

The SaveDocumentVPDF will add the text of the PDF to preserve text selection capabilities and searchability and will flatten (burn in) the PDF Forms if there are any.

The saving operation will apply the pdfScale to the page sizes and positions, merge the rendered PDF page with the flattened annotations (PDF Forms), add the Text Objects, then finally apply the pdfPw password if it’s not empty.

Method Type POST
URL api/dm/save-pdf
Parameters
Name Type Description
DocumentID Object

The specified document’s DocumentID.

The DocumentID can be any object, for example an absolute path of a file, or a database row ID. The specified Content-Engine will interpret the DocumentID and serve the document.

savePages List<string> List of the pages in base64 string.
savePageInfos List<bihtml5BASE.PageInfo> List of the page information of each page.
pdfTextObjects List<List<bihtml5PDF.TextItem>> List of the Text Objects of the PDF for each page.
pdfAnnotations List<List<bihtml5PDF.PDFFormAnnotation>> List of the PDF Annotations of the PDF for each page.
pdfAnnotationsFlatten List<string> List of the flattened PDF annotations for each page in base64 string.
pdfPw String The original password, if the PDF was password-protected.
pdfScale Int The scaling adjustment (multiplier) was used when opening the PDF. The
CE (Optional) String

The Specified Content-Engine.

Possible values:

0: Default Content-Engine (default)

1: FileEngine

2: DatabaseEngine

Response Type JSON (JsonResult)
Return values

{

uploadResponse (bihtml5BASE.UploadResponse)

}

Programming notes

None

Example

JavaScript Example

// Promise function for Saving PDF document with text and annotations (forms)

const SaveVectorPDF = () => {

return new Promise((resolve, reject) => {

$.ajax({

type: "POST",

url: API_SaveDocumentVPDF, /* Ajax/SaveDocumentVPDF.cshtml */

cache: false,

data: {

savePages: JSON.stringify(Pages), // Array of base64 page

savePageInfos: JSON.stringify(PageInformation), // Array of PageInformation objects

pdfPw: pdfPassword, // Original PDF password

pdfAnnotations: JSON.stringify(PDFFields), // Array of PDFAnnotations objects

pdfAnnotationsFlatten: JSON.stringify(FlattenPDFs), // Array of flattened PDFAnnotation objects

pdfTextObjects: JSON.stringify(PDFPages), // Array of PDFTextObjects objects

pdfScale: scale // The scaling factor used to render the PDF. By default its 3

},

success: function (r) {

resolve(r); // return promise with the received memory handle

},

error: function (xhr, textStatus, message) {

// handle error

reject(message); // reject promise if failed

}

});

})

};

// Example for chaining the steps of the saving

function Save() {

// Flattening the PDF form fields

FlattenPDF().then(

(result) => {

// Saving the PDF document

SaveVectorPDF().then(

(handle) => {

// Updating the document using the Content-Engine

UpdateDocument(handle).then(

(result) => {

console.log("Saving finished.");

}

)

}

)

}

)

}

Requirements