Node Support and Attachment
konsumer - February 6, 2008 - 06:59
| Project: | dompdf |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | konsumer |
| Status: | needs work |
Jump to:
Description
I wanted support for loading nodes as well as views, so I added it, along with an option for "attachment" which allows you to set the attachment (inline or attachment.) This makes it display in the browser window, or as a download.
I could make this more generalized, so there is a central function that does the settings form and rendering, and you can add support for pdf printing whatever you want, but this is all I needed, so I'm posting it, people should let me know if they want support for other stuff.
| Attachment | Size |
|---|---|
| dompdf_node_and_attachment_support.patch | 8.46 KB |

#1
Also, I forgot to mention:
$view_name definition was missing in dompdf_stream_pdf(), I changed it to be $id with $type, so you can use different 'types' (like 'views', or 'node') and id (the name of the view, or content type for nodes) 'views' is the default, so it should work as before.
This also adds support for providing a more general method of adding a form for PDF stuff to things. I think it could all be improved by having a single dompdf_alter function as well as the themeables, and allow modules to add their own hooks (as well as maybe some default includes that do views and node.) Maybe the $form_id could be the key, instead of "views" or "node" and then it would all be automatic, if a modules adds itself to a queue.
Again, this is more then I needed, but I would be willing to code it, if people are interested.
#2
I could not apply this patch to the current version of DOMPDF in CVS. 11 out of 11 hunks failed.
Konsumer: It's funny I started working on this exact functionality right around the time you posted this patch without ever seeing it. I went in a different direction though, I built a separate module that added the ability to download a PDF attachment and allows you to store CSS for the module or for the content type (and was thinking of adding a setting for individual nodes). I think that CSS and better HTML support is what separates the DOMPDF library from the TCPDF library which is a nightmare to theme. I hadn't included support for the inline though that's a good idea, I think I will.
Anyway, I like what you said in your follow up post a lot!!! That is the direction that I think this module should be headed. It should provide an API for other modules. Frankly I'd like to see separate NodePDF and ViewsPDF modules (either packaged with DOMPDF or available separately) in an effort to keep this module light and versatile. Not only am I interested in this functionality I would love to collaborate on it. I am very new to development but I can do a little bit of coding and a lot of testing/brainstorming.
I love the signup_status PDF capabilities, they are seamless.
#3
jrbeeman and I have been talking about new ideas for the dompdf module. I wrote a more modular system, and made separate modules for pdf nodes and views. I added more advanced templating system (replaced the header/footer system, so you can do full-page PDF-specific header/footer stuff, like page-numbering, vector logos, lines, etc) and added a more general API-like way of doing settings form for incorporating with other modules.
The new system I worked out is a much better approach, I think, and it's lighter-weight, while having more functionality. I added support for different paper-sizes (drupal nodes rendered as envelopes!) and optionally hiding the task, so you can provide links to PDF, in some other way, if you want.
You can get a copy of what I currently have here:
http://jetboystudio.com/downloads/pdfapi.tar.gz
When I have more time, I'd like to add a few improvements, like more configuration options, and improve the theming stuff.
It also includes a patched version of dompdf (the lib, not the module,) that has vector graphic support for the Cpdf rendering engine (I don't have a testing system for the pdflib stuff.)
You can see an example of it's usage with this:
http://jetboystudio.com/downloads/pdfapi_theming_example.tar.gz
I include the inkscape file I use to create the logo.ai file (which I exported to Adobe Illustrator 8 format)
It's not perfect rendering, (I couldn't figure out anything like "z-index", so layering is wonky sometimes...) but it definitely saved me some time, in trying to get really high-quality logos into PDFs (it was a lot faster for me to write an AI renderer, then it would have been to draw it with dompdf path primitives)
Just extract it into your current theme dir, and open a drupal PDF (setup a view or content-type to display as a PDF.)
#4
Subscribing, the PDF API module you posted there seems to work very well for me.
#5
Hello,
I use the DOMPDF module to generate output pages from my website. I also use the contemplate module and I notice that the DOMPDF module only allows Views to generate PDF. Does someone have solutions or answers about using DOMPDF (or PDFVIEW) with Contemplate module ?
Thanks
#6
I could be wrong about this but I think that Contemplate effects the PDFview output. PDFview uses the TCPDF library, however, and so theming it is a major pain. I have written a small module that uses the DOMPDF module to allow the output of nodes, my module also allows you to add a "download pdf" button to the bottom of every node of whatever types you specify.
I have not released the module because I wanted to see what was going on with adding this to the DOMPDF module as per Konsumer's patch or connecting it to the PDFAPI thing that he posted about last. If you're interested I could send it to you or perhaps add it as a project.
#7
The above version does the same stuff, makes theming easier, and also has more options for how users can download PDFs (page size, for example)