Marc's CL-PDF is great for producing new PDF documents in CL, and I intend to use it to create a high quality background image for invoice forms generated by some other program, whose programmers claim that "background images can't be done in our PDF printer".
Right now, I think I would need to (roughly) parse the contents of the generated PDF into a page tree, find the (stream) contents of each page, slap the image in front of it (should be doable by referencing it, I need to look this up), regenerate the administrative stuff and write the file out again.
Or maybe the other way round: generate the required number of pages with background picture with CL-PDF and insert the generated (stream and resource) data. Then CL-PDF would do the housekeeping for me.
That's the background, now for the questions:
1. Does something like this already exist?
2. If not, does anybody have any hints on creating a PDF parser?
And just for the fun of it:
3. Try finding the language reference for PDF via a search engine. Hint: "PDF reference", "PDF language reference", "Adobe PDF format description", "PDF developer documentation" are not very helpful :-)
> Marc's CL-PDF is great for producing new PDF documents in CL, > and I intend to use it to create a high quality background > image for invoice forms generated by some other program, whose > programmers claim that "background images can't be done in our > PDF printer".
> Right now, I think I would need to (roughly) parse the contents > of the generated PDF into a page tree, find the (stream) contents > of each page, slap the image in front of it (should be doable by > referencing it, I need to look this up), regenerate the administrative > stuff and write the file out again.
The easiest way to do this is to parse the PDF file and recreate the structure with CL-PDF objects. Then you can modify it add/remove pages, add content before/after the existing pages content and then have CL-PDF write the new PDF file. I do this on a web site and generate the PDF files in memory to serve HTTP requests. The background PDF is a word generated document (i.e. ugly PDF!)
> Or maybe the other way round: generate the required number of > pages with background picture with CL-PDF and insert the generated > (stream and resource) data. Then CL-PDF would do the housekeeping > for me.
If you generate the background with CL-PDF, then it's much easier to stay in CL and to add content to a page. In fact if you just have a background content (PDF stream) you can insert it in any page you want by doing something like this in the (with-page ...): (write-sequence *existing-pdf-stream* *page-stream*)
> That's the background, now for the questions:
> 1. Does something like this already exist?
> 2. If not, does anybody have any hints on creating a PDF parser?
Marc Battyani <Marc.Batty...@fractalconcept.com> wrote: > The easiest way to do this is to parse the PDF file and recreate the > structure with CL-PDF objects. Then you can modify it add/remove pages, add > content before/after the existing pages content and then have CL-PDF write > the new PDF file. > I do this on a web site and generate the PDF files in memory to serve HTTP > requests. The background PDF is a word generated document (i.e. ugly PDF!)
maybe as bad as Word-generated HTML?? ugh.
>> Or maybe the other way round: generate the required number of >> pages with background picture with CL-PDF and insert the generated >> (stream and resource) data. Then CL-PDF would do the housekeeping >> for me.
> If you generate the background with CL-PDF, then it's much easier to stay in > CL and to add content to a page. In fact if you just have a background > content (PDF stream) you can insert it in any page you want by doing > something like this in the (with-page ...): > (write-sequence *existing-pdf-stream* *page-stream*)
So let's write a PDF parser returning CL-PDF objects. Would you be interested in merging this back to your stuff? If so, do you have any strategic tips regarding package layout etc.?
> So let's write a PDF parser returning CL-PDF objects. > Would you be interested in merging this back to your stuff? > If so, do you have any strategic tips regarding package layout etc.?
I already have a pdf parser which constructs a cl-pdf document from a pdf file but I didn't released it because : 1- it's a quick and dirty hack 2- it's not portable as I use the Lispworks's parser generator
I don't have the time to clean it and make it portable by either writing a stand alone parser for the pdf grammar or using a portable parser generator like zebu. For the lexer, it could be a good idea to look at Michael Parker's lexer generator instead of my hand written one.
If you have some time and are willing to work on this just contact me...