hey everyone
i'm glad that jcnventura ported the pdf function for drupal 5.
but i'm having a problem..
i themed my pdf by adjusting the module's print.tpl.php and print.css. this worked well for getting the pdf for one node.
i have to mention that i used the node id to get the cck fields i want in the template.
with this setup, printing a view renders a blank pdf
to fix this i restored the module's print.tpl.php. and made a print.node-TYPE.tpl.php and put it in my theme folder
but the template isn't used, so it fetches the default print template. so i get fields i don't want.
and printing a view works in this setup.
what i want to achieve is, that my print.node-TYPE.tpl.php get's used for printing the node & the views. so that all my nodes in the view are styled as well and show the right ckk field.
hope this makes sense
thanx in advance!
Comments
Comment #1
jcnventuraHi,
I am assuming that TYPE as you placed there is a placeholder.. I.e. for story types you would use the print.node-story.tpl.php filename..
And also, I am sorry but there's no way that the current system can enable a view to use a type-specific template, simply because views are not types..
I will take a look to see if I can understand what your problem is..
Comment #2
jcnventuraOh, and another thing. The template file must be placed in your current theme's directory, not in the theme folder. The instructions are not so clear about that..
Comment #3
30equals commentedhey jcnventura, thanx for the quick reply!
yes, the TYPE is a placeholder for posting the issue here. i'm using my real node type name for the template.
and i put the template in the directory of my custom theme yes. strangely enough, a couple of hours after i made my post the template for the node types started to catch on. maybe a caching problem, but i cleared the drupal cach several times before. however, now i have a problem with curly quotes pasted in a cck field by a user. i tried the t() function for each field, but that doesn't help. and the charset type already is utf-8...
the part i don't understand about the views thing is, now that i got the pdf template working for a single node, a pdf page of a view with those node types i made a template for, doesn't use those templates.
if you would do this for a normal drupal outputted view, that would work no ? i've made several views before, and whenever i made a template for a node type, the view uses those templates for each node in it's view page.
hope this is clearer now.
Comment #4
jcnventuraThe template system that is used by Views and the rest of Drupal doens't apply directly to this case.. This module actually treats nodes a lot different than non-nodes (and a view is not a node)..
What gets 'printed' when you process a view is what gets output by Drupal.. So, it should be using the template you have setup for 'normal' Drupal page browsing. The way that the system is built is supposed to let you customize the output of the print view (mostly to include/exclude elements and to move things around a bit), but it was never supposed to be a mini-Drupal inside Drupal.
Your cache problem was probably some caching by your proxy or your browser's cache. You should press Shift+F5 to force a refresh to make sure in those cases
As to the quotes, what is the problem exactly?
João
Comment #5
30equals commentedok, i understand now. so i presume it's better for the view to just do a list view, so i can choose the fields and css the output
nonetheless it's a great module
yeah, the caching problem is weird, i clear my browser caching everytime as well. but anyway, it's working now ;)
the quotes problem: when people copy/paste text with quotes from a word .doc file and put it in a cck field, the quotes render as question marks in the pdf.
thanx!
Comment #6
jcnventuraHi,
Regarding the quotes, are you using TCPDF or dompdf? I am guessing you're using dompdf, as that is the one that doesn't support UTF-8. Last night's dev has a patch that converts Unicode to ISO-8859-1 before passing it to dompdf, but that only fixes the 96 extra characters which are supported by that encoding..
I think that the curly quotes are not part of those 96, so you'll probably need to replace them with normal quotes..
João
Comment #7
30equals commentedyes, i'm using dompdf because of the full css support.
pity about the unicode issue.
maybe i can solve it with a custom function which checks for win charachters and replaces them..
thanx for your replies.
Comment #8
jcnventuraComment #10
chrishiggins29 commentedin order to save u time w messy MS WORD single and double quotes - here's a quick'n'dirty fix how to replace them w normal quotes since DomPDF doesn't support UTF-8.
Open print_pdf.pages.inc and add t following function on top of t file AFTER require_once line:
then, search for these lines ...
and add t following call of t function BEFORE them
That's it - this should output normal quotes in t PDF!
Note: I know I shouldn't touch t code of t module - so consider my posting as a "feature request" for t next version ;-)
Hope, that helps.
Comment #11
jcnventuraHi,
The module supports three (3) library-supported methods of converting from UTF-8 to ISO-8859-1 which is at least a bit more supported by dompdf. Then it converts those ISO-8859-1 chars to html entities to force dompdf to accept them when it can't handle the ISO chars.
That's as far as I am willing to go in fixing something that needs to be fixed by dompdf. I am certainly not planning on starting to add arbitrary char replacements. Sorry, but I must draw the line somewhere on what can be fixed on this side and what MUST be fixed on their side.
Thanks for the effort, though.. Maybe this will indeed by helpful to others.
João
Comment #12
_snake_ commentedHi,
I was creating the template (see http://drupal.org/node/826638). And jcnventura you say that it has to be inside the current theme folder. Well, my current theme folder is in /sites/all/themes/[theme_name]
if I use dompdf library (0.5.1) (I don't change the dompdf_config.inc.php, I set 777 permissions on lib/fonts, and I don't installate the fonts (the fonts in /lib/fonts are: Courier, Helvetica and Times)) the following error appears in the log:
Call to undefined function spl_autoload_register() in /srv/www/htdocs/webs/evissa/sites/all/modules/print/print_pdf/print_pdf.pages.inc on line 124
Well, then I change to tcpdf library (5.0.010), and it generates the pdf well, but the template is not used...
Any suggestion?
Thanks
Comment #13
_snake_ commentedWell,
maybe I found the solution...
I click on generate pdf, then it generates the pdf. So the pdf file is open. If I make changes on the template and then I generate the pdf, it shows the prevously version.
So, before you click on generate pdf file, you have to close all pdf files about the node nodes you have, and then click on generate pdf.
Comment #14
jcnventura_snake_: I can't understand if you still have a problem, or not, but please add a new issue instead of re-opening old ones.