dolibarr  16.0.5
Functions
pdf.lib.php File Reference

Set of functions used for PDF generation. More...

Go to the source code of this file.

Functions

 pdf_admin_prepare_head ()
 Return array head with list of tabs to view object informations. More...
 
 pdf_getFormat (Translate $outputlangs=null, $mode='setup')
 Return array with format properties of default PDF format. More...
 
 pdf_getInstance ($format='', $metric='mm', $pagetype='P')
 Return a PDF instance object. More...
 
 pdf_getEncryption ($pathoffile)
 Return if pdf file is protected/encrypted. More...
 
 pdf_getPDFFont ($outputlangs)
 Return font name to use for PDF generation. More...
 
 pdf_getPDFFontSize ($outputlangs)
 Return font size to use for PDF generation. More...
 
 pdf_getHeightForLogo ($logo, $url=false)
 Return height to use for Logo onto PDF. More...
 
 pdfGetHeightForHtmlContent (&$pdf, $htmlcontent)
 Function to try to calculate height of a HTML Content. More...
 
 pdfBuildThirdpartyName ($thirdparty, Translate $outputlangs, $includealias=0)
 Returns the name of the thirdparty. More...
 
 pdf_build_address ($outputlangs, $sourcecompany, $targetcompany='', $targetcontact='', $usecontact=0, $mode='source', $object=null)
 Return a string with full address formated for output on documents. More...
 
 pdf_pagehead (&$pdf, $outputlangs, $page_height)
 Show header of page for PDF generation. More...
 
 pdf_getSubstitutionArray ($outputlangs, $exclude=null, $object=null, $onlykey=0)
 Return array of possible substitutions for PDF content (without external module substitutions). More...
 
 pdf_watermark (&$pdf, $outputlangs, $h, $w, $unit, $text)
 Add a draft watermark on PDF files. More...
 
 pdf_bank (&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber=0, $default_font_size=10)
 Show bank informations for PDF generation. More...
 
 pdf_pagefoot (&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0, $page_largeur=0, $watermark='')
 Show footer of page for PDF generation. More...
 
 pdf_writeLinkedObjects (&$pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size)
 Show linked objects for PDF generation. More...
 
 pdf_writelinedesc (&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $posy, $hideref=0, $hidedesc=0, $issupplierline=0)
 Output line description into PDF. More...
 
 pdf_getlinedesc ($object, $i, $outputlangs, $hideref=0, $hidedesc=0, $issupplierline=0)
 Return line description translated in outputlangs and encoded into htmlentities and with
More...
 
 pdf_getlinenum ($object, $i, $outputlangs, $hidedetails=0)
 Return line num. More...
 
 pdf_getlineref ($object, $i, $outputlangs, $hidedetails=0)
 Return line product ref. More...
 
 pdf_getlineref_supplier ($object, $i, $outputlangs, $hidedetails=0)
 Return line ref_supplier. More...
 
 pdf_getlinevatrate ($object, $i, $outputlangs, $hidedetails=0)
 Return line vat rate. More...
 
 pdf_getlineupexcltax ($object, $i, $outputlangs, $hidedetails=0)
 Return line unit price excluding tax. More...
 
 pdf_getlineupwithtax ($object, $i, $outputlangs, $hidedetails=0)
 Return line unit price including tax. More...
 
 pdf_getlineqty ($object, $i, $outputlangs, $hidedetails=0)
 Return line quantity. More...
 
 pdf_getlineqty_asked ($object, $i, $outputlangs, $hidedetails=0)
 Return line quantity asked. More...
 
 pdf_getlineqty_shipped ($object, $i, $outputlangs, $hidedetails=0)
 Return line quantity shipped. More...
 
 pdf_getlineqty_keeptoship ($object, $i, $outputlangs, $hidedetails=0)
 Return line keep to ship quantity. More...
 
 pdf_getlineunit ($object, $i, $outputlangs, $hidedetails=0, $hookmanager=false)
 Return line unit. More...
 
 pdf_getlineremisepercent ($object, $i, $outputlangs, $hidedetails=0)
 Return line remise percent. More...
 
 pdf_getlineprogress ($object, $i, $outputlangs, $hidedetails=0, $hookmanager=null)
 Return line percent. More...
 
 pdf_getlinetotalexcltax ($object, $i, $outputlangs, $hidedetails=0)
 Return line total excluding tax. More...
 
 pdf_getlinetotalwithtax ($object, $i, $outputlangs, $hidedetails=0)
 Return line total including tax. More...
 
 pdf_getLinkedObjects (&$object, $outputlangs)
 Return linked objects to use for document generation. More...
 
 pdf_getSizeForImage ($realpath)
 Return dimensions to use for images onto PDF checking that width and height are not higher than maximum (16x32 by default). More...
 
 pdfGetLineTotalDiscountAmount ($object, $i, $outputlangs, $hidedetails=0)
 Return line total amount discount. More...
 

Detailed Description

Set of functions used for PDF generation.

Definition in file pdf.lib.php.

Function Documentation

◆ pdf_admin_prepare_head()

pdf_admin_prepare_head ( )

Return array head with list of tabs to view object informations.

Returns
array head array with tabs

Definition at line 46 of file pdf.lib.php.

◆ pdf_bank()

pdf_bank ( $pdf,
  $outputlangs,
  $curx,
  $cury,
  $account,
  $onlynumber = 0,
  $default_font_size = 10 
)

Show bank informations for PDF generation.

Parameters
TCPDF$pdfObject PDF
Translate$outputlangsObject lang
int$curxX
int$curyY
Account$accountBank account object
int$onlynumberOutput only number (bank+desk+key+number according to country, but without name of bank and domiciliation)
int$default_font_sizeDefault font size
Returns
float The Y PDF position

Definition at line 812 of file pdf.lib.php.

◆ pdf_build_address()

pdf_build_address (   $outputlangs,
  $sourcecompany,
  $targetcompany = '',
  $targetcontact = '',
  $usecontact = 0,
  $mode = 'source',
  $object = null 
)

Return a string with full address formated for output on documents.

Parameters
Translate$outputlangsOutput langs object
Societe$sourcecompanySource company object
Societe | string | null$targetcompanyTarget company object
Contact | string | null$targetcontactTarget contact object
int$usecontactUse contact instead of company
string$modeAddress type ('source', 'target', 'targetwithdetails', 'targetwithdetails_xxx': target but include also phone/fax/email/url)
Object$objectObject we want to build document for
Returns
string String with full address

Definition at line 427 of file pdf.lib.php.

◆ pdf_getEncryption()

pdf_getEncryption (   $pathoffile)

Return if pdf file is protected/encrypted.

Parameters
string$pathoffilePath of file
Returns
boolean True or false

Definition at line 234 of file pdf.lib.php.

◆ pdf_getFormat()

pdf_getFormat ( Translate  $outputlangs = null,
  $mode = 'setup' 
)

Return array with format properties of default PDF format.

Parameters
Translate$outputlangsOutput lang to use to autodetect output format if we need 'auto' detection
string$mode'setup' = Use setup, 'auto' = Force autodetection whatever is setup
Returns
array Array('width'=>w,'height'=>h,'unit'=>u);

Definition at line 84 of file pdf.lib.php.

◆ pdf_getHeightForLogo()

pdf_getHeightForLogo (   $logo,
  $url = false 
)

Return height to use for Logo onto PDF.

Parameters
string$logoFull path to logo file to use
bool$urlImage with url (true or false)
Returns
number

Definition at line 313 of file pdf.lib.php.

◆ pdf_getInstance()

pdf_getInstance (   $format = '',
  $metric = 'mm',
  $pagetype = 'P' 
)

Return a PDF instance object.

We create a FPDI instance that instantiate TCPDF.

Parameters
string$formatArray(width,height). Keep empty to use default setup.
string$metricUnit of format ('mm')
string$pagetype'P' or 'l'
Returns
TCPDF PDF object

Definition at line 126 of file pdf.lib.php.

◆ pdf_getlinedesc()

pdf_getlinedesc (   $object,
  $i,
  $outputlangs,
  $hideref = 0,
  $hidedesc = 0,
  $issupplierline = 0 
)

Return line description translated in outputlangs and encoded into htmlentities and with

Parameters
Object$objectObject
int$iCurrent line number (0 = first line, 1 = second line, ...)
Translate$outputlangsObject langs for output
int$hiderefHide reference
int$hidedescHide description
int$issupplierlineIs it a line for a supplier object ?
Returns
string String with line

Definition at line 1395 of file pdf.lib.php.

◆ pdf_getlinenum()

pdf_getlinenum (   $object,
  $i,
  $outputlangs,
  $hidedetails = 0 
)

Return line num.

Parameters
Object$objectObject
int$iCurrent line number
Translate$outputlangsObject langs for output
int$hidedetailsHide details (0=no, 1=yes, 2=just special lines)
Returns
string

Definition at line 1687 of file pdf.lib.php.

◆ pdf_getlineprogress()

pdf_getlineprogress (   $object,
  $i,
  $outputlangs,
  $hidedetails = 0,
  $hookmanager = null 
)

Return line percent.

Parameters
Object$objectObject
int$iCurrent line number
Translate$outputlangsObject langs for output
int$hidedetailsHide details (0=no, 1=yes, 2=just special lines)
HookManager$hookmanagerHook manager instance
Returns
string

Definition at line 2178 of file pdf.lib.php.

◆ pdf_getlineqty()

pdf_getlineqty (   $object,
  $i,
  $outputlangs,
  $hidedetails = 0 
)

Return line quantity.

Parameters
Object$objectObject
int$iCurrent line number
Translate$outputlangsObject langs for output
int$hidedetailsHide details (0=no, 1=yes, 2=just special lines)
Returns
string

Definition at line 1931 of file pdf.lib.php.

◆ pdf_getlineqty_asked()

pdf_getlineqty_asked (   $object,
  $i,
  $outputlangs,
  $hidedetails = 0 
)

Return line quantity asked.

Parameters
Object$objectObject
int$iCurrent line number
Translate$outputlangsObject langs for output
int$hidedetailsHide details (0=no, 1=yes, 2=just special lines)
Returns
string

Definition at line 1971 of file pdf.lib.php.

◆ pdf_getlineqty_keeptoship()

pdf_getlineqty_keeptoship (   $object,
  $i,
  $outputlangs,
  $hidedetails = 0 
)

Return line keep to ship quantity.

Parameters
Object$objectObject
int$iCurrent line number
Translate$outputlangsObject langs for output
int$hidedetailsHide details (0=no, 1=yes, 2=just special lines)
Returns
string

Definition at line 2051 of file pdf.lib.php.

◆ pdf_getlineqty_shipped()

pdf_getlineqty_shipped (   $object,
  $i,
  $outputlangs,
  $hidedetails = 0 
)

Return line quantity shipped.

Parameters
Object$objectObject
int$iCurrent line number
Translate$outputlangsObject langs for output
int$hidedetailsHide details (0=no, 1=yes, 2=just special lines)
Returns
string

Definition at line 2011 of file pdf.lib.php.

◆ pdf_getlineref()

pdf_getlineref (   $object,
  $i,
  $outputlangs,
  $hidedetails = 0 
)

Return line product ref.

Parameters
Object$objectObject
int$iCurrent line number
Translate$outputlangsObject langs for output
int$hidedetailsHide details (0=no, 1=yes, 2=just special lines)
Returns
string

Definition at line 1720 of file pdf.lib.php.

◆ pdf_getlineref_supplier()

pdf_getlineref_supplier (   $object,
  $i,
  $outputlangs,
  $hidedetails = 0 
)

Return line ref_supplier.

Parameters
Object$objectObject
int$iCurrent line number
Translate$outputlangsObject langs for output
int$hidedetailsHide details (0=no, 1=yes, 2=just special lines)
Returns
string

Definition at line 1752 of file pdf.lib.php.

◆ pdf_getlineremisepercent()

pdf_getlineremisepercent (   $object,
  $i,
  $outputlangs,
  $hidedetails = 0 
)

Return line remise percent.

Parameters
Object$objectObject
int$iCurrent line number
Translate$outputlangsObject langs for output
int$hidedetailsHide details (0=no, 1=yes, 2=just special lines)
Returns
string

Definition at line 2135 of file pdf.lib.php.

◆ pdf_getlinetotalexcltax()

pdf_getlinetotalexcltax (   $object,
  $i,
  $outputlangs,
  $hidedetails = 0 
)

Return line total excluding tax.

Parameters
Object$objectObject
int$iCurrent line number
Translate$outputlangsObject langs for output
int$hidedetailsHide details (0=no, 1=yes, 2=just special lines)
Returns
string Return total of line excl tax

Definition at line 2229 of file pdf.lib.php.

◆ pdf_getlinetotalwithtax()

pdf_getlinetotalwithtax (   $object,
  $i,
  $outputlangs,
  $hidedetails = 0 
)

Return line total including tax.

Parameters
Object$objectObject
int$iCurrent line number
Translate$outputlangsObject langs for output
int$hidedetailsHide value (0 = no, 1 = yes, 2 = just special lines)
Returns
string Return total of line incl tax

Definition at line 2285 of file pdf.lib.php.

◆ pdf_getlineunit()

pdf_getlineunit (   $object,
  $i,
  $outputlangs,
  $hidedetails = 0,
  $hookmanager = false 
)

Return line unit.

Parameters
Object$objectObject
int$iCurrent line number
Translate$outputlangsObject langs for output
int$hidedetailsHide details (0=no, 1=yes, 2=just special lines)
HookManager$hookmanagerHook manager instance
Returns
string Value for unit cell

Definition at line 2092 of file pdf.lib.php.

◆ pdf_getlineupexcltax()

pdf_getlineupexcltax (   $object,
  $i,
  $outputlangs,
  $hidedetails = 0 
)

Return line unit price excluding tax.

Parameters
Object$objectObject
int$iCurrent line number
Translate$outputlangsObject langs for output
int$hidedetailsHide details (0=no, 1=yes, 2=just special lines)
Returns
string

Definition at line 1846 of file pdf.lib.php.

◆ pdf_getlineupwithtax()

pdf_getlineupwithtax (   $object,
  $i,
  $outputlangs,
  $hidedetails = 0 
)

Return line unit price including tax.

Parameters
Object$objectObject
int$iCurrent line number
Translate$outputlangsObject langs for output
int$hidedetailsHide value (0 = no, 1 = yes, 2 = just special lines)
Returns
string

Definition at line 1889 of file pdf.lib.php.

◆ pdf_getlinevatrate()

pdf_getlinevatrate (   $object,
  $i,
  $outputlangs,
  $hidedetails = 0 
)

Return line vat rate.

Parameters
Object$objectObject
int$iCurrent line number
Translate$outputlangsObject langs for output
int$hidedetailsHide details (0=no, 1=yes, 2=just special lines)
Returns
string

Definition at line 1784 of file pdf.lib.php.

◆ pdf_getLinkedObjects()

pdf_getLinkedObjects ( $object,
  $outputlangs 
)

Return linked objects to use for document generation.

Warning: To save space, this function returns only one link per link type (all links are concated on same record string). This function is used by pdf_writeLinkedObjects

Parameters
object$objectObject
Translate$outputlangsObject lang for output
Returns
array Linked objects

Definition at line 2340 of file pdf.lib.php.

◆ pdf_getPDFFont()

pdf_getPDFFont (   $outputlangs)

Return font name to use for PDF generation.

Parameters
Translate$outputlangsOutput langs object
Returns
string Name of font to use

Definition at line 265 of file pdf.lib.php.

◆ pdf_getPDFFontSize()

pdf_getPDFFontSize (   $outputlangs)

Return font size to use for PDF generation.

Parameters
Translate$outputlangsOutput langs object
Returns
int Size of font to use

Definition at line 288 of file pdf.lib.php.

◆ pdf_getSizeForImage()

pdf_getSizeForImage (   $realpath)

Return dimensions to use for images onto PDF checking that width and height are not higher than maximum (16x32 by default).

Parameters
string$realpathFull path to photo file to use
Returns
array Height and width to use to output image (in pdf user unit, so mm)

Definition at line 2474 of file pdf.lib.php.

◆ pdf_getSubstitutionArray()

pdf_getSubstitutionArray (   $outputlangs,
  $exclude = null,
  $object = null,
  $onlykey = 0 
)

Return array of possible substitutions for PDF content (without external module substitutions).

Parameters
Translate$outputlangsOutput language
array$excludeArray of family keys we want to exclude. For example array('mycompany', 'object', 'date', 'user', ...)
Object$objectObject
int$onlykey1=Do not calculate some heavy values of keys (performance enhancement when we need only the keys), 2=Values are truncated and html sanitized (to use for help tooltip)
Returns
array Array of substitutions

Definition at line 737 of file pdf.lib.php.

◆ pdf_pagefoot()

pdf_pagefoot ( $pdf,
  $outputlangs,
  $paramfreetext,
  $fromcompany,
  $marge_basse,
  $marge_gauche,
  $page_hauteur,
  $object,
  $showdetails = 0,
  $hidefreetext = 0,
  $page_largeur = 0,
  $watermark = '' 
)

Show footer of page for PDF generation.

Parameters
TCPDF$pdfThe PDF factory
Translate$outputlangsObject lang for output
string$paramfreetextConstant name of free text
Societe$fromcompanyObject company
int$marge_basseMargin bottom we use for the autobreak
int$marge_gaucheMargin left (no more used)
int$page_hauteurPage height
Object$objectObject shown in PDF
int$showdetailsShow company adress details into footer (0=Nothing, 1=Show address, 2=Show managers, 3=Both)
int$hidefreetext1=Hide free text, 0=Show free text
int$page_largeurPage width
int$watermarkWatermark text to print on page
Returns
int Return height of bottom margin including footer text

Definition at line 989 of file pdf.lib.php.

◆ pdf_pagehead()

pdf_pagehead ( $pdf,
  $outputlangs,
  $page_height 
)

Show header of page for PDF generation.

Parameters
TCPDF$pdfObject PDF
Translate$outputlangsObject lang for output
int$page_heightHeight of page
Returns
void

Definition at line 711 of file pdf.lib.php.

◆ pdf_watermark()

pdf_watermark ( $pdf,
  $outputlangs,
  $h,
  $w,
  $unit,
  $text 
)

Add a draft watermark on PDF files.

Parameters
TCPDF$pdfObject PDF
Translate$outputlangsObject lang
int$hHeight of PDF
int$wWidth of PDF
string$unitUnit of height (mm, pt, ...)
string$textText to show
Returns
void

Definition at line 757 of file pdf.lib.php.

◆ pdf_writelinedesc()

pdf_writelinedesc ( $pdf,
  $object,
  $i,
  $outputlangs,
  $w,
  $h,
  $posx,
  $posy,
  $hideref = 0,
  $hidedesc = 0,
  $issupplierline = 0 
)

Output line description into PDF.

Parameters
TCPDF$pdfPDF object
Object$objectObject
int$iCurrent line number
Translate$outputlangsObject lang for output
int$wWidth
int$hHeight
int$posxPos x
int$posyPos y
int$hiderefHide reference
int$hidedescHide description
int$issupplierlineIs it a line for a supplier object ?
Returns
string

Definition at line 1345 of file pdf.lib.php.

◆ pdf_writeLinkedObjects()

pdf_writeLinkedObjects ( $pdf,
  $object,
  $outputlangs,
  $posx,
  $posy,
  $w,
  $h,
  $align,
  $default_font_size 
)

Show linked objects for PDF generation.

Parameters
TCPDF$pdfObject PDF
object$objectObject
Translate$outputlangsObject lang
int$posxX
int$posyY
float$wWidth of cells. If 0, they extend up to the right margin of the page.
float$hCell minimum height. The cell extends automatically if needed.
int$alignAlign
string$default_font_sizeFont size
Returns
float The Y PDF position

Definition at line 1309 of file pdf.lib.php.

◆ pdfBuildThirdpartyName()

pdfBuildThirdpartyName (   $thirdparty,
Translate  $outputlangs,
  $includealias = 0 
)

Returns the name of the thirdparty.

Parameters
Societe | Contact$thirdpartyContact or thirdparty
Translate$outputlangsOutput language
int$includealias1=Include alias name after name
Returns
string String with name of thirdparty (+ alias if requested)

Definition at line 386 of file pdf.lib.php.

◆ pdfGetHeightForHtmlContent()

pdfGetHeightForHtmlContent ( $pdf,
  $htmlcontent 
)

Function to try to calculate height of a HTML Content.

Parameters
TCPDF$pdfPDF initialized object
string$htmlcontentHTML Contect
Returns
int Height
See also
getStringHeight()

Definition at line 338 of file pdf.lib.php.

◆ pdfGetLineTotalDiscountAmount()

pdfGetLineTotalDiscountAmount (   $object,
  $i,
  $outputlangs,
  $hidedetails = 0 
)

Return line total amount discount.

Parameters
Object$objectObject
int$iCurrent line number
Translate$outputlangsObject langs for output
int$hidedetailsHide details (0=no, 1=yes, 2=just special lines)
Returns
string Return total of line excl tax

Definition at line 2504 of file pdf.lib.php.