Go to Scriptcase store

# PDF Advanced settings

## Interface

Using this interface you can define the display layout of cells containing the values of the fields in the body of the report.

PDF interface settings.

- Attributes
  - Seq : Sequential number of cells (ascending order).
  - Cell : Cell name.
  - Pos X : Sets the abscissa of the cell.
  - Pos Y : Sets the ordinate of the cell.
  - Width : Sets the cell width.
  - Alignment : Sets the cell alignment.
  - Field : Here you have to select the field that will be displayed within the cell, according to the application SQL.

## Code

Scriptcase creates the codes automatically, so by changing that within the option “code” you will assume the PDF creation PHP code.

Configuration interface of the PDF Code.

The application “Rport PDF” was developed based on a library called TCPDF, so that you can use the available library methods or a corresponding macro from the table below. In order to use some method you must use $pdf object, for example: $pdf->AcceptPageBreak(parameters).

In order to access the TCPDF documentation Click here

## Macros ReportPDF

Scriptcase Macro | Description
--- | ---
sc_pdf_text | This method allows you to place a string.
sc_pdf_write | This method prints the text of the current position.
sc_pdf_set_y | Sets the current y-axis position.
sc_pdf_set_xy | Sets the current position of the x-axis and y-axis.
sc_pdf_set_top_margin | Defines the top of the margin.
sc_pdf_set_right_margin | Sets the right margin.
sc_pdf_set_left_margin | Sets the left margin.
sc_pdf_set_margins | Sets the left, top, and right margin.
sc_pdf_set_title | Defines the title of the document.
sc_pdf_set_text_color | Sets the color to use for the text.
sc_pdf_set_subject | Defines the subject of the document.
sc_pdf_set_line_width | Sets the length of the pdf line.
sc_pdf_line | Draws a line between two points.
sc_pdf_set_keywords | Associates keywords with the document.
sc_pdf_set_font | Sets the current font size.
sc_pdf_add_font | Defines which font will be used in the text.
sc_pdf_close | Defines the closing of the pdf document.
sc_pdf_error | This method is automatically called in case of a fatal error.
sc_pdf_add_page | Adds a new page to the pdf document.
sc_pdf_footer | This method is responsible for rendering the footer of the pdf document.
sc_pdf_header | This method is responsible for rendering the header of the pdf document.
sc_pdf_get_string_length | Returns the length of a string.
sc_pdf_get_y | Returns the current y-axis position.
sc_pdf_get_x | Returns the current x-axis position.
sc_pdf_link | Adds the link to a rectangular area of the page.
sc_pdf_image | Embed an image in the document.
sc_pdf_set_author | Defines the author of the document.
sc_pdf_set_auto_page_break | Enables or disables the automatic page breaking mode.
sc_pdf_set_compression | Activates or deactivates page compression.
sc_pdf_output | Send the document to a given destination.
sc_pdf_set_creator | Defines the creator of the document.
sc_pdf_set_display_mode | Defines the way the document is to be displayed by the viewer.
sc_pdf_accept_page_break | Whenever a page break condition is met, the method is called.
sc_pdf_ln | Performs a line break.
sc_pdf_rect | Outputs a rectangle. It can be drawn (border only), filled (with no border) or both.
sc_pdf_set_draw_color | Defines the color used for all drawing operations (lines, rectangles and cell borders)
sc_pdf_set_fill_color | Defines the color used for all filling operations.
sc_pdf_multi_cell | This method allows printing text with line breaks.
sc_pdf_cell | Prints a cell (rectangular area) with optional borders, background color and character string.
sc_pdf_add_link | Creates a new internal link and returns its identifier.
sc_pdf_alias_nb_pages | Defines an alias for the total number of pages.
sc_pdf_set_link | Defines the page and position a link points to.

#### sc_pdf_text

Description:

This method allows to place a string precisely on the page.

Parameters:

y: y-axis
txt: string
link: URL

Example:

    sc_pdf_text("1","1","Your Text Here");

Scope:

Layout PDf > Código > Layout e Corpo

#### sc_pdf_write

Description:

This method prints text from the current position. When the right margin is reached (or the \n character is met) a line break occurs and text continues from the left margin. Upon method exit, the current position is left just at the end of the text. It is possible to put a link on the text.

Parameters:

h: height
txt: string
link: URL

Example:

    sc_pdf_write(150,'Your Text Here','https://www.scriptcase.net');

Scope: PDf Layout > Code > Layout & body

#### sc_pdf_set_y

Description:

Sets the current y-axis position.

Parameters:

y: y-axis

Example:

    sc_pdf_set_y(180,true);

Scope: PDf Layout > Code > Layout & body

#### sc_pdf_set_x

Description:

Sets the current x-axis position.

Parameters:

x: x-axis

Example:

    sc_pdf_set_x(180);

Scope: PDf Layout > Code > Layout & body

#### sc_pdf_set_xy

Description:

Sets the current position of the x-axis and y-axis.

Parameters:

x: y-axis
y: x-axis

Example:

    sc_pdf_set_x(180,180);

Scope: PDf Layout > Code > Layout & body

#### sc_pdf_set_top_margin

Description:

Defines the top margin. The method can be called before creating the first page.

Parameters:

margin: the margin

Example:

    sc_pdf_set_top_margin(1000);

Scope:

PDf Layout > Code > Layout & body

#### sc_pdf_set_right_margin

Description:

Defines the right margin. The method can be called before creating the first page.

Example:

    sc_pdf_set_right_margin(1000);

Scope:

PDf Layout > Code > Layout & body

#### sc_pdf_set_left_margin

Description:

Defines the left margin. The method can be called before creating the first page.

Example:

    sc_pdf_set_left_margin(1000);

Scope:

PDf Layout > Code > Layout & body

#### sc_pdf_set_margins

Description:

Defines the left, top and right margins. By default, they equal 1 cm. Call this method to change them.

Parameters:

left: margin left
top: margin top
right: margin right

Example:

    sc_pdf_set_margins(200, 200, 200);

Scope:

PDf Layout > Code > Layout & body

#### sc_pdf_set_title

Description:

Defines the title of the document.

Parâmetro:

`títle: title of the document`

Example:

    sc_pdf_set_title("Your Title Here");

Scope:

PDf Layout > Code > Layout & body

#### sc_pdf_set_text_color

Description:

Defines the color used for text. It can be expressed in RGB components or gray scale. The method can be called before the first page is created and the value is retained from page to page.

Example:

    sc_pdf_set_text_color(106,13,173);
    sc_pdf_write(150,'Your Text Here','https://www.scriptcase.net');

Scope:

PDf Layout > Code > Layout & body

#### sc_pdf_set_subject

Description:

Defines the subject of the document.

Example:

    sc_pdf_set_subject("Your Subject here");

Scope:

PDf Layout > Code > Layout & body

#### sc_pdf_set_line_width

Description:

Defines the line width.

Parameters:

width: margin width

Example:

    sc_pdf_set_line_width(1500);
    sc_pdf_line(50,25,70,35);

Scope:

PDf Layout > Code > Layout & body

#### sc_pdf_line

Description:

Draws a line between two points.

Example:

    sc_pdf_line(50,25,70,35);

Scope:

PDf Layout > Code > Layout & body

#### sc_pdf_set_keywords

Description:

Associates keywords with the document, generally in the form ‘keyword1 keyword2 …’.

Parameters:

keywords: list of keywords

Example:

    sc_pdf_set_keywords(test test2, true);

Scope:

PDf Layout > Code > Layout & body

#### sc_pdf_set_font

Description:

Sets the font used to print character strings. It is mandatory to call this method at least once before printing text or the resulting document would not be valid.

Parameters:

family

Font to be defined.

- Courier (fixed-width)
- Helvetica or Arial (synonymous; sans serif)
- Times (serif)
- Symbol (symbolic)
- ZapfDingbats (symbolic)

style

Font style to be set.

- empty string: regular
- B: bold
- I: italic
- U: underline

size

Font size to be set.

Example:

    sc_pdf_set_font('Arial', 'B', 14)

Scope: PDf Layout > Code > Layout & body

#### sc_pdf_add_font

Description:

Defines which font will be used in the text. You can pass parameters for font-family, font-style and font-size.

Parameters:

family

Font to be defined.

- Courier (fixed-width)
- Helvetica or Arial (synonymous; sans serif)
- Times (serif)
- Symbol (symbolic)
- ZapfDingbats (symbolic)

style

Font style to be set.

- empty string: regular
- B: bold
- I: italic
- U: underline

size

Font size to be set.

file

The font file

By default, the name is constructed from the family and style, in lower case with no spaces.

Example:

    sc_pdf_add_font('Comic', 'I', 'comici.php');

Scope:

Layout PDf > Code > Layout & body

#### sc_pdf_close

Description:

Terminates the PDF document. It is not necessary to call this method explicitly because Output() does it automatically.

Example:

    sc_pdf_close();

Scope:

PDf Layout > Code > Layout & body

#### sc_pdf_error

Description:

This method is automatically called in case of a fatal error; it simply throws an exception with the provided message.

Example:

    sc_pdf_error(“Your Text Here”);

Scope: PDf Layout > Code > Layout & body

#### sc_pdf_add_page

Description:

Adds a new page to the document.

Example:

    sc_pdf_add_page('Portrait','A4',0);

Scope:

PDf Layout > Code > Layout & body

#### sc_pdf_footer

Description:

This method is used to render the page footer. It is automatically called by sc_pdf_add_page() and sc_pdf_close() and should not be called directly by the application.

Example:

    sc_pdf_footer();

Scope:

PDf Layout > Code > Layout & body

#### sc_pdf_header

Description:

This method is used to render the page header. It is automatically called by sc_pdf_add_page() and should not be called directly by the application.

Example:

    sc_pdf_header();

Scope: PDf Layout > Code > Layout & body

#### sc_pdf_get_string_length

Description:

Returns the length of a string in user unit. A font must be selected.

Example:

    sc_pdf_get_string_length("Text To Be Measured");

Scope:

PDf Layout > Code > Layout & body

#### sc_pdf_get_y

Description:

Returns the current y-axis position.

Example:

    sc_pdf_get_y();

Scope:

PDf Layout > Code > Layout & body

#### sc_pdf_get_x

Description:

Returns the current x-axis position.

Example:

    sc_pdf_get_x();

Scope:

PDf Layout > Code > Layout & body

#### sc_pdf_link

Description:

Puts a link on a rectangular area of the page. Text or image links are generally put via Cell(), Write() or Image(), but this method can be useful for instance to define a clickable area inside an image.

Parameters:

x : x-axis
y : y-axis
w : width
h : height
link : url

Example:

    sc_pdf_link(100,100,10,10,'https://scriptcase.com.br');

Scope:

PDf Layout > Code > Layout & body

#### sc_pdf_image

Description:

Embeds an image in the document. Image size can be set in several ways. Supported formats: JPEG, PNG and GIF, the GD extension must be enabled to use GIF.

Parameters:

link : url path
x : x-axis
y : y-axis
w : width
h : height
type : image format

Example:

    sc_pdf_image('http://chart.googleapis.com/chart?cht=p3&chd=t:60,40&chs=250x100&chl=HelloWorld', 60, 30, 90, 0,'PNG');

Scope:

PDf Layout > Code > Layout & body

#### sc_pdf_set_author

Description:

Defines the author of the document.

Example:

    sc_pdf_set_author("Scriptcase");

Scope:

PDf Layout > Code > Layout & body

#### sc_pdf_set_auto_page_break

Description:

Enables or disables the automatic page breaking mode. When enabling, the second parameter is the distance from the bottom of the page that defines the triggering limit. By default, the mode is on and the margin is 2 cm.

Example:

    sc_pdf_set_auto_page_break(true, 10);

Scope:

PDf Layout > Code > Layout & body

#### sc_pdf_set_compression

Description:

Activates or deactivates page compression. When activated, the internal representation of each page is compressed, which leads to a compression ratio of about 2 for the resulting document.

Note: the Zlib extension is required for this feature. If not present, compression will be turned off.

Example:

    sc_pdf_set_compression(true);

Scope:

PDf Layout > Code > Layout & body

#### sc_pdf_output

Description:

Send the document to a given destination: browser, file or string. In the case of a browser, the PDF viewer may be used or a download may be forced.

Parameters:

- I: send the file inline to the browser. The PDF viewer is used if available.
- D: send to the browser and force a file download with the name given by name.
- F: save to a local file with the name given by name (may include a path).
- S: return the document as a string.

Example 1: Save the document to a local directory:

    $pdf->Output('F', 'reports/report.pdf');

Example 2: Force a download:

    $pdf->Output('D', 'report.pdf');

Scope:

PDf Layout > Code > Layout & body

#### sc_pdf_set_creator

Description:

Defines the creator of the document. This is typically the name of the application that generates the PDF.

Example:

    sc_pdf_set_creator(“X Creator”,”true”);

Scope:

PDf Layout > Code > Layout & body

#### sc_pdf_set_display_mode

Description:

Defines the way the document is to be displayed by the viewer.

Parameters:

zoom:

- fullpage: displays the entire page on screen
- fullwidth: uses maximum width of window
- real: uses real size (equivalent to 100% zoom)
- default: uses viewer default mode

layout:

- single: displays one page at once
- continuous: displays pages continuously
- two: displays two pages on two columns
- default: uses viewer default mode

Example:

    sc_pdf_set_display_mode("fullpage", "");

Scope:

PDf Layout > Code > Layout & body

#### sc_pdf_accept_page_break

Description:

Whenever a page break condition is met, the method is called, and the break is issued or not depending on the returned value. This method is called automatically and should not be called directly by the application.

Example:

    sc_pdf_accept_page_break();

Scope:

PDf Layout > Code > Layout & body

#### sc_pdf_ln

Description:

Performs a line break. The current abscissa goes back to the left margin and the ordinate increases by the amount passed in parameter.

Example:

    sc_pdf_ln();

Scope:

PDf Layout > Code > Layout & body

#### sc_pdf_rect

Description:

Outputs a rectangle. It can be drawn (border only), filled (with no border) or both.

Parameters:

- x : x-axis
- y : y-axis
- w : width
- h : height

Estilo de renderização:

D or empty string: draw. This is the default value. F: fill DF ou FD: Draw and fill

Example:

    sc_pdf_rect($x, $y, $w, $h, 'D');

Scope:

PDf Layout > Code > Layout & body

#### sc_pdf_set_draw_color

Description:

Defines the color used for all drawing operations (lines, rectangles and cell borders). It can be expressed in RGB components or gray scale. The method can be called before the first page is created and the value is retained from page to page.

Example:

    sc_pdf_set_draw_color(245, 232, 125);

Scope:

PDf Layout > Code > Layout & body

#### sc_pdf_set_fill_color

Description:

Defines the color used for all filling operations (filled rectangles and cell backgrounds). It can be expressed in RGB components or gray scale. The method can be called before the first page is created and the value is retained from page to page.

Example:

    sc_pdf_set_fill_color(245, 232, 125);

Scope:

PDf Layout > Code > Layout & body

#### sc_pdf_multi_cell

Description:

This method allows printing text with line breaks. They can be automatic (as soon as the text reaches the right border of the cell) or explicit (via the \n character). As many cells as necessary are output, one below the other.

Parameters:

- w: cell width
- h: cell height
- txt: string to print
- border: Indicates if borders must be drawn around the cell block.
- align: Sets the text alignment. Possible values are:
  L: left alignment
  C: center
  R: right alignment
  J: justification (default value)
  fill: Indicates if the cell background must be painted (true) or transparent (false). Default value: false.

Example:

    _sc_pdf_multi_cell(63, 10, "YourText", 1);

Scope:

PDf Layout > Code > Layout & body

#### sc_pdf_cell

Description:

Prints a cell (rectangular area) with optional borders, background color and character string. The upper-left corner of the cell corresponds to the current position. The text can be aligned or centered. After the call, the current position moves to the right or to the next line. It is possible to put a link on the text. If automatic page breaking is enabled and the cell goes beyond the limit, a page break is done before outputting.

Parameters:

- w: cell width
- h: cell height
- txt: string to print
- border: Indicates if borders must be drawn around the cell block.
- align: Sets the text alignment. Possible values are:
  L: left alignment
  C: center
  R: right alignment
  J: justification (default value)
  fill: Indicates if the cell background must be painted (true) or transparent (false). Default value: false.
- link: URL

Example:

    sc_pdf_cell(60, 6, 'Your Text', 0);

Scope:

PDf Layout > Code > Layout & body

#### sc_pdf_add_link

Description:

Creates a new internal link and returns its identifier. An internal link is a clickable area which directs to another place within the document.

Example:

    sc_pdf_add_link();

Scope:

PDf Layout > Code > Layout & body

#### sc_pdf_alias_nb_pages

Description:

Defines an alias for the total number of pages. It will be substituted as the document is closed.

Example:

    sc_pdf_cell(0, 10, 'Page','{nb}', 0, 0, 'C')
    sc_pdf_alias_nb_pages();

Scope:

PDf Layout > Code > Layout & body

#### sc_pdf_set_link

Description:

Defines the page and position a link points to.

Example:

    sc_pdf_set_link($link);

Scope:

PDf Layout > Code > Layout & body

## Positioning

This interface allows you to define the display order of the fields (selecting through the arrows next to the right frame).

Configuration interface of the PDF fields placement.

#####

#####