PDF Generation Template Editor
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
Before conversion, finish loading the document and prepare a writable output path different from the source. Its parent directory must exist.
import { CPDFReaderView } from '@compdfkit_pdf_sdk/react_native';
async function convertStandard(reader: CPDFReaderView, outputPath: string) {
const document = reader._pdfDocument;
const currentType = await document.getPdfStandardType();
if (!await reader.save()) throw new Error('Failed to save the document');
const success = await document.convertToPdfStandard(
outputPath, 'pdf_a_2b', true,
);
if (!success) throw new Error('PDF standard conversion failed');
return { currentType, outputPath };
}getPdfStandardType() reads the document's declared standard; it does not perform a full conformance check. convertToPdfStandard(outputPath, type, fontSubset) returns boolean. fontSubset defaults to true and controls font subsetting when saving.
| Standard | type |
|---|---|
| PDF/A-1 | pdf_a_1a, pdf_a_1b |
| PDF/A-2 | pdf_a_2a, pdf_a_2u, pdf_a_2b |
| PDF/A-3 | pdf_a_3a, pdf_a_3u, pdf_a_3b |
| PDF/X | pdf_x_1a, pdf_x_3, pdf_x_4 |
| PDF/E | pdf_e_1 |
| PDF/UA | pdf_ua_1 |
| PDF/VT | pdf_vt_1, pdf_vt_2 |
saveAs(path, true, true) to output an unencrypted copy, then open that copy for conversion. Obtain the necessary document permissions first.content:// URIs with write access.document.open(outputPath) if needed, then read the type or inspect the output.false or reject the Promise. Use the output only after confirming success.