I would like to alter the output of the pdf filename. After digging around views_pdf_plugin_display.inc, it seems the output is using the view machine name?

if (empty($path_to_store_pdf)) {
      $path_to_store_pdf = $this->view->name;

How do I reference a field in the view, such as content title, so I can append it to the output? I understand some formatting would be required to make it a valid filename.

I am a novice with PHP, so any help/direction is greatly appreciated!

#9 changing-output-name-1722492-9.patch473 byteskillua99


Version:7.x-1.0-rc1» 7.x-1.x-dev
Component:Code» Miscellaneous
Category:task» support

Ah thanks for changing to the correct category. Can anyone offer any direction? :/

Is there any update on this? I'd like to alter the file name as well. Currently it's using Views' machine name.

Component:Miscellaneous» Code
Category:support» feature

Since clearly this issn't possible currently and the request could be usefull I'm changing this to feature request.

Basically a new setting for "PDF SETTINGS" is requested that makes it possible to set a custom file name, preferable with the support of tokens.

I am interested in this as well.

I found at least one way to alter the PDF filename.

1) Add this to the last "PHP Code After Output" box
$this->view->pdf->Output("YOUR PDF NAME");
This should go at the very end of any code. As far as I can tell, nothing after it will be rendered.

You could change out "YOUR PDF NAME" to something like $this->view->build_info['title'] to use the view title.


2) In views_pdf_plugin_display.inc, change

if (empty($path_to_store_pdf)) {
      $path_to_store_pdf = $this->view->name;

if (empty($path_to_store_pdf)) {
      $path_to_store_pdf = $this->view->build_info['title'];

I haven't tried this second way yet.

Status:Active» Postponed (maintainer needs more info)
Issue tags:+Needs steps to reproduce

Dear fellow Drupal enthusiasts,

I have set this issue to "Postponed (Maintainer needs more information)".

If not already done please add an issue summary and steps how to reproduce the problem.
And please read again, "Making an issue report".

Help about how to do this can be found on IRC and in the user groups.

After there is new information, please re-open the issue by changing the status to active.

This issue was edited with the help of Issue Helper

Status:Postponed (maintainer needs more info)» Active

People just want a way to set the PDF name dynamically.

And this is possible if you change
$path_to_store_pdf = $this->view->name;
$path_to_store_pdf = $this->view->get_title();
in views_pdf_plugin_display.inc

The title can include field placeholders or can be set by contextual filters, which is how people would be able to change the PDF name.

Sorry for not proving a patch but the change is pretty simple to apply and I don't think it will break anything.

Status:Active» Needs review
Issue tags:-Needs steps to reproduce
new473 bytes

This is a feature that can be easily introduced.

Please need reviews this patch, but I did a push into the dev branch.

Works for me

Issue summary:View changes
Status:Needs review» Closed (fixed)