Skip to content

{ Author Archives }

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 692 pages. The place to start is fPDF, which [...]

Javascript == Lisp, again

I've been trying on and off to get my head around continuations in Scheme, which is the language that gnucash uses for reports. It's one of the modern versions of Lisp. And then I came across a throwaway line in the YQL documentation about JSONP with a callback is a also called continuation-passing style. A [...]

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 [...]

Trying to Search with Bing and Failing

I'm not a fan of having to create a Google Custom Search Engine to limit searches to one site with an HTML form (which seems to be necessary for mobile sites), so let's play with Bing: <form method="get" action="http://www.bing.com/search" > <input name="q" type="text"/> <input type="submit" value="Search with Bing"/> <input name="q1" value="site:http://bililite.nfshost.com/blog" type="hidden"/> </form> And it [...]

Back to a Simple Google Search Form

Earlier, I noted that the old, simple Google search: <form method="get" action="http://www.google.com/search" > <input name="q" type="text"/> <input type="submit" value="Search with Google"/> <input name="sitesearch" value="http://bililite.nfshost.com/blog" type="hidden"/> </form> is deprecated and doesn't work from Google's mobile site. Google does have an API for custom searches that has all sorts of fancy parameters to manipulate, but it requires [...]