Writing PDF files from RunRev

jbv jbv.silences at Club-Internet.fr
Mon Dec 1 04:26:05 EST 2003


> > I haven't visited the link, but have some
> > experience writing PDF files from Metacard.
> Wonderful! Have you exported to pdf the full content
> of a field, a card or a whole stack?

Take it easy...    ;-)
It actually began more than 2 years ago on the MC list
when I helped Monte Goulding (sp?) generating PDF
files for one of his projects. I guess Monte also worked
a lot on exporting data as PDF, and that he might be of
some help as well (if not too busy)...
As for me, it's been more than 1.5 years since the last
time I tweaked some PDF in MC... AFAIR it was in
a CGI script : requests sent from a form on a web page
were extracting data from a database and exporting them
on the fly as PDF for download.
AFAIR I used "templates" (PDF files made in Illustrator)
featuring keywords, and the replace cmd was used to
insert accurate data in the file that was then saved as PDF.
Before saving, I had to change in the trailer the number of
bytes in the file, otherwise it would generate an error when
opening the file, and AFAIR some versions of Acrobat
Reader on some platforms even refused to open it.

IMHO "exporting a card or a whome stack" as PDF is not
the best way to approach the problem. I mean : we're talking
of completely different languages / environments.
So I guess the best is to :
- decide how you want your data to be displayed in PDF
- build one (or several) PDF templates
- write a "PDF export" handler that picks data (field content,
etc) in your stack and insert it in the PDF file
- fine tune your PDF file (according to the data inserted) and
save it.

Probably a more general PDF library could be created, but I
doubt it will cover all needs...

> For this reason, I'm interested to know if the
> code of this site still works.
> <http://www.mactech.com/articles/mactech/Vol.16/16.03/DynamicPDF/>
> Maybe it does not works for me because the wrong
> line endings or because it had to be written
> as binary data.
> > the more closely your file follows the PDF
> > format requirements, the better.
> I agree, but my experience writing
> binary data is NULL... :((

Sorry I'm too busy right now to check this code (PDF code
is totally off my head right now).
Nevertheless, I would suggest that you don't spend too much
time debugging code made by others. You'd better write your
own code, following the PDF tutorial reference.
Another solution is to produce PDF files from Illustrator, and
see if they work fine.

Last but not least : IMHO you don't need to bother with binary
data. There are actually 2 types of PDF files : compressed and
uncompressed. Uncompressed files (like those produced by
Illustrator) are just ASCII (and if you study them carefully you
will see how close PDF is from PostScript). In all my PDF
teakings with MC, I always used uncompressed format.
The only drawback is that you'll have to deal with HUGE
files sometimes...


More information about the Use-livecode mailing list