Updates

ComPDFKit PDF SDK 1.7.0 — Text Editing

By ComPDFKit | Thu. 14 Nov. 2024
Content EditorRelease

We’re excited to announce the release of ComPDFKit PDF SDK 1.7.0 for iOS and Android. In this release, we added new functionalities in iOS and Android to provide more options in editing text.

 

New features added in this release include:

 

         - Modify font

         - Modify alignment

         - Undo and redo

         - Create text blocks

         - Copy blocks of text

 

 

Why Optimize the Text Editing Feature?

 

To ensure stability, the content of the PDF file is fixed and cannot be changed. Therefore, if you want to edit the PDF content, the old way is to convert the format, and then convert it back to the PDF format after editing. Now, you can make quick text edits to PDFs with our ComPDFKit PDF SDK without converting the file format, this is a huge timesaver.

 

In the previous version, we implemented the primary text editing function. This version is further optimized to support features including modifying text font, modifying alignment, creating text blocks, and copying text blocks. 

 

         - You can modify the font as one of Helvetica, Courier, and Times-Roman, and set the font to bold or italic.

         - You can set the text alignment to be left, right, centered, justified, or scattered.

         - Supports creating text blocks anywhere on the page, and you can adjust their size.

         - Supports copying any text block in a PDF file.

 

While editing text, ComPDFKit supports users to undo or redo changes made at any point during the editing process. Additionally, note that changes will be saved only after the user executes the save operation.

 

The following are some sample codes for text editing on iOS platform.



How to Set the Font to Bold

 

You can select a piece of text and set it to bold. Here we take Java as an example.

CPDFEditTextSelections textSelections = (CPDFEditTextSelections) selections;
textSelections.setRederingmode(CPDFEditTextArea.PDFEditTextRenderingMode.PSOPDFEDITMODE_FILL_STROKE);
pageView.operateEditTextSelect(CPDFPageView.EditTextSelectFuncType.ATTR);

 

 

How to Set the Alignment

 

You can set the alignment of the text to be right. Here we take Java as an example.

CPDFEditTextSelections textSelections = (CPDFEditTextSelections) selections;
textSelections.setAlign(CPDFEditTextArea.PDFEditAlignType.PSOPDFEditAlignRight);
pageView.operateEditTextSelect(CPDFPageView.EditTextSelectFuncType.ATTR);

 

 

How to Redo and Undo

 

You can redo or undo your action. Here we take Java as an example.

((CPDFReaderView)readerView).getEditManager().addEditStatusChangeListener(new OnEditStatusChangeListener() {
            @Override
            public void onBegin(int type) {
               
            }

            @Override
            public void onUndo(int page, boolean canUndo) {
               
            }

            @Override
            public void onRedo(int page, boolean canRedo) {

            }

            @Override
            public void onExit() {
               
            }
        });

//Undo
readerView.onEditUndo();

//Redo
readerView.onEditRedo();

 

 

Conclusion

  

Check our documentation page to get more feature details. Please contact us to try it out and give us more feedback. We will keep optimizing and providing the best PDF SDK for our customers.