[pdftex] [slightly off-topic] php and byte serving linearized pdf

James H. Cloos Jr. cloos at jhcloos.com
Sun Jun 1 17:13:37 CEST 2003


>>>>> "Thierry" == Thierry Bouche <thierry.bouche at ujf-grenoble.fr> writes:

Thierry> to mask the actual url of some PDF files, we use a php
Thierry> script which, after some parsing, calls readfile(x.pdf)

Thierry> My problem is that, if the pdf is linearized, this method
Thierry> bypasses the byte-serving dialogue between the acrobat plugin
Thierry> and the apache server...

There are a couple of things you need to do to get the byte serving to
work.  You should get a stat(2) of the pdf file before sending the
headers.  IIRC, php's function for that is fstat().  That will provide
you with most of the info you'll need.

You need to send at least:

        Accept-Ranges: bytes
        Content-Length: <int>
        Content-Type: application/pdf

and maybe also:

        Last-Modified: <date>
        ETag: <string>

Last-Modified and Content-Length are provided by the stat(2) call.
ETag is probably not required, but may help some proxied users.  Check
out the apache src for details on how it generates an etag and
duplicate that algorithm if you want one.

The next step is to actually support byte requests.  For that, there
are several issues you need to address.  rfc2616 has the details.
(I was going to specify them, but there are more than I remembered.)

I mirror rfcs from rsync://ftp.isi.edu/rfcs/.  They have
rfc2616.{txt,ps,pdf}.

-JimC




More information about the pdftex mailing list