[RESOLVED] Make PDF API

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
xtianos
Forum Newbie
Posts: 14
Joined: Tue Mar 11, 2014 9:35 pm

[RESOLVED] Make PDF API

Post by xtianos »

Folks,

Out of ambition I guess, could anyone point me to a tutorial where I can learn how to write my own PHP API to create my own PDFs? I realize that there are multiple APIs available out there; however, I would like to learn how to create my own so I can increase my knowledge of PHP and of any other additional languages I might need to learn in the process. Thanks in advance.
Last edited by xtianos on Fri May 29, 2015 8:55 am, edited 1 time in total.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Make PDF API

Post by requinix »

Exactly how "create my own" do you mean? Learning how to construct a PDF byte by byte? Or learning how to use a third-party converter?

The former will suck. The latter is what everybody else does.
xtianos
Forum Newbie
Posts: 14
Joined: Tue Mar 11, 2014 9:35 pm

Re: Make PDF API

Post by xtianos »

It would be the former.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Make PDF API

Post by requinix »

Alrighty.

I don't know PDFs personally but I've done stuff like this before. First step is locating the PDF specification, which has changed over time so there's a few versions and no doubt some in development. Read through and understand the gist of it. I then start writing classes for the various structures within - nothing fancy, basically just member variables to hold data. Then basic code like constructors and some helper methods.
The goal is to generate a small PDF with a couple words in it. Simplest of simple. Then add support for things as you go.
xtianos
Forum Newbie
Posts: 14
Joined: Tue Mar 11, 2014 9:35 pm

Re: Make PDF API

Post by xtianos »

Roger that! I guess now it's time to hunt down the ISO specification. Thanks for the help.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: [RESOLVED] Make PDF API

Post by Christopher »

There are two parts to this design:

1. The design of the code that holds the data representation of the PDF internally and allows operations to that data.

2. The design of the code that writes the data to a file.

3. The design of the API the programmer uses to access the library.

Evolving toward good designs is going to be important. You might want to look at existing PDF libraries to see what they have done. And since the PDF spec is so large, you need to support a common subset of features first and then keep adding support.

And then there is the whole issue of reading PDFs that involves multiple header, bodies and trailers ...
(#10850)
Post Reply