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.
ComPDF Conversion SDK supports converting PDF documents to OFD documents. Similar to searchable PDF, OFD conversion also supports OCR, page background preservation, and transparent text layers.
This format uses only the following options of OfdOptions; the other options have no effect:
| Option | Default | Meaning |
|---|---|---|
EnableOCR | false | The text layer comes from OCR on the pages chosen by OcrOption; when off, it comes from the text of the PDF. Image input without OCR has no text layer. Ignored if the license does not include OCR. |
OcrOption | OCROption.e_All | Which content OCR handles: OCROption.e_All every page; OCROption.e_ScanPage only image (scanned) pages; OCROption.e_InvalidCharacter re-recognizes unreadable characters of the text layer on the other pages; OCROption.e_InvalidCharacterAndScanPage both. Only takes effect when EnableOCR is on. |
Languages | { OCRLanguage.e_ENGLISH } | OCR recognition languages; when no language is given, English is used. Only takes effect when EnableOCR is on. |
EnableDocumentOrientationClassification | false | Turns the page image upright before OCR; the page size follows the rotation. Only takes effect when EnableOCR is on. |
EnableDocumentDewarp | false | Flattens curved or warped page photos before OCR. Only takes effect when EnableOCR is on. |
PageRanges | Empty | Pages to convert, e.g. "1-3,5,7-9"; empty converts every page. For multi-frame image input it selects the frames. |
OutputDocumentPerPage | false | Writes one file per page instead of one document. The files are named after the input file plus the page number and are written to the folder of the output path; the file name in the output path is not used. |
EnableAutoPageSize | false | Image input only: sizes the page from the image resolution, matched to the nearest standard paper size; when off, one image pixel becomes one point. |
CustomPageWidth / CustomPageHeight | 0 | Image input only: exact page width and height in points (1 pt = 1/72 inch); both must be greater than 0. The image is fitted inside with white padding. Takes precedence over EnableAutoPageSize. |
Example:
OfdOptions ofdOptions = new OfdOptions();
ofdOptions.EnableOCR = true;
ofdOptions.EnableDocumentOrientationClassification = true;
ofdOptions.OutputDocumentPerPage = true;
ErrorCode error = CPDFConversion.StartPDFToOfd("input.pdf", "password", "path/output.ofd", ofdOptions);string inputFilePath = "***";
string password = "***";
string outputFileName = "***";
PdfOptions ofdOptions = new OfdOptions();
ofdOptions.EnableOCR = true;
ofdOptions.Languages = new List<OCRLanguage> { OCRLanguage.e_ENGLISH };
ErrorCode error = CPDFConversion.StartPDFToOfd(inputFilePath, password, outputFileName, ofdOptions);