DynaPDF.Parser.ExtractText
--------------------------

Extracts text from parser.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [DynaPDF](component_DynaPDF.md) | [14.0](newinversion140.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "DynaPDF.Parser.ExtractText"; PDF; Flags { ; Left; Bottom; Right; Top } ) 

**MBS**( **"DynaPDF.Parser.ExtractText";** /\* Extracts text from parser. \*/  
**$PDF**; /\* The PDF reference. \*/   
**$Flags**; /\* The flags for text extraction.  
Can include Default, SortTextX, SortTextY, SortTextXY, DeleteOverlappingText and/or NoHeuristic.  
Usually you may want to use SortTextX here.  
  
The flag MediaBox limits text extraction to the media box. The flag CropBox uses the crop box (if missing media box) for the rectangle.e.g. "SortTextX" \*/   
**$Left**; /\* Optional; The left coordinate of the rectangle.e.g. 0 \*/   
**$Bottom**; /\* Optional; The bottom coordinate of the page.e.g. 0 \*/   
**$Right**; /\* Optional; The right coordinate of the page.e.g. 595 \*/   
**$Top**) /\* Optional; The top coordinate of the page.e.g. 842 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| PDF | The PDF reference. | $pdf |  |
| Flags | The flags for text extraction.   Can include Default, SortTextX, SortTextY, SortTextXY, DeleteOverlappingText and/or NoHeuristic.   Usually you may want to use SortTextX here.      The flag MediaBox limits text extraction to the media box. The flag CropBox uses the crop box (if missing media box) for the rectangle. | "SortTextX" |  |
| Left | The left coordinate of the rectangle. | 0 | Optional |
| Bottom | The bottom coordinate of the page. | 0 | Optional |
| Right | The right coordinate of the page. | 595 | Optional |
| Top | The top coordinate of the page. | 842 | Optional |

### Result

Returns text or error.

### Description

Extracts text from parser.  
The function extracts the text of a page with the same algorithm that [DynaPDF.FindText](DynaPDFFindText.md) uses to find text on a page. In order to get exactly the same result the flag "SortTextX" must be set.   
  
The function [DynaPDF.ExtractText](DynaPDFExtractText.md) of the PDF instance calls in fact this function internally.  
  
The optional parameter Area defined using left, bottom, right and top can be set to restrict text extraction to that rectangle. The rectangle 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. The page coordinate system is de-rotated before text extraction starts since this produces better results. The width and height must be calculated from the crop box if set, or from the media box otherwise. Note also that the width and height must be exchanged if the orientation is 90, -90, 270, or -270 degrees.  
### Examples

Extract text of a page

 Set Variable \[ $page ; Value: 1 \]  
Set Variable \[ $r ; Value: MBS ("[DynaPDF.Parser.ParsePage](DynaPDFParserParsePage.md)"; $pdf ; $page ; "EnableTextSelection") \]  
If \[ MBS ("IsError") \]  
 Show Custom Dialog \[ "Failed to parse page" ; $r \]  
Else  
 Set Variable \[ $$text ; Value: MBS ("DynaPDF.Parser.ExtractText"; $pdf ; $page ; "SortTextX NoHeuristic CropBox") \]  
End If  
### See also

- [DynaPDF.ExtractText](DynaPDFExtractText.md)
- [DynaPDF.FindText](DynaPDFFindText.md)
- [DynaPDF.Parser.DeleteText](DynaPDFParserDeleteText.md)
- [DynaPDF.Parser.ParsePage](DynaPDFParserParsePage.md)
- [DynaPDF.Parser.TextMatrix](DynaPDFParserTextMatrix.md)
- [IsError](IsError.md)

### Release notes

- **Version 15.1**
    - Added flags MediaBox and CropBox to [DynaPDF.Parser.ExtractText](https://www.mbsplugins.eu/DynaPDFParserExtractText.shtml), [DynaPDF.ExtractText](https://www.mbsplugins.eu/DynaPDFExtractText.shtml) and [DynaPDF.ExtractDocumentText](https://www.mbsplugins.eu/DynaPDFExtractDocumentText.shtml).
- **Version 14.0**
    - Added DynaPDF parser functions: [DynaPDF.Parser.ChangeAltFont](https://www.mbsplugins.eu/DynaPDFParserChangeAltFont.shtml), [DynaPDF.Parser.Create](https://www.mbsplugins.eu/DynaPDFParserCreate.shtml), [DynaPDF.Parser.DeleteText](https://www.mbsplugins.eu/DynaPDFParserDeleteText.shtml), [DynaPDF.Parser.ExtractText](https://www.mbsplugins.eu/DynaPDFParserExtractText.shtml), [DynaPDF.Parser.FindText](https://www.mbsplugins.eu/DynaPDFParserFindText.shtml), [DynaPDF.Parser.Line](https://www.mbsplugins.eu/DynaPDFParserLine.shtml), [DynaPDF.Parser.ParsePage](https://www.mbsplugins.eu/DynaPDFParserParsePage.shtml), [DynaPDF.Parser.ReplaceSelText](https://www.mbsplugins.eu/DynaPDFParserReplaceSelText.shtml), [DynaPDF.Parser.SetAltFont](https://www.mbsplugins.eu/DynaPDFParserSetAltFont.shtml), [DynaPDF.Parser.TextMatrix](https://www.mbsplugins.eu/DynaPDFParserTextMatrix.shtml), [DynaPDF.Parser.WriteToPage](https://www.mbsplugins.eu/DynaPDFParserWriteToPage.shtml).

### Blog Entries

- [MBS FileMaker Plugin, version 15.1pr1](https://www.mbsplugins.de/archive/2025-02-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [New in MBS FileMaker Plugin 14.0](https://www.mbsplugins.de/archive/2024-01-23/New_in_MBS_FileMaker_Plugin_14/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 13.6pr1](https://www.mbsplugins.de/archive/2023-12-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 23th November 2023 , last changed 31st January 2025

  
[DynaPDF.Parser.DeleteText](DynaPDFParserDeleteText.md) - [DynaPDF.Parser.FindText](DynaPDFParserFindText.md)

[HTML Version](DynaPDFParserExtractText.shtml)