Download & Extend

Can Panel pages be sent to PDF for rendering?

Project:Printer, email and PDF versions
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs review

Issue Summary

On a site with extensive use of Panels3, I also have a critical need to print to PDF.

We have a content type=Project, and a Panels treatment of the node. I have placed the PDF link onto the Panels layout, and the link shows up on the final output.

However, the print action is actually using the base node, not the Panel's layout.

Can I get the print action on the Panel level instead?

Using wkhtmltoPDF.

Thanks!

Comments

#1

Status:active» postponed (maintainer needs more info)

Can you provide a URL to the page?

#2

Howdy JCV: thanks for checking...the page is behind a security layer at the moment. It's a normal panel page, and as merlinofchaos notes, panel pages are not nodes.

The Print module can be invoked with printpdf/[nodeID] (only?)

So there seems to be no way to address the current state of the user's screen, which is being rendered though Panels, not through a node.

Have you been able to get a panel page to print with wkhtmltopdf?

Thanks, JB

#3

No, you can also access pages via printpdf/path.

To show links in those pages you need to enable the appropriate setting in the module settings.

#4

Ahhh! That sounds like the go: but where in the settings? I've been through the common settings and the PDF settings. Sorry for being blind, but can you please show me where to change/set this?

Thanks!

#5

Right: never mind...found it!
PDF Settings> Advanced options> Use URL alias instead of node ID

Sorry for the hassle...

FWIW, I started a thread over with the Panels people as well on this point: I'll share this tidbit with them.

Thanks again,

JB

#6

But: we're back.

Yes, even though the option is ticked, and the bottom of the PDF shows that it used the URL and not the node ID, the proble is that it is still feeding off of the *nodes content* vs all the rich relational content I have dragged into the panel page.

The panel page is rendered whenever a node of type x is called.

So the node content is one layer

The Panel pages sits on top and assembles views etc (along with native node content).

What I want is for the user to get the Panel page assembly, not just the node content...and the URL path trick is not doing the trick (sad to report!)

JB

#7

Status:postponed (maintainer needs more info)» closed (fixed)

Just to complete this one...

There's no underlying problem with any of the Print module gear here. The hard fact is that producing a nice PDF version requires hand coding of a specific template.

We opened up our nice Panel page display and went through each content area, creating php calls in the pdf template. If we make changes to the cck/node/view assembly, then these changes have to be separately managed in the PDF template as well.

Closing...

#8

I agree with #6. Printing just node content vs a cobination of views / node content is very different and very important. I want to be able to pdf print a particular set of views.

Is is possible to print a particular set of views related to a node with the module as it stands now? Considering trying it out, but if it can print a certain type of views, wont do me any good.

Any suggestions?

#9

@whatmetropolis: as I understand it, thesystem works as follows...

1. The prin module takes the url (with node value) and has a quick look for any custom print stylesheets that might exist *for the target node type*.

So if you're printing a node of type = media_release, Print will look for a media_release-print.tpl.php (or something close to that)

2. This template can carry whatever php you wish to include...which means you can call whatever views with whatever parameters you're able to code for.

So on the one hand it's a manual coding job, buit on the other you get to do whatever you like...

A themer is probably the person you need. Someone to connect the views with the print tpl.

HTH.

#10

The Print/PDF module is great, but like others before me I've hit this same problem.
From my own experiments, it appears that the module is quite happy to render the output of a regular Panels page with a dedicated url path, it's just when using a Panel node that the Print module 'chooses' to use the raw node instead of waiting until Panels has done its stuff.

I'm going to dig into the code a bit, but in principle it seems that the Print module is quite capable of rendering the Panel node output but maybe needs a switch to tell it to do this instead of the raw node. Everyone on this thread would probably say it should default to taking the output from Panels, just as you see in the browser, but if a switch is needed it could be in the print settings or even per content type.

Andy

#11

Yes, indeed! There may be subtleties I'm not yet aware of, but looking at print_controller() in print.pages.inc, the code has 3 options to process the page: _print_generate_node(), _print_generate_book() and _print_generate_path(). The current logic gives the simple node generation priority, then book (not sure how that differs) and finally path is treated like a poor-man's fallback. A quick hack to make _print_generate_path() the first choice happily created print and PDF versions of a Panels node page.

So it's just a case of refining this logic with some admin settings...

Andy

#12

Status:closed (fixed)» active

Having re-opened this issue, I've re-linked and highlighted this update on the duplicate issue #890596: How to print Panels output?.

As previously stated, it's simple to patch the print_controller() function to use the Panels output for nodes, but I wanted to get some input on reqs/spec before suggesting a specific patch. When should the print module take Panels output rather than node-specific output?

What additional admin setting might be required according to your use-cases?

#13

I wrote a patch, that implements panels support.
It's only a few lines long.
I think it's better, not to change the logic of the print_controller(). The patch has only a impact, if panels is installed.

AttachmentSize
panel_support_print_printpdf_1.12.patch 957 bytes

#14

Hi guys...as the issue originator 1.5 years ago (!) it's great to see the new thinking here...especially appreciate andy_read and ayalon grabbing the issue by both ends and having a go.

I'm a non coder: it looks to me like there is the stub of an idea offered by the existing option to: PDF Settings> Advanced options> Use URL alias instead of node ID

Isn't this the "switch" point needed? The problem (back in 2009) was that despite using this option we still got the raw node.

If the #13 patch forces PrintPDF to use the URL alias (ie, the final rendered page) that means there's no need for additional interface/management work. Just add a comment to the Use URL option noting the effect of providing a solution for Panels (and other rendered elements).

#15

Patch in #13 works well. I had been using custom .tpl files (i.e. print_pdf.node-MY_CONTENT_TYPE.tpl.php) but the patch defaults to the print.tpl.php. Anyone know if there is a way to override this and create custom tpl files?

#16

Can someone adapt this patch to print_mail.inc file so that it works with send mail and not just print?

#17

#13 also seems to work for d7 except that the check on the page callback should be for 'page_manager_node_view_page' (line 95).

#18

Status:active» needs review

#19

I have put this patch in place and see no difference. I have a panel with a node displayed and a view at the bottom. I really need the PDF & Print & Email to include the view at the bottom....Help I am new to this so I am hoping I put it in the right spot in the file.

#20

It can be easily achieved by having no hacks using print.node-type.tpl.php

Just follow the steps mentioned below

1.copy print.node-type.tpl.php into theme
2.Create a function as follows in template.php

<?php
function get_panel_view(&$node) {
   
// Load my task plugin
   
$task = page_manager_get_task('node_view');
   

   
// Load the node into a context.
   
ctools_include('context');
   
ctools_include('context-task-handler');
   
$contexts = ctools_context_handler_get_task_contexts($task, '', array($node));
   
   
$output = ctools_context_handler_render($task, '', $contexts, array($node->nid), false);
    if (
$output !== FALSE) {
        return
$output['content'];
    }
   
// Otherwise, fall back.
   
return node_view($node);
}
?>

3.In print.node-type.tpl.php replace

<?php
print $print['content']
?>
into
<?php
print get_panel_view($print['node']);
?>

4.Rebuild theme cache

5.You are done

#21

dhayalan_ms. thank you very much! you made my day!

#20 works perfect for print page. I will try it for pdf and e-mail also and let you know.

nobody click here