DynaPDF.FlushPages
------------------

The function writes the pages in memory to the PDF file.

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

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

**MBS**( **"DynaPDF.FlushPages";** /\* The function writes the pages in memory to the PDF file. \*/  
**$PDF**; /\* The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). \*/   
**$Flags**) /\* Optional; A combination of the flag values.   
Default is 0.e.g. 0 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| PDF | The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). | $pdf |  |
| Flags | A combination of the flag values.    Default is 0. | 0 | Optional |

### Result

Returns OK or error message.

### Description

The function writes the pages in memory to the PDF file.  
The function can be called every time a new page was created or whenever the pages in memory are no longer required.  
Calling the function on a memory based PDF file is not meaningful. The output file must already be open before the function can be called. If no output file was set in [DynaPDF.New](DynaPDFNew.md) then open the output file with [DynaPDF.OpenOutputFile](DynaPDFOpenOutputFile.md) beforehand.  
Flushed pages can no longer be accessed with [DynaPDF.EditPage](DynaPDFEditPage.md) but it is of course possible to add further pages to the file.  
By default, the function writes the content streams of all pages and referenced templates, patterns, and images to the output file. The content streams of these objects will be released but the objects remain in memory. So, all handles remain valid and it is still possible to use already flushed objects in subsequent pages. For example, a flushed image or template can still be inserted in other pages with DynaPDF.PlaceImage or [DynaPDF.PlaceTemplate](DynaPDFPlaceTemplate.md) because the content streams or image buffers are not required for this action.  
The flag ImagesOnly can be used to flush the images in memory only. This can be useful if further objects must be added to the pages in memory or if a large image was inserted.  
It is allowed to call the function within an open page. In this case the function does not flush the content stream of the current open page but anything else depending on the used flags.  
Calling a function like [DynaPDF.DeletePage](DynaPDFDeletePage.md), [DynaPDF.DeleteField](DynaPDFDeleteField.md) or any other function that deletes a flushed object results in a damaged PDF file.  
  
| Default | 0 | Write anything to the file that is possible |
|---|--:|---|
| ImagesOnly | 1 | If set, only images are written to the PDF file. All pages are still kept in memory and can be modified with [DynaPDF.EditPage](DynaPDFEditPage.md). Flushed images can still be referenced in other pages. The image handles remain valid. |
| ExclLastPage | 2 | If set, the last page is not flushed |

See also [FlushPages](https://www.monkeybreadsoftware.com/DynaPDF-Manual/FlushPages.shtml) function in DynaPDF manual.

### Examples

Do a flush:

 MBS ( "DynaPDF.FlushPages" )  
### See also

- [DynaPDF.Clear](DynaPDFClear.md)
- [DynaPDF.DeleteField](DynaPDFDeleteField.md)
- [DynaPDF.DeletePage](DynaPDFDeletePage.md)
- [DynaPDF.EditPage](DynaPDFEditPage.md)
- [DynaPDF.FlushPagesEx](DynaPDFFlushPagesEx.md)
- [DynaPDF.New](DynaPDFNew.md)
- [DynaPDF.OpenOutputFile](DynaPDFOpenOutputFile.md)
- [DynaPDF.PlaceTemplate](DynaPDFPlaceTemplate.md)

### Release notes

- **Version 10.3**
    - Added [DynaPDF.FlushPagesEx](https://www.mbsplugins.eu/DynaPDFFlushPagesEx.shtml) and [DynaPDF.ResetAnnotAP](https://www.mbsplugins.eu/DynaPDFResetAnnotAP.shtml) functions.

### Example Databases

- [DynaPDF/Merge PDFs](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Merge%20PDFs.shtml#13ScriptAnchor_)

### Blog Entries

- [MBS Filemaker Plugin, version 3.3pr6](https://www.mbsplugins.de/archive/2013-07-12/MBS_Filemaker_Plugin_version_3/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 18th August 2014 , last changed 14th July 2022

  
[DynaPDF.FlattenForm](DynaPDFFlattenForm.md) - [DynaPDF.FlushPagesEx](DynaPDFFlushPagesEx.md)

[HTML Version](DynaPDFFlushPages.shtml)