Page 301 - Open Soource Technologies 304.indd
P. 301

Unit 12: Portable Document Format



            The pdf_show_boxed( ) function returns the number of characters that did not fit in the box. If   Notes
            the feature parameter is present, it must be set to the string “blind”. This prevents the text from
            being drawn on the page and is useful for checking whether a string will fit in the box without
            actually drawing it.




                        Develop a PHP program to show the use of text functions in PDF.


            12.3.3 Text Attributes

            There are three common ways to alter the appearance of text. One is to underline, overline, or
            strike out the text using parameters. Another is to change the stroking and filling. The third is
            to change the text’s color.
            Each of the underline,  overline,  and strikeout parameters  may  be set  to “true” or “false”
            independently of the others. For example:
            pdf_set_parameter($pdf, “underline”, “true”); // enable underlining
            Stroking text means drawing a line around the path defined by the text. The effect is an outline
            of the text. Filling text means to fill the shape defined by the text.
            You can set whether text should be stroked or filled with the textrendering parameter. The valid
            values are shown in Table 12.2.

                            Table 12.2: Values for the Text Rendering Parameter

                             Value                 Effect
                               0     Normal
                               1     Stroke (outline)
                               2     Fill and stroke
                               3     Invisible
                               4     Normal, add to clipping path
                               5     Fill and stroke, add to clipping path
                               6     Invisible, add to clipping path


            You can select the text color using the pdf_setcolor( ) function:
            pdf_setcolor(pdf, type, colorspace, c1 [, c2, c3 [, c4]]);

            The type parameter is either “stroke”, “fill”, or “both”, indicating whether you’re specifying the
            color to be used for outlining the letters, filling the letters, or both. The colorspace parameter is
            one of “gray”, “rgb”, “cmyk”, “spot”, or “pattern”. The “gray”, “spot”, and “pattern” colorspaces
            take only one color parameter, whereas “rgb” takes three and “cmyk” takes all four.
            Example shows colors, underlines, overlines, strikeouts, stroking, and filling at work.

                          Changing text attributes
            <?php

            $p = pdf_new( );




                                             LOVELY PROFESSIONAL UNIVERSITY                                   295
   296   297   298   299   300   301   302   303   304   305   306