Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
::Fpdi setasign::Fpdi

Namespaces

namespace  setasign\Fpdi
  
 
namespace  setasign\Fpdi\PdfParser
  
 
namespace  setasign\Fpdi\PdfParser\CrossReference
  
 
namespace  setasign\Fpdi\PdfParser\Filter
  
 
namespace  setasign\Fpdi\PdfParser\Type
  
 
namespace  setasign\Fpdi\PdfReader
  
 
namespace  setasign\Fpdi\PdfReader\DataStructure
  
 
namespace  setasign\Fpdi\Tcpdf
  
 
namespace  setasign\Fpdi\Tfpdf
  
 

Classes

class  AbstractReader
 Abstract class for cross-reference reader classes. More...
 
class  Ascii85
 Class for handling ASCII base-85 encoded data. More...
 
class  Ascii85Exception
 Exception for Ascii85 filter class. More...
 
class  AsciiHex
 Class for handling ASCII hexadecimal encoded data. More...
 
class  CrossReference
 Class CrossReference. More...
 
class  CrossReferenceException
 Exception used by the CrossReference and Reader classes. More...
 
class  FilterException
 Exception for filters. More...
 
interface  FilterInterface
 Interface for filters. More...
 
class  FixedReader
 Class FixedReader. More...
 
class  Flate
 Class for handling zlib/deflate encoded data. More...
 
class  FlateException
 Exception for flate filter class. More...
 
class  FpdfTpl
 Class FpdfTpl. More...
 
class  Fpdi
 Class Fpdi. More...
 
class  FpdiException
 Base exception class for the FPDI package. More...
 
class  LineReader
 Class LineReader. More...
 
class  Lzw
 Class for handling LZW encoded data. More...
 
class  LzwException
 Exception for LZW filter class. More...
 
class  Page
 Class representing a page of a PDF document. More...
 
class  PageBoundaries
 An abstract class for page boundary constants and some helper methods. More...
 
class  PdfArray
 
class  PdfBoolean
 Class representing a boolean PDF object. More...
 
class  PdfDictionary
 Class representing a PDF dictionary object. More...
 
class  PdfHexString
 Class representing a hexadecimal encoded PDF string object. More...
 
class  PdfIndirectObject
 Class representing an indirect object. More...
 
class  PdfIndirectObjectReference
 Class representing an indirect object reference. More...
 
class  PdfName
 Class representing a PDF name object. More...
 
class  PdfNull
 Class representing a PDF null object. More...
 
class  PdfNumeric
 Class representing a numeric PDF object. More...
 
class  PdfParser
 A PDF parser class. More...
 
class  PdfParserException
 Exception for the pdf parser class. More...
 
class  PdfReader
 A PDF reader class. More...
 
class  PdfReaderException
 Exception for the pdf reader class. More...
 
class  PdfStream
 Class representing a PDF stream object. More...
 
class  PdfString
 Class representing a PDF string object. More...
 
class  PdfToken
 Class representing PDF token object. More...
 
class  PdfType
 A class defining a PDF data type. More...
 
class  PdfTypeException
 Exception class for pdf type classes. More...
 
interface  ReaderInterface
 ReaderInterface for cross-reference readers. More...
 
class  Rectangle
 Class representing a rectangle. More...
 
class  StreamReader
 A stream reader class. More...
 
class  TcpdfFpdi
 Class TcpdfFpdi. More...
 
class  Tokenizer
 A tokenizer class. More...
 

Functions

 _out ($s)
 
 _putimages ()
 
 _putxobjectdict ()
 
 AddPage ($orientation='', $size='', $rotation=0)
 
 beginTemplate ($width=null, $height=null, $groupXObject=false)
 Begins a new template.
 
 cleanUp ($allReaders=false)
 Release resources and file handles.
 
 endTemplate ()
 Ends a template.
 
 getImportedPageSize ($tpl, $width=null, $height=null)
 Get the size of an imported page.
 
 getNextTemplateId ()
 Get the next template id.
 
 getPdfParserInstance (StreamReader $streamReader)
 @noinspection PhpUndefinedClassInspection
 
 getPdfReader ($id)
 Get a pdf reader instance by its id.
 
 getPdfReaderId ($file)
 Get an unique reader id by the $file parameter.
 
 getTemplateSize ($tpl, $width=null, $height=null)
 Get the size of a template.
 
 importPage ($pageNumber, $box=PageBoundaries::CROP_BOX, $groupXObject=true)
 Imports a page.
 
 Link ($x, $y, $w, $h, $link)
 
 SetDrawColor ($r, $g=null, $b=null)
 
 SetFillColor ($r, $g=null, $b=null)
 
 SetFont ($family, $style='', $size=0)
 
 SetFontSize ($size)
 
 SetLineWidth ($width)
 
 SetLink ($link, $y=0, $page=-1)
 
 setMinPdfVersion ($pdfVersion)
 Set the minimal PDF version.
 
 setPageFormat ($size, $orientation)
 Set the page format of the current page.
 
 setSourceFile ($file)
 Set the source PDF file.
 
 useImportedPage ($pageId, $x=0, $y=0, $width=null, $height=null, $adjustPageSize=false)
 Draws an imported page onto the page.
 
 useTemplate ($tpl, $x=0, $y=0, $width=null, $height=null, $adjustPageSize=false)
 Draws a template onto the page or another template.
 
 writePdfType (PdfType $value)
 Writes a PdfType object to the resulting buffer.
 

Variables

array $createdReaders = []
 Instances created internally.
 
string null $currentReaderId
 The current reader id.
 
null int $currentTemplateId
 The template id for the currently created template.
 
array $importedPages = []
 Data of all imported pages.
 
array $objectMap = []
 A map from object numbers of imported objects to new assigned object numbers by FPDF.
 
array $objectsToCopy = []
 An array with information about objects, which needs to be copied to the resulting document.
 
int $templateId = 0
 A counter for template ids.
 
trait FpdfTplTrait
 Trait FpdfTplTrait.
 
trait FpdiTrait
 The FpdiTrait.
 

Detailed Description

Function Documentation

◆ beginTemplate()

beginTemplate ( $width = null,
$height = null,
$groupXObject = false )

Begins a new template.

Parameters
float | int | null$widthThe width of the template. If null, the current page width is used.
float | int | null$heightThe height of the template. If null, the current page height is used.
bool$groupXObjectDefine the form XObject as a group XObject to support transparency (if used).
Return values
intA template identifier.

◆ cleanUp()

cleanUp ( $allReaders = false)

Release resources and file handles.

This method is called internally when the document is created successfully. By default it only cleans up stream reader instances which were created internally.

Parameters
bool$allReaders

◆ endTemplate()

endTemplate ( )

Ends a template.

Return values
bool|int|nullA template identifier.

◆ getImportedPageSize()

getImportedPageSize ( $tpl,
$width = null,
$height = null )

Get the size of an imported page.

Give only one of the size parameters (width, height) to calculate the other one automatically in view to the aspect ratio.

Parameters
mixed$tplThe template id
float | int | null$widthThe width.
float | int | null$heightThe height.
Return values
array|boolAn array with following keys: width, height, 0 (=width), 1 (=height), orientation (L or P)

◆ getNextTemplateId()

getNextTemplateId ( )
protected

Get the next template id.

Return values
int

◆ getPdfParserInstance()

getPdfParserInstance ( StreamReader $streamReader)
protected

@noinspection PhpUndefinedClassInspection

Get a new pdf parser instance.

Parameters
StreamReader$streamReader
Return values
PdfParser|FpdiPdfParser

◆ getPdfReader()

getPdfReader ( $id)
protected

Get a pdf reader instance by its id.

Parameters
string$id
Return values
PdfReader

◆ getPdfReaderId()

getPdfReaderId ( $file)
protected

Get an unique reader id by the $file parameter.

Parameters
string | resource | PdfReader | StreamReader$fileAn open file descriptor, a path to a file, a PdfReader instance or a StreamReader instance.
Return values
string

◆ getTemplateSize()

getTemplateSize ( $tpl,
$width = null,
$height = null )

Get the size of a template.

Give only one of the size parameters (width, height) to calculate the other one automatically in view to the aspect ratio.

Parameters
mixed$tplThe template id
float | int | null$widthThe width.
float | int | null$heightThe height.
Return values
array|boolAn array with following keys: width, height, 0 (=width), 1 (=height), orientation (L or P)

◆ importPage()

importPage ( $pageNumber,
$box = PageBoundaries::CROP_BOX,
$groupXObject = true )

Imports a page.

Parameters
int$pageNumberThe page number.
string$boxThe page boundary to import. Default set to PageBoundaries\CROP_BOX.
bool$groupXObjectDefine the form XObject as a group XObject to support transparency (if used).
Return values
stringA unique string identifying the imported page.
Exceptions
CrossReferenceException
FilterException
PdfParserException
PdfTypeException
PdfReaderException
See also
PageBoundaries

◆ setMinPdfVersion()

setMinPdfVersion ( $pdfVersion)
protected

Set the minimal PDF version.

Parameters
string$pdfVersion

◆ setPageFormat()

setPageFormat ( $size,
$orientation )

Set the page format of the current page.

Parameters
array$sizeAn array with two values defining the size.
string$orientation"L" for landscape, "P" for portrait.
Exceptions
BadMethodCallException

◆ setSourceFile()

setSourceFile ( $file)

Set the source PDF file.

Parameters
string | resource | StreamReader$filePath to the file or a stream resource or a StreamReader instance.
Return values
intThe page count of the PDF document.
Exceptions
PdfParserException

◆ useImportedPage()

useImportedPage ( $pageId,
$x = 0,
$y = 0,
$width = null,
$height = null,
$adjustPageSize = false )

Draws an imported page onto the page.

Give only one of the size parameters (width, height) to calculate the other one automatically in view to the aspect ratio.

Parameters
mixed$pageIdThe page id
float | int | array$xThe abscissa of upper-left corner. Alternatively you could use an assoc array with the keys "x", "y", "width", "height", "adjustPageSize".
float | int$yThe ordinate of upper-left corner.
float | int | null$widthThe width.
float | int | null$heightThe height.
bool$adjustPageSize
Return values
arrayThe size.
See also
Fpdi\getTemplateSize()

◆ useTemplate()

useTemplate ( $tpl,
$x = 0,
$y = 0,
$width = null,
$height = null,
$adjustPageSize = false )

Draws a template onto the page or another template.

Give only one of the size parameters (width, height) to calculate the other one automatically in view to the aspect ratio.

Parameters
mixed$tplThe template id
array | float | int$xThe abscissa of upper-left corner. Alternatively you could use an assoc array with the keys "x", "y", "width", "height", "adjustPageSize".
float | int$yThe ordinate of upper-left corner.
float | int | null$widthThe width.
float | int | null$heightThe height.
bool$adjustPageSize
Return values
arrayThe size
See also
FpdfTplTrait\getTemplateSize()

◆ writePdfType()

writePdfType ( PdfType $value)
protected

Writes a PdfType object to the resulting buffer.

Parameters
PdfType$value
Exceptions
PdfTypeException

Variable Documentation

◆ FpdfTplTrait

trait FpdfTplTrait
Initial value:
{
protected array $templates = []

Trait FpdfTplTrait.

This class adds a templating feature to tFPDF.

◆ FpdiTrait

trait FpdiTrait
Initial value:
{
protected PdfReader[] $readers = []
A PDF reader class.
Definition PdfReader.php:28

The FpdiTrait.

This trait offers the core functionalities of FPDI. By passing them to a trait we can reuse it with e.g. TCPDF in a very easy way.