Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

DynaPDF.Parser.DeleteText

Deletes text in the area.

Component Version macOS Windows Linux Server iOS SDK
DynaPDF 14.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "DynaPDF.Parser.DeleteText"; PDF; Left; Bottom; Right; Top )   More

Parameters

Parameter Description Example
PDF The PDF reference. $pdf
Left The left coordinate of the rectangle. 0
Bottom The bottom coordinate of the page. 0
Right The right coordinate of the page. 595
Top The top coordinate of the page. 842

Result

Returns 1, 0 or error.

Description

Deletes text in the area.
The function deletes every glyph or character that touches or lies inside the rectangle Area.

Area must be defined as if the page would be viewed in a PDF viewer. That means in bottom up coordinates and the orientation must be considered (see DynaPDF.GetOrientation). The width and height of a page must be calculated from the crop box if set, or from the media box otherwise (see DynaPDF.GetPageBBox). Note also that the width and height must be exchanged if the orientation is 90, -90, 270, or -270 degrees.

Note that this function deletes text only. Text can also occur in form of images or vector graphics. There are no functions yet to identify and delete text in such objects.

If the function succeeds the return value is true. If the function fails the return value is false.

Examples

Delete a rectangle in text:

# initialize parser
Set Variable [ $OptimizeFlags ; Value: 0 ]
Set Variable [ $r ; Value: MBS( "DynaPDF.Parser.Create"; $pdf; $OptimizeFlags ) ]
#
# Now parse a page
Set Variable [ $r ; Value: MBS("DynaPDF.Parser.ParsePage"; $pdf; 1; "EnableTextSelection") ]
If [ MBS("IsError") ]
    Show Custom Dialog [ "Failed to parse page" ; $r ]
Else
    # Define the rectangle
    Set Variable [ $areaLeft ; Value: 200 ]
    Set Variable [ $areaWidth ; Value: 200 ]
    Set Variable [ $areaTop ; Value: 200 ]
    Set Variable [ $areaHeight ; Value: 200 ]
    #
    # we need right and bottom. And since coordinates are bottom-up, we bottom is the smaller y value
    Set Variable [ $areaRight ; Value: $areaLeft + $areaWidth ]
    Set Variable [ $areaBottom ; Value: $areaTop ]
    Set Variable [ $areaTop ; Value: $areaTop + $areaHeight ]
    #
    # now delete text in that area
    Set Variable [ $r ; Value: MBS( "DynaPDF.Parser.DeleteText"; $pdf; $areaTop; $areaBottom; $areaLeft; $areaRight) ]
    If [ MBS("IsError") ]
        Show Custom Dialog [ "Failed to parse page" ; $r ]
    Else
        # Save changes back
        Set Variable [ $r ; Value: MBS( "DynaPDF.Parser.WriteToPage"; $pdf; $OptimizeFlags) ]
    End If
End If

See also

Release notes

Example Databases

Blog Entries

This function checks for a license.

Created 23th November 2023, last changed 23th November 2023


DynaPDF.Parser.Create - DynaPDF.Parser.ExtractText