On this page
Guides
Edit Text and Image Properties
ComPDFKit supports to modify the properties of text and images. To configure text and image properties, you can utilize the MouseLeftButtonDownHandler
event of CPDFToolManager
.
Edit Text Properties
ComPDFKit supports modifying text properties, such as text font size, name, color, alignment, italics, bold, transparency, etc. And copying, and creating or removing underlines and strikethroughs for text.
This example shows how to set text to 12pt, red, and bold:
C#
toolManager.MouseLeftButtonDownHandler += ToolManager_MouseLeftButtonDownHandler;
private void ToolManager_MouseLeftButtonDownHandler(object sender, MouseEventObject e)
{
int pageIndex = -1;
CPDFToolManager manager = sender as CPDFToolManager;
CPDFEditArea editArea = manager.GetSelectedEditAreaObject(ref pageIndex);
if (editArea != null && editArea.Type == CPDFEditType.EditText)
{
CPDFEditPage editPage = manager.GetDocument().PageAtIndex(pageIndex).GetEditPage();
CPDFEditTextArea textArea = editArea as CPDFEditTextArea;
Rect textRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
// Text properties
textArea.SetCharsFontColor(255,0,0);
textArea.SetCharsFontTransparency(255);
textArea.SetCharsFontSize(12,true);
textArea.SetCharsFontName("Arial");
textArea.SetCharsFontBold(true);
textArea.SetCharsFontItalic(true);
textArea.SetTextAreaAlign(TextAlignType.AlignLeft);
editPage.EndEdit();
manager.GetCPDFViewerTool().UpdateRender(textRect, textArea);
}
}
Below is the example code for creating and removing underlines and strikethroughs for text:
c#
// creating underlines and strikethroughs for text
textArea.AddUnderline();
textArea.AddStrikethrough();
// removing underlines and strikethroughs for text
textArea.RemoveUnderline();
textArea.RemoveStrikethrough();
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:
C#
toolManager.MouseLeftButtonDownHandler += ToolManager_MouseLeftButtonDownHandler;
private void ToolManager_MouseLeftButtonDownHandler(object sender, MouseEventObject e)
{
int pageIndex = -1;
CPDFToolManager manager = sender as CPDFToolManager;
CPDFEditArea editArea = manager.GetSelectedEditAreaObject(ref pageIndex);
if (editArea != null && editArea.Type == CPDFEditType.EditText)
{
CPDFEditPage editPage = manager.GetDocument().PageAtIndex(pageIndex).GetEditPage();
CPDFEditImageArea imageArea = editArea as CPDFEditImageArea;
Rect imageRect = DataConversionForWPF.CRectConversionForRect(imageArea.GetFrame());
//Image properties.
imageArea.Rotate(90);
imageArea.HorizontalMirror();
manager.GetCPDFViewerTool().UpdateRender(imageRect, imageArea);
editPage.EndEdit();
}
}