On Tue, October 17, 2006 9:50 am, [EMAIL PROTECTED] wrote: > I want to change the text color of a word mid-sentence when outputting > text to a pdf file. > > I've looked at pdf_show_boxed and pdf_show_xy, but I dont think either > would actually work the way I need, and I'm hoping their is an easier > way > than trying to step through a long string word by word, then changing > color to display one word, and then trying to continue while making it > all > look as though it flows. This, of course, would open up all kinds of > issues in terms of line feeds and the like > > If anyone has any advice or could help in any way, please let me know > because this has been frustrating.
After you do pdf_show_boxed() for the one color, do this: $textx = pdf_get_value($pdf, 'textx', 0); $texty = pdf_get_value($pdf, 'texty', 0); Now you know where PDFlib "left off" for the last word of that color. You can begin again at that point with a new color. Rinse. Repeat. It's probably going to be a pain to finish off a line, and then do a large chunk of text after that, but it's totally do-able. Note that pdf_show_boxed returns all the text that didn't "fit" -- so if you do this with boxes that are one line, and just keep doing that line after line, interspersing with the colored text and using the pdf_get_value() above, this is totally do-able, if somewhat tedious. If the colored text is "rare" enough, it might be worth doing something like: 1. text up to next colored text 2. pdf_get_value() 3. colored text 4. pdf_get_value() 5. one_line box size for pdf_show_boxed, returns rest of text 6. GOTO 1. particularly if you have huge texts and need performance to not loop through it one line at a time for ALL of it. On the plus side, pdflib, in my experience, tends to generate VERY small and compact PDF output, so the bandwidth is as cheap as it can be... YMMV -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php