mPDF Manual – mPDF functions

# OverWrite()

(mPDFI >= 2.3)

OverWrite – Replace specified text strings in an existing PDF file

mixed OverWrite ( string $sourcefile , mixed$search , mixed $replacement [, string$dest [, string $file_out ]]) Using the class extension mPDFI, an existing PDF file can be overwritten, replacing specified text with alternatives. For example you may have created a long complex PDF file, and you wish to produce copies with an individual number on each copy without having to re-generate the whole document each time. Overwrite() does not re-flow the text from the source file. If the$replacement string is longer than the $search string, it may overlap the following text. ## Parameters$sourcefile

This parameter specifies the source PDF file to use.  $sourcefile should be a relative path to a local file.$search

The pattern to search for. It can be either a string or an array with strings. Must only contain only ASCII characters.

If the document is utf-8 mode, the search patterns must not exist in text with justified alignment. (Justified text is achieved in mPDF by varying the character spacing for each SPACE between words; this breaks up the text in the PDF file.)

$replacement The string or an array with strings to replace.$replacement can contain any utf-8 encoded characters.

If this parameter is a string and the $search parameter is an array, only the first$search element will be replaced by the $replacement string, any extra$search s will be replaced by an empty string. If both $search and$replacement parameters are arrays, each $search will be replaced by the$replacement counterpart. If there are fewer elements in the $replacement array than in the$search array, any extra $search s will be replaced by an empty string.$dest

$dest specifies the destination for the generated PDF document. DEFAULT: “D” Values D: download the PDF file I: serves in-line to the browser S: returns the PDF document as a string F: save as file$file_out

</span>

$sourcefile This parameter specifies the filename for the output PDF file. No path should be included unless$dest is set as “F”.

DEFAULT: “mpdf.pdf”

## Return Value

OverWrite() returns the PDF file as a string if \$dest is set to “S”.

## Changelog

VersionDescription

Example #1