1. Trang chủ
  2. » Công Nghệ Thông Tin

PHP Developer''''s Dictionary- P55 potx

5 187 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 5
Dung lượng 365,66 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Syntax int cpdf_open int compression, string filename Description The cpdf_open function, which was added in PHP 3.0.8 and PHP 4.0.b4, creates a new PDF document.. cpdf_close Syntax

Trang 1

Syntax

int cpdf_open (int compression, string filename)

Description

The cpdf_open() function, which was added in PHP 3.0.8 and PHP 4.0.b4, creates a new PDF document A compression parameter value other than 0 indicates that compression should be used The optional filename parameter names the file to

which the contents should be written By not specifying a filename, you can have the document created in memory, and then later decide to write it to a file or stream back to the client through standard out Use cpdf_save_to_file() to save a copy of the file, and use cpdf_output_buffer() to send the contents to standard out The ClibPDF library does accept "-" as a filename parameter to indicate standard out, but when PHP is used as an Apache module, you must use the cpdf_output_buffer() function instead of this shortcut The return value is used as

a handle to most other ClibPDF functions

cpdf_close()

Syntax

void cpdf_close (int pdf document)

Description

The cpdf_close() function, which was added in PHP 3.0.8 and PHP 4.0.b4, closes an active pdf document Make sure to call this function when you have finished

processing the PDF document because doing so releases all memory and file resources allocated by the library during processing You also need to free any additional resources you created—such as plots—because this is not done automatically

cpdf_page_init()

Syntax

void cpdf_page_init (int pdf document, int page number, int

orientation, double height, double

width, double unit)

Trang 2

The cpdf_page_init() function, which was added in PHP 3.0.8 and PHP 4.0.b4, initializes an individual page for writing The pdf_document parameter is the handle

returned from cpdf_open() The page_number parameter indicates the page to

which you want to write For a single-page document, this should be 1; for a multi-page document, you can start with 1 or any larger number The orientation parameter enables you to indicate whether the page should be written in landscape (1) or portrait (0) format The height and width parameters specify the size of the

page based on the unit parameter, which is the number of points per unit This

defaults to 72, which is the number of points in one inch The following code will initialize page 1, set the page orientation to portrait, and set the dimensions to 8.5´11 inches

cpdf_page_init($cpdf, 1, 0, 792,612);

cpdf_finalize_page()

Syntax

void cpdf_finalize_page (int pdf document, int page number)

Description

The cpdf_finalize_page() function, which was added in PHP 3.0.10 and PHP 4.0.b4, ends the page specified by page_number A page cannot be modified after it

has been finalized This should be used with longer documents for efficient memory use, but isn't necessary for shorter documents (3 pages or fewer)

cpdf_finalize()

Syntax

void cpdf_finalize (int pdf document)

Description

The cpdf_finalize() function, which was added in PHP 3.0.8 and PHP 4.0.b4, finishes the document so that it can be streamed to the client or stored in a file

cpdf_output_buffer()

Syntax

Trang 3

void cpdf_outpuf_buffer (int pdf document)

Description

The cpdf_output_buffer() function, which was added in PHP 3.0.9 and PHP 4.0.b4, dumps the contents of the current buffer to stdout This is used when the cpdf_open() is called without a filename parameter, which causes the contents to

be held in memory

cpdf_save_to_file()

Syntax

void cpdf_save_to_file (int pdf document, string filename)

Description

The cpdf_save_to_file() function, which was added in PHP 3.0.8 and PHP 4.0.b4, dumps the contents of the current buffer to a file designated by the filename parameter This is useful when no filename is specified with the cpdf_open() function, which causes the document to be created and stored in memory

cpdf_set_current_page()

Syntax

void cpdf_set_current_page (int pdf document, int page number)

Description

The cpdf_set_current_page() function, which was added in PHP 3.0.9 and PHP 4.0.b4, specifies the page in the document to which subsequent commands pertain You can switch between multiple pages in a document, but after the cpdf_finalize_page() function is called, you can no longer modify that page Note that if you switch pages, the domain will revert back to the default domain for that page Domains are commonly used to enable you to switch easily between coordinate systems

cpdf_begin_text()

Trang 4

void cpdf_begin_text(int pdf document)

Description

The cpdf_begin_text() function, which was added in PHP 3.0.8 and PHP 4.0.b4, marks the beginning of a text section in a PDF page The cpdf_end_text() function

is called when the text section is complete Multiple lines of text can be drawn within

a text section as long as they share the same font

<?pdf cpdf_begin_text($pdf);

cpdf_set_font($pdf, 12,"Times-Roman","WinAnsiEncoding");

cpdf_text($pdf,50,50,"First line of text");

cpdf_text($pdf,50,100,"Second line of text");

cpdf_end_text($pdf) ?>

cpdf_end_text()

Syntax

void cpdf_end_text (int pdf document)

Description

The cpdf_end_text() function, which was added in PHP 3.0.8 and PHP 4.0.b4, marks the end of the text section All text sections must start with cpdf_begin_text() and end with cpdf_end_text()

cpdf_show()

Syntax

void cpdf_show (int pdf document, string text)

Description

The cpdf_show() function, which was added in PHP 3.0.8 and PHP 4.0.b4, outputs the text parameter at the current text point The lower-left corner of text is aligned

with the current point The current text point is updated to be the end of the text string

Trang 5

cpdf_show_xy()

Syntax

void cpdf_show_xy (int pdf document, string text,

double x-coor, double y-coor, int mode)

Description

The cpdf_show_xy() function, which was added in PHP 3.0.8 and PHP 4.0.b4, outputs the text parameter at the position indicated by the x-coor and y-coor

parameters The optional mode parameter is used to indicate the unit length in points

(72 points per inch) Omitting a value or specifying 0 causes the default page unit to

be used

cpdf_text()

Syntax

void cpdf_text (int pdf document, string text,

double x-coor, double y-coor, int mode, double orientation, int

alignmode)

Description

The cpdf_text() function, which was added in PHP 3.0.8 and PHP 4.0.b4, outputs the text parameter at the position indicated by the x-coor and y-coor parameters

The optional mode parameter is used to indicate the unit length in points (72 points

per inch) Omitting a value or specifying 0 causes the default page unit to be used The optional parameter orientation is used to indicate that text should be rotated

orientation degrees from the horizontal axis The optional alignmode parameter

indicates how the text should be placed relative to the current text point Align modes are defined in the cpdflib.h file The possible values are formed with

"TEXT_POS_" and a location indicator concatenated together Possible values are UL,

ML, LL, UM, MM, LM, UR, MR, LR, where L is left or lower, M is middle, U is upper, and R

is right For example, TEXT_POS_LL indicates that the lower-left corner of text should be located at the x and y coordinates

cpdf_set_font()

Syntax

Ngày đăng: 07/07/2014, 05:20