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

DynaPDF.WriteFTextEx

Writes text on current page with formatting commands.

Component Version macOS Windows Linux Server iOS SDK
DynaPDF 3.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "DynaPDF.WriteFTextEx"; PDF; PosX; PosY; Width; Height; Align; Text { ; PlainText } )   More

Parameters

Parameter Description Example Flags
PDF The PDF reference returned from DynaPDF.New. $pdf
PosX X-Coordinate of output rectangle $x
PosY Y-Coordinate of output rectangle $y
Width Width of output rectangle $w
Height Height of output rectangle or -1. $h
Align The text alignment. Can be left, center, right or justify. "left"
Text The text to write. "Hello World"
PlainText Available in MBS FileMaker Plugin 9.1 or newer.
Pass 1 to ignore formatting commands and treat text as plain text.
Default is 0 to interpret commands in text.
0 Optional

Result

Returns OK or error message.

Description

Writes text on current page with formatting commands.
Use DynaPDF.GetFTextHeightEx or DynaPDF.GetFTextHeight to calculate the space needed for the text if you want to create a matching text rectangle for vertical alignment.

See DynaPDF.AllowPageBreak for whether to do page breaks or not.

Please set a font first with DynaPDF.SetFont function before you write on the page.
See DynaPDF.WriteStyledTextEx to convert FileMaker styles to DynaPDF commands.

See also WriteFTextEx function in DynaPDF manual.

Examples

Write text in a rectangle:

MBS( "DynaPDF.WriteFTextEx"; $PDF; 100; 500; 100; 100; "left"; "Hello World" )

Loop over pages and add page numbers:

Set Variable [$PageCount; Value:MBS( "DynaPDF.GetPageCount"; $pdf )]
Set Variable [$PageNumber; Value:1]
Set Variable [$pageWidth; Value:MBS("DynaPDF.GetPageWidth"; $pdf)]
Set Variable [$pageHeight; Value:MBS("DynaPDF.GetPageHeight"; $pdf)]
Loop
    Set Variable [$r; Value:MBS("DynaPDF.EditPage"; $pdf; $PageNumber)]
    Set Variable [$r; Value:MBS( "DynaPDF.SetFont"; $pdf; "Helvetica"; 0; 12)]
    Set Variable [$r; Value:MBS( "DynaPDF.WriteFTextEx"; $pdf; 50; $pageHeight - 50; $pageWidth-100; 30; "right"; GetAsText($PageNumber) & " of " & $PageCount)]
    Set Variable [$r; Value:MBS("DynaPDF.EndPage"; $pdf)]
    Set Variable [$PageNumber; Value:$PageNumber +1]
    Exit Loop If [$PageNumber > $PageCount]
End Loop

Annotate PDF page with text on top center:

# make pdf
Set Field [PDF::Annotated PDF; PDF::Original PDF]
#Clear current PDF document
Set Variable [$pdf; Value:MBS("DynaPDF.New")]
#Load PDF from container
Set Variable [$r; Value:MBS("DynaPDF.OpenPDFFromContainer"; $pdf; PDF::Original PDF)]
Set Variable [$r; Value:MBS("DynaPDF.ImportPDFFile"; $pdf)]
# write on each page a header
Set Variable [$index; Value:1]
Set Variable [$count; Value:MBS("DynaPDF.GetPageCount"; $pdf)]
Loop
    Set Variable [$r; Value:MBS("DynaPDF.EditPage"; $pdf; $index)]
    Set Variable [$r; Value:MBS("DynaPDF.SetPageCoords"; $pdf; "topdown")]
    Set Variable [$r; Value:MBS("DynaPDF.SetFont"; $pdf; "Arial"; 0; 10; 1; "unicode")]
    Set Variable [$PageWidth; Value:MBS("DynaPDF.GetPageWidth"; $pdf)]
    Set Variable [$print; Value:MBS("DynaPDF.WriteFTextEx"; $pdf; 0; 20; $PageWidth; -1; "center"; "Doc - " & PDF::PK & "")]
    Set Variable [$r; Value:MBS("DynaPDF.EndPage"; $pdf)]
    Set Variable [$index; Value:$index + 1]
    Exit Loop If [$index > $count]
End Loop
#save
Set Field [PDF::Annotated PDF; MBS( "DynaPDF.Save"; $PDF; "print.pdf" )]
#Cleanup
Set Variable [$r; Value:MBS("DynaPDF.Release"; $pdf)]

Write some text with a link:

MBS( "DynaPDF.WriteFTextEx"; $PDF; 100; 500; 100; 100; "left"; "Link to DynaPDF: \FC[16711680]\ul#\LK[false, TRUE, false, https://www.dynaforms.com]Test\EK#\ul#\FC[0]." )

Write text in RGB colors:

Set Variable [ $r ; Value: MBS("DynaPDF.SetColorSpace"; $pdf; "DeviceRGB") ]
# calculate color values for RBB
Set Variable [ $red ; Value: MBS( "DynaPDF.RGB"; 255; 0; 0 ) ]
Set Variable [ $green ; Value: MBS( "DynaPDF.RGB"; 0; 255; 0 ) ]
Set Variable [ $blue ; Value: MBS( "DynaPDF.RGB"; 0; 0; 255 ) ]
# now write some text
Set Variable [ $r ; Value: MBS("DynaPDF.DynaPDF.WriteFTextEx"; $pdf; 100; 100; 500; 200;
    "left"; "Testing: " &
    "\FC[" & $red & "]Red" &
    "\FC[" & $green & "]Green" &
    "\FC[" & $blue & "]Blue" ) ]

Write text in CMYK colors:

# set colorspace
Set Variable [ $r ; Value: MBS("DynaPDF.SetColorSpace"; $pdf; "DeviceCMYK") ]

# calculate color values for CMYK
Set Variable [ $cyan ; Value: MBS( "DynaPDF.CMYK"; 255; 0; 0; 0 ) ]
Set Variable [ $magenta ; Value: MBS( "DynaPDF.CMYK"; 0; 255; 0; 0 ) ]
Set Variable [ $yellow ; Value: MBS( "DynaPDF.CMYK"; 0; 0; 255; 0 ) ]
Set Variable [ $black ; Value: MBS( "DynaPDF.CMYK"; 0; 0; 0; 255 ) ]

# now write some text
Set Variable [ $r ; Value: MBS("DynaPDF.DynaPDF.WriteFTextEx"; $pdf; 100; 100; 500; 200;
    "left"; "Testing: " &
    "\FC[" & $cyan & "]Cyan" &
    "\FC[" & $Magenta & "]Magenta" &
    "\FC[" & $Yellow & "]Yellow" &
    "\FC[" & $Black & "]Black" ) ]

Draw page number inside a round rectangle box:

# set color white to fill and light gray for frame
Set Variable [ $r ; Value: MBS( "DynaPDF.SetStrokeColor"; $pdf; ,1; ,1; ,1) ]
Set Variable [ $r ; Value: MBS( "DynaPDF.SetFillColor"; $pdf; 1; 1; 1) ]
# draw round rect with one point border
Set Variable [ $r ; Value: MBS( "DynaPDF.SetLineWidth"; $pdf; 1) ]
Set Variable [ $r ; Value: MBS( "DynaPDF.RoundRectEx"; $pdf; 50; $pageHeight - 50; $pageWidth - 100; 30; 5; 5; "FillStroke" ) ]
#
# set color black
Set Variable [ $r ; Value: MBS( "DynaPDF.SetStrokeColor"; $pdf; 0; 0; 0) ]
Set Variable [ $r ; Value: MBS( "DynaPDF.SetFillColor"; $pdf; 0; 0; 0) ]
# and write centered text
Set Variable [ $r ; Value: MBS( "DynaPDF.SetFont"; $pdf; "Helvetica"; 0; 20) ]
Set Variable [ $r ; Value: MBS( "DynaPDF.WriteFTextEx"; $pdf; 50; $pageHeight - 50; $pageWidth-100; 30; "center"; GetAsText($PageNumber) & " of " & $PageCount) ]

See also

Release notes

Example Databases

Blog Entries

This function checks for a license.

Created 18th August 2014, last changed 13th December 2023


DynaPDF.WriteFText - DynaPDF.WriteFTextExRotated