Edit PDF
PDF editing provides the ability to change content so that its data can be improved or re-purposed.
- Create, move, or delete text and images.
- Edit text and images properties.
- Undo or redo any change.
- Customize the menu of text editing.
When editing PDF, other operations are not supported like adding or deleting annotations, adding watermarks, modifying form properties, etc.
PDF editing supports the following editing modes:
- Text Mode. In text mode, the text blocks surrounded by dotted lines will be displayed in the PDF document, then you can copy, paste, add, or delete text.
- Image Mode. In image mode, the images surrounded by dotted lines will be displayed in the PDF document, then you can delete, crop, rotate, mirror, replace, save images, or set transparency.
- Text-Image Mode. In text-image mode, the text blocks and images surrounded by dotted lines will be displayed in the PDF document, then you can edit text and images.
Initialize the Editing Mode
Before editing, you should initialize editing mode. ComPDFKit provides methods to initialize editing mode. The following code shows you how to initialize the editing mode:
NSURL *url = [NSURL fileURLWithPath:pdfPath];
CPDFDocument *document = [[[CPDFDocument alloc] initWithURL:url] autorelease];
CPDFView *pdfView = [[[CPDFView alloc] initWithFrame:self.view.bounds] autorelease];
// Set the document to display
pdfView.document = document;
// Begin editing text.
[viewer beginEditingLoadType:CEditingLoadTypeText]
ComPDFKit provides the ability to customize the look and feel in editing mode. You can modify the display effect according to your needs, such as the width of text block border, the color of text block border, and more. The following code shows how to customize the look in edit mode:
CPDFEditingConfig *editingConfig = [[CPDFEditingConfig alloc]init];
editingConfig.editingBorderWidth = 1.0;
editingConfig.editingBorderColor = [CPDFKitPlatformColor redColor];
pdfView.editingConfig = editingConfig;