Skip to content

{ Category Archives } PHP

Fractions and Units in PHP

For the bililite webservices, I kept all the data in what I would call "standard" American medical units, centimeters for height, kilograms for weight, mmHg for blood pressure, mg/dl for bilirubin. But lots of doctors use pounds and inches, and it would be nice to allow those as well. I could have separate data entry […]

Don’t Reinvent the Wheel, PDF Style

After playing with creating PDFs with PHP using fPDF for a while, and trying to get everything to work consistently, I discovered tcpdf, which is a fork of fpdf that includes everything that anyone has ever added to the original. And I mean everything; this thing is huge! I printed out the source to see […]

Paths, Vector Graphics and PHP images in FPDF

Looking at FPDF and at my PDF tutorial, it is clear that there are a few things that PDF's can do that aren't part of the API of FPDF. However, FPDF is easily extensible to include everything I might find useful, so I put together a package of those routines. See the code. See the […]

Creating PDFs with PHP, part 5: Text

Now we need to add text. That's the most useful part of a PDF, and the easiest. Also the hardest. Sometimes life is like that. See the code.

Creating PDFs with PHP, part 4: Images

Now that we can draw in our PDF, we want to add images. There are two kinds of images, bitmapped and vector. In PDF, images are called XObjects (The X stands for external, meaning defined outside the page). Vector images are easier, since they are just packages of PDF drawing commands, a sort of macro. […]

Creating PDFs with PHP, part 3: Drawing

Now that we can create blank PDF's, it's time to add some stuff. Vector drawing commands (lines and shapes) are simple; you just add the commands to the page content stream. In terms of the original class that would be: $this->pages[count($this->pages)-1]->contents .= "the command\n"; // we just need some whitespace at the end, but the […]

Creating PDFs with PHP, part 2: A Blank Page

Continuing my attempt to dissect FDPF to understand PDF's, we'll create the simplest PDF: a blank page. We need a couple of objects: Catalog This serves as the root object and describes the data structures in the document, which for our purposes is just the collection of printed pages. Other things, like the data for […]

Creating PDFs with PHP: Syntax

I wanted to allow my webservices to create PDF files, and I figured it couldn't be too hard—after all, it's just a bunch of graphics commands in a text file, right? Foolish me. The reference manual is 756 pages long, not including the javascript reference, another 769 pages. The place to start is fPDF, which […]

A Search Box for the Website

I've been playing with search engines and for the search API I'm going with Bing; Google limits their free API to 100 queries a day and requires creating a custom search engine. Bing requires signing up and getting an "AppID" but from there it's unlimited. Documentation is, well, Microsoftian: impossible to find and hard to […]

Sitemeter Stats for non-HTML pages

Sitemeter works by inserting an image and iframe into your page, so that when the browser retrieves it, sitemeter can look at the referer and know what page was visited. But you can't include image links in an XML or GIF file, so I can't tell which of the bililite webservices are being visited. But […]