Creating PDF documents
The Scanbot Web SDK offers functionality for PDF generation. Create the appropriate generator as follows:
const options: Partial<PdfConfiguration> = { pageSize: "A4", pageDirection: "PORTRAIT", pageFit: "FIT_IN", dpi: 72, jpegQuality: 80 };
const generator = await scanbotSDK.beginPdf(options);
Options
See the API reference for a list of available options and how they play together.
Adding individual pages
You can add individual images to your PDF document:
await generator.addPage(image);
Adding all pages of a document
If you obtained a document from the RTU UI, you can add all pages at once:
await generator.addPages(document);
When all images have been added, complete
the transaction and receive the resulting byte array:
const bytes = await generator.complete();
As an example, you can force the PDF download of the pages in the browser via:
function saveBytes(data, name) {
const extension = name.split(".")[1];
const a = document.createElement("a");
document.body.appendChild(a);
a.style = "display: none";
const blob = new Blob([data], {type: `application/${extension}`});
const url = window.URL.createObjectURL(blob);
a.href = url;
a.download = name;
a.click();
window.URL.revokeObjectURL(url);
}
And then call it as such:
saveBytes(bytes, "generated.pdf");
Want to scan longer than one minute?
Generate a free trial license to test the Scanbot SDK thoroughly.
Get your free Trial License