Skip to main content

Creating PDF Documents | Capacitor Document Scanner

ScanbotSDK.createPDF(args: CreatePDFArguments): Promise<ResultWrapper<CreatePDFResult>>;

export interface CreatePDFArguments {
imageFileUris: string[];
options?: {
pageSize?: PDFPageSize;
pageOrientation?: PDFPageOrientation;
metadata?: PDFMetadata;
};
}

Renders the given image files into a PDF document and stores it as a file. For each image, a separate page is generated.

Typically, the final hi-res document image files of the scanned Pages (documentImageFileUri) are used to generate the PDF file.

import { ScanbotSDK, Page } from 'capacitor-plugin-scanbot-sdk';
// Always make sure you have a valid license on runtime via ScanbotSDK.getLicenseInfo()
if (!licenseCheckMethod()) { return; }

const result = await ScanbotSDK.createPDF({
imageFileUris: this.scannedPages.map(p => p.documentImageFileUri),
pageSize: 'FIXED_A4'
});

// use the PDF file URI from result, e.g.:
await uploadPdf(result.pdfFileUri);

Input args:

  • imageFileUris: Input images as an array of file URIs in proper order (image element 1 => page 1, etc).
  • options: Additional configurable options
    • pageSize: PDF page size enum value to specify the output page size. See below.
    • pageOrientation : Set orientation of the PDF page.
    • metadata : Associated metadata with the created PDF.

Result:

  • pdfFileUri: File URI of the PDF result file ('file:///...').

Supported PDF Page Sizes

  • A3: represents 297 x 420 (mm) page size. The image is fitted and centered within the page.
  • A4: represents 210 x 297 (mm) page size. The image is fitted and centered within the page.
  • A5: represents 148 x 210 (mm) page size. The image is fitted and centered within the page.
  • B4: represents 250 x 353 (mm) page size. The image is fitted and centered within the page.
  • B5: represents 176 x 250 (mm) page size. The image is fitted and centered within the page.
  • COMM10: represents 4.125 x 9.5 (inches) page size. The image is fitted and centered within the page.
  • CUSTOM: represents a custom page size. Each page is as large as its image at 72 dpi.
  • EXECUTIVE: represents 7.25 x 10.5 (inches) page size. The image is fitted and centered within the page.
  • LEGAL: represents 8.5 x 14 (inches) page size. The image is fitted and centered within the page.
  • LETTER: represents 8.5 x 11 (inches) page size. The image is fitted and centered within the page.
  • US4x6: represents 4 x 6 (inches) page size. The image is fitted and centered within the page.
  • US4x8: represents 4 x 8 (inches) page size. The image is fitted and centered within the page.
  • US5x7: represents 5 x 7 (inches) page size. The image is fitted and centered within the page.
PDF with OCR

If you need to generate a searchable PDF file with a text layer, please refer to the "OCR" section.

Want to scan longer than one minute?

Generate your free "no-strings-attached" Trial License and properly test the Scanbot SDK.

Get your free Trial License

What do you think of this documentation?


On this page

Scroll to top