| |
Open a view where PDF file is to be generated
- Enable PDF Builder integration for this view
- Goto View Properties tab
- Open Components pane
- Check Pdf Builder
- Click on Save button at the bottom of page
- In the view, create a new object of PDF class
- $pdf = new PDF('path', 'paperSize', 'orientation');
- path is the folder path where generated pdf will be stored, this folder should have write access
- paperSize can have values 'letter', 'legal', 'ledger', 'A0', 'A1', 'A2', 'A3', 'A4', 'A5', 'letter' is default
- orientation can have values 'portrait' or 'landscape', 'portrait' is default
- Functions Available
- Text Functions
- SetFontSize(fontSize): Sets default font size for text, eg: $pdf->SetFontSize(12);
- AddFont(fontFamily): Adds a font family and returns the handle
- eg: $helveticaBold = $pdf->AddFont('Helvetica-Bold');
- Valid fontnames are: 'Times-Roman', 'Helvetica', 'Courier', 'Symbol', 'Times-Bold', 'Helvetica-Bold', 'Courier-Bold', 'ZapfDingbats', 'Times-Italic',
- 'Helvetica-Oblique', 'Courier-Oblique', 'Times-BoldItalic', 'Helvetica-BoldOblique', 'Courier-BoldOblique'
- SetText(handle, text): Changes the text added previously at given handle
- SetTextFont(handle, fontSize, fontHandle): Changes the font of the text added previously at given handle
- SetUnits(units, sizeW=0, sizeH=0): Sets unit to specify sizes in pdf
- units can have values inch, cm, point
- if units = point then define sizeW and sizeH if they are different than paper size
- AddText(x, y, text, fontSize, fontNameHandle): Adds the text in pdf
- 'x' is the value of x co-ordinate from left
- 'y' is the value of y co-ordinate from bottom
- 'text' is the text to be added
- 'fontSize' is the size of font for this text
- 'fontNameHandle' is the handle of the added font used for this text
- AddTextWrap(x, y, text, maxWidth, lineHeight, fontSize, fontNameHandle): Adds the text in pdf in wraped format (on multiple lines)
- 'x' is the value of x co-ordinate from left
- 'y' is the value of y co-ordinate from bottom
- 'text' is the text to be added
- 'maxWidth' is the number of maximum characters displayed on each line
- 'lineHeight' is the line height for each line
- 'fontSize' is the size of font for this text
- 'fontNameHandle' is the handle of the added font used for this text
- GetTextWrapLineCount(text, maxWidth, lineHeight, fontSize, fontNameHandle): Returns the number lines needed for a text if wrapped
- 'Text' is the text to be added
- 'maxWidth' is the number of maximum characters displayed on each line
- 'lineHeight' is the line height for each line
- 'fontSize' is the size of font for this text
- 'fontNameHandle' is the handle of the added font used for this text
- Other Functions
- DrawLine(x1, y1, x2, y2, thickness, drawColor);
- 'x1' is the distance of starting point of line from left
- 'y1' is the distance of starting point of line from bottom
- 'x2' is the distance of end point of line from left
- 'y2' is the distance of end point of line from bottom
- 'thickness' is the thickness of line
- 'drawColor' is the color of line
- DrawRectangle(x, y, width, height, thickness, borderColor, fillColor);
- 'x' is the distance of starting point of rectangle from left
- 'y' is the distance of starting point of rectangle from bottom
- 'width' of rectangle
- 'height' of rectangle
- 'thickness' is the thickness of borders of rectangle
- 'borderColor' is the color of borders of rectangle
- 'fillColor' is the color of inside area of rectangle
- AddPage(paperSize, orientation);
- paperSize can have values 'letter', 'legal', 'ledger', 'A0', 'A1', 'A2', 'A3', 'A4', 'A5', 'letter' is default
- orientation can have values 'portrait' or 'landscape', 'portrait' is default
- AddImageResource(imagePath): Adds the image resource of image given at 'imagePath' returns the handle for that image
- AddImage(handle, left, bottom, width, height): Adds the image to the pdf given handle for that image
- handle is the handle of image resource returned by function AddImageResource
- left is the distance of starting point of image from left
- bottom is the distance of starting point of image from bottom
- 'width' of image
- 'height' of image
- Generating Output
- Render(outputfilename)
- eg: $pdf->Render("outputfilename");
- outputfilename is the pdf file name with full path and extention .pdf
|
|