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.
Configure custom context menu items in Context Menu, then handle taps with onCustomContextMenuItemTapped.
onCustomContextMenuItemTapped(identifier, event) passes the custom item identifier separately. The second event argument does not contain identifier.
| Context | Second event argument |
|---|---|
| Screenshot | { image: string }; Base64 without a Data URI prefix. Android encodes PNG, while iOS encodes JPEG at quality 0.85. |
| Text selection | { text: string, rect: CPDFRectF, pageIndex: number } |
| Page long press | { point: { x: number, y: number }, pageIndex: number } |
| Annotation | { annotation: CPDFAnnotation } |
| Content editor | { editArea: CPDFEditArea } |
| Form field | { widget: CPDFWidget } |
annotation, widget, and editArea are converted to SDK class instances. rect and point remain plain JavaScript objects. Image editing also uses the editArea key; there is no imageArea event key.
<CPDFReaderView
ref={pdfReaderRef}
document={samplePDF}
configuration={configuration}
onCustomContextMenuItemTapped={(identifier, event) => {
const annotation = event.annotation as CPDFAnnotation | undefined;
if (annotation) {
console.log(identifier, annotation.type);
}
}}
/>When displaying a screenshot, add the correct Data URI prefix in your application: data:image/png;base64, on Android or data:image/jpeg;base64, on iOS.
For custom toolbar actions, see Custom Toolbar Menu.