DynaPDF.ExtractDocumentText
---------------------------

Extracts the text of all pages.

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

MBS( "DynaPDF.ExtractDocumentText"; PDF { ; Flags } ) 

**MBS**( **"DynaPDF.ExtractDocumentText";** /\* Extracts the text of all pages. \*/  
**$PDF**; /\* The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). \*/   
**$Flags**) /\* Optional; 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" \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| PDF | The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). | $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" | Optional      Added in version **14.4**. |

### Result

Returns text or error.

### Description

Extracts the text of all pages.  
This is like extracting page by page, but plugin may do it faster than a loop in a FileMaker script and puts a newline between pages.  
Use [DynaPDF.ExtractText](DynaPDFExtractText.md) is you need text from just one page.  
  
For Mac only solutions, you can also try [PDFKit.GetPDFText](PDFKitGetPDFText.md).   
  
Needs DynaPDF Lite license.  
Please use [DynaPDF.SetCMapDir](DynaPDFSetCMapDir.md) to define the CMap folder to handle encodings better.  
  
If you have an open page, we close it automatically for you before doing the import.  
### Examples

Load PDF and extract text:

 Set Variable \[$pdf ; Value:MBS ("[DynaPDF.New](DynaPDFNew.md)")\]  
Set Variable \[$r ; Value:MBS ("[DynaPDF.OpenPDFFromContainer](DynaPDFOpenPDFFromContainer.md)";$pdf ; Test::data )\]  
Set Variable \[$r ; Value:MBS ("[DynaPDF.ImportPDFFile](DynaPDFImportPDFFile.md)";$pdf )\]  
Set Field \[Test::PageText ; MBS ("DynaPDF.ExtractDocumentText"; $pdf )\]  
Set Variable \[$r ; Value:MBS ("[DynaPDF.Release](DynaPDFRelease.md)"; $pdf )\]  
Full script to get text with error checking:

 If \[MBS ("[DynaPDF.IsInitialized](DynaPDFIsInitialized.md)") ≠ 1\]  
 Perform Script \[“InitDynaPDF”\]  
End If  
Set Variable \[$pdf ; Value:MBS ("[DynaPDF.New](DynaPDFNew.md)")\]  
If \[MBS ("IsError")\]  
 Show Custom Dialog \["DynaPDF Fehler"; $pdf \]  
Else  
 Set Variable \[$r ; Value:MBS ("[DynaPDF.OpenPDFFromContainer](DynaPDFOpenPDFFromContainer.md)";$pdf ; Test::data )\]  
 If \[MBS ("IsError")\]  
 Show Custom Dialog \["DynaPDF Fehler"; $r \]  
 Else  
 Set Variable \[$r ; Value:MBS ("[DynaPDF.ImportPDFFile](DynaPDFImportPDFFile.md)";$pdf )\]  
 If \[MBS ("IsError")\]  
 Show Custom Dialog \["DynaPDF Fehler"; $r \]  
 Else  
 Set Field \[Test::PageText ; MBS ("DynaPDF.ExtractTextOld"; $pdf )\]  
 Commit Records/Requests \[No dialog\]  
 End If  
 End If  
 #Cleanup  
 Set Variable \[$r ; Value:MBS ("[DynaPDF.Release](DynaPDFRelease.md)"; $pdf )\]  
End If  
### See also

- [DynaPDF.ExtractPageRectText](DynaPDFExtractPageRectText.md)
- [DynaPDF.ExtractText](DynaPDFExtractText.md)
- [DynaPDF.ImportPDFFile](DynaPDFImportPDFFile.md)
- [DynaPDF.IsInitialized](DynaPDFIsInitialized.md)
- [DynaPDF.New](DynaPDFNew.md)
- [DynaPDF.OpenPDFFromContainer](DynaPDFOpenPDFFromContainer.md)
- [DynaPDF.Release](DynaPDFRelease.md)
- [DynaPDF.SetCMapDir](DynaPDFSetCMapDir.md)
- [IsError](IsError.md)
- [PDFKit.GetPDFText](PDFKitGetPDFText.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.4**
    - Added Flags parameter for [DynaPDF.ExtractDocumentText](https://www.mbsplugins.eu/DynaPDFExtractDocumentText.shtml) function.
- **Version 14.0**
    - Rewrote [DynaPDF.ExtractDocumentText](https://www.mbsplugins.eu/DynaPDFExtractDocumentText.shtml) using newer [DynaPDF.ExtractText](https://www.mbsplugins.eu/DynaPDFExtractText.shtml) function internally.
- **Version 10.1**
    - Fixed a problem with recursive templates in [DynaPDF.ExtractDocumentText](https://www.mbsplugins.eu/DynaPDFExtractDocumentText.shtml), [DynaPDF.ExtractPageRectText](https://www.mbsplugins.eu/DynaPDFExtractPageRectText.shtml) and [DynaPDF.ExtractPageText](https://www.mbsplugins.eu/DynaPDFExtractPageText.shtml) functions.
- **Version 8.0**
    - Renamed existing [DynaPDF.ExtractText](http://www.mbsplugins.eu/DynaPDFExtractText.shtml) to [DynaPDF.ExtractDocumentText](http://www.mbsplugins.eu/DynaPDFExtractDocumentText.shtml). New function does the same, but now part of DynaPDF itself and not a helper function from our plugin.

### Example Databases

- [DynaPDF/PDF Library](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/PDF%20Library.shtml#1ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Plugin, version 15.1pr1](https://www.mbsplugins.de/archive/2025-02-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 14.4pr3](https://www.mbsplugins.de/archive/2024-08-21/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 14.0pr7](https://www.mbsplugins.de/archive/2024-01-08/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 10.1pr5](https://www.mbsplugins.de/archive/2020-02-24/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 6/2020, Seite 33](https://filemaker-magazin.de/neuigkeit/4118-Appetithappen-FMM_202006)

This function checks for a license.

Created 8th December 2015 , last changed 31st January 2025

  
[DynaPDF.ExchangePages](DynaPDFExchangePages.md) - [DynaPDF.ExtractImages](DynaPDFExtractImages.md)

[HTML Version](DynaPDFExtractDocumentText.shtml)