Printing multiple selected records as PDFs

PaulT

Member
I am wondering if I can filter a List view to the records I want and then print those records as PDFs in their details view layout, each details view printing as a separate PDF?

I tried to do what was posted on http://fabrikar.com/forums/index.php?threads/printing-selected-records.16106/ but this didn't work. (That post is from 2010 so maybe too old).

The idea is to Print all that weeks Timesheets for a weekending in one go. Each Timesheet is to be laid out as it is in it's details view. So one timesheet may take up 3 pages then Page 4 would be the start of the second timesheet and so on. That way each page of a timesheet can be stapled together and be separate from the next timesheet but all the timsheets get printed in one print job.
 
I just found that the Download List plugin set to PDF's may do what I am wanting. I tried this but just got blank PDF's when I download the zip file (It had the right number of separate pdf's but they just didn't have any content when opened). If I go back to the site and open one of the records in details view and press the PDF button it downloads a PDF for that record, it does contain content (it is set to bootstrap but doesn't seem to be applying any formatting, the fields just appear in one column, one above the other, not horizontally as displayed in the details view.)

So there is 2 issues:
  1. Download zip produces blank PDF's
  2. Details view PDF doesn't load bootstrap styling
 
Last edited:
Do you have ACLs on your details view, i.e. with the "View Records" setting under the list's Access controls?

The problem with the download list plugin's PDF feature is that it gets the PDF views by the plugin code on the server making CURL calls to itself (localhost). Which doesn't have the authentication credentials that the browser has. So it's basically a 'guest'.

I've been thinking about adding an access control feature to allow localhost access to work round this.

Meanwhile, try experimenting, if you do have 'view records' access control, try setting that to Public and see if the PDF's get created.

Note that PDF creation is a very time and resource heavy operation, so trying to do it for a lot of rows at once can take quite a while.

-- hugh
 
Yes I did have ACL on the details view and I have set it to Public and now the PDF content is getting generated. However it doesn't load any formatting. The PDF template in List Details Layout is set to Bootstrap.
 
I suspect it is, but other limitations of DOMPDF are making it look fugly.

Try enabling PDF debug (global Fabrik options, debug tab), which sends the output to the browser rather than running it through DOMPDF, and look at the source of the page.

-- hugh
 
I already tried it with PDF debug on but there is no sign of bootstrap being loaded. I checked in Chrome inspect and couldn't see any bootstrap being loaded.
I created a custom template which is a duplicate of the Bootstrap Template and called it custom1. This is placed in components/com_fabrik/views/details/tmpl/custom1. I was able to set the Forms Layout Details view Template to custom1 and the PDF Template to custom1 and then I placed some css in custom1
#$form {
background-color: blue;
}
This blue background showed up in the HTML details view and also other bootstrap styling. When I clicked the PDF button (in PDF debug mode) the blue background did appear but no bootstrap styling at all.
At least I know I can do some formatting but it would be good to get the Bootstrap showing up or some hint of it.
 
Last edited:
Not sure what to tell you. If you've applied that change, you should now have the bootstrap CSS being loaded:

pdf_bs.png

The PDF output won't look like that, for a variety of reasons to do with the DOMPDF library, but the CSS should be there.

-- hugh
 
I am just wondering where bootstrap is getting loaded from for the PDF rendering. Normally the bootstrap is loaded by the Joomla Template but when printing details view PDF it only loads the contentpane so the Joomla template isn't there. May be I don't have the bootstrap required to load? Just trying to think of any possibilities.

Actually the more I mess around with this I realise I will be better off if I just dump the bootstrap idea and just custom style it.

I have now done that and it has come out really good!
 
Last edited:
The problem with the download list plugin's PDF feature is that it gets the PDF views by the plugin code on the server making CURL calls to itself (localhost). Which doesn't have the authentication credentials that the browser has. So it's basically a 'guest'.

I've been thinking about adding an access control feature to allow localhost access to work round this.

So this means the only way I can get the element to print on PDF via this download list plugin is for it to be publicly accessible? If you added the access control would that mean I could set elements to Administrator and they would still print on the PDF download but only be accessible on screen by Administrator users.? If that is the case what would need to happen for you to add this feature in a short period of time (like one or 2 weeks)?
 
Individual element ACL's will behave normally. Basically, you'll see whatever you would see if you load a details view on the front end as a guest. The PDF's are being rendered by the server, "pretending" to be a browser, doing a file_get_contents() on the details URL. Which doesn't have the authentication credentials of the actual browser session, so is treated as a guest.

This is a sub-optimal solution, but is the only realistic way of providing the multiple PDF download feature, given the way J!'s model / view / controller (MVC) methodology works. It's very difficult (bordering on impossible) when in one view (list) to run other views (details). So I cheat by doing the "make CURL calls to the web server to get the PDF views" thing, so the PDF views are built in an entirely separate instance of J!.

-- hugh
 
The only problem I have is I want to print off timesheets which contain pay rates and customer details and so I don't want any chance of this being publicly accessible even though it might be only a slim chance that anyone would actually access it. The whole site is only accessible if you are registered or above and the PDFs I actually want to be set to Administrator level. At the moment I would have to set the elements to public for them to print as PDFs via download plugin.
You said you might be able to make it possible to set access controls on this feature, I would like to know if it is possible to get this feature within 2 weeks? Would I need to pay for it as a custom job and if so how much would that be?
 
Yes, that would have to be done as custom work. I just took a look at what is involved, and it's about 1.5 hours work, about evenly split between coding / documenting, and testing.

I'll get @mediaateam to discuss it with you.

-- hugh
 
Just to keep this one up to date ... as I believe Robbie let you know, I committed the changes to allow localhost to bypass "can view" ACLs when creating a PDF view in this commit:

https://github.com/Fabrik/fabrik/commit/4af0f95db1bdab47a0622aa4383983366544733f

(and the one after it where I removed some debug code).

So if you do a full github update (see wiki), and set the new global list config setting "Allow PDF localhost" to Yes, you should be able to keep your list ACL's set to prevent guest access to normal front end details view, and be able to use the download plugin to generate multiple PDFs.

-- hugh
 
Hi Hugh,
I have installed that full github update and set "Allow PDF localhost" in the Global settings but it isn't working, it still only allows content to show when the list access and individual elements are set to Public on details view.
The other unfortunate thing is the change you made to the PDFs to add the Bootstrap is now actually working (where is wasn't before) and is overriding the custom styling I created. So I commented that line out of components/com_fabrik/views/form/view.pdf.php for now and that stops the bootstrap from loading. (Yes I know I originally asked for that but because it wasn't working I created my own custom css which was much better).
The thing that is strange to me is that bootstrap commit you added last week didn't work, now I have done a full Github update it is working but your new ACL stuff doesn't work? That sounds like some sort of caching issue? however when I switch the ACL to Public (it works immediately) and if I switch to Registered (it stops working immediately), caching doesn't seem to interfere with that. I have caching switched off in Joomla Global configuration. Do you have any other ideas of why it isn't working for me?
 
Last edited:
I have installed that full github update and set "Allow PDF localhost" in the Global settings but it only allows content to show when the list access and individual elements are set to Public on details view.

Does it render the view at all, just without elements with ACLs? I didn't add anything to the element access, although I think I could easily apply the same logic to those.

-- hugh
 
If you add ACL to the list access, it creates the zip file, when you download and decompress that it has the selected pdfs in it, in this case I selected 4 items and there where 4 pdfs. Each PDF has a file size of 1KB and the pages are blank.
With regards to having ACL on the elements themself, I think that would be better as it ensures better security and flexibility.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top