Skip to content
Guides

Edit Text and Image Properties

ComPDFKit offers various methods to modify text and image attributes.

Edit Text Properties

ComPDFKit supports modifying text properties, such as text font size, name, color, alignment, italics, bold, transparency, etc.

This example shows how to set text to 12pt, red, and bold:

swift
pdfView.setEditingSelectionFontSize(12.0)
pdfView.setEditingSelectionFontColor(.red)
pdfView.setCurrentSelectionIsBold(true)
objective-c
[pdfView setEditingSelectionFontSize:12.0];
[pdfView setEditingSelectionFontColor:[CPDFKitPlatformColor redColor]];
[pdfView setCurrentSelectionIsBold:YES];

Below is the example code for creating and removing underlines and strikethroughs for text:

swift
//  creating underlines and strikethroughs for text
pdfView?.setCurrentSelectionShowUnderline(true, with: editingArea as? CPDFEditTextArea)
pdfView?.setCurrentSelectionShowStrikeout(true, with: editingArea as? CPDFEditTextArea)

//  removing underlines and strikethroughs for text
pdfView?.setCurrentSelectionShowUnderline(false, with: editingArea as? CPDFEditTextArea)
pdfView?.setCurrentSelectionShowStrikeout(false, with: editingArea as? CPDFEditTextArea)
objective-c
//  creating underlines and strikethroughs for text
[pdfView setCurrentSelectionShowUnderline:YES withTextArea:(CPDFEditTextArea *)editingArea];
[pdfView setCurrentSelectionShowStrikeout:YES withTextArea:(CPDFEditTextArea *)editingArea];

//  removing underlines and strikethroughs for text
[pdfView setCurrentSelectionShowUnderline:NO withTextArea:(CPDFEditTextArea *)editingArea];
[pdfView setCurrentSelectionShowStrikeout:NO withTextArea:(CPDFEditTextArea *)editingArea];

Edit Image Properties

ComPDFKit supports modifying image properties, such as rotating, cropping, mirroring, and setting transparency.

This example shows how to rotate an image and set it to semi-transparent:

swift
pdfView.rotateEdit(pdfView.editingArea() as! CPDFEditImageArea, rotateAngle: 90)
/**
 * Set the image transparency.
 */
pdfView.setImageTransparencyEdit(pdfView.editingArea() as! CPDFEditImageArea, transparency: 0.5)
objective-c
[pdfView rotateEditArea:pdfView.editingArea rotateAngle:90];
/**
 * Set the image transparency.
 */
[pdfView setImageTransparencyEditArea:pdfView.editingArea transparency:0.5];