Tableau has been designed for, and is best at, creating data visualisations and interactive dashboards; however, sometimes as Tableau developers we must swallow our pride because of client request, acquiesce, and put together workbooks which aren't necessarily so visual or interactive and feature some of the 'no-no's of Tableau development, like:
- Printing
- Report bursting
- Data export (as a primary function)
- Complex cross-tab filled financial reports
Alan Eldrige described these activities extremely well in his whitepaper 'Designing Efficient Workbooks' and in particular - why you should avoid them; so I won't get into that detail now. I will however explore one of these activities: printing, and specifically one aspect of printing-related activities - PDF generation.
During a project I've been working on for the last couple of months, I have been asked to create a workbook which can easily be converted to a PDF for distribution and archive. Of course I explained my hesitation but proceeded to put together a design that would be just as clean and clear, evenly laid-out and generally well-presented on screen in Tableau Server as it is as a PDF document and therefore also, when printed.
I stumbled across a few issues during this process but thankfully found fixes, or at least - workarounds, for each.
War on Error
Firstly, it just didn't work.
I could neither find any posts on the Tableau Support Community nor could I find any other references to this error, let alone fixes, anywhere else on the Web. I wasn't particularly surprised, though, since I have been aware for some time that this is not a core function for Tableau, it is not something that is discussed very often on the forums or blogs, and it's a feature that receives little development priority.
I figured that the resources required to render the PDF pages exceeded the allowance provided by Tableau Server so I tried generating one using a workbook with some of the views deleted and indeed, it worked. This wasn't quite acceptable, though, so rather than exporting to PDF from the workbook hosted on our Tableau Server, I tried Print to PDF from the File menu within Tableau Desktop to create a PDF of the whole workbook and - voilĂ - it worked!
So for this issue, the takeaway is that Tableau Desktop is more capable than Tableau Server to render PDFs - especially if your workbook is large and/or complex.
Update - 29 February 2016
I just stumbled across this interesting note as I was browsing through recent Tableau release update details.
The version of Tableau Server in operation at my workplace is 9.0.4.
The release notes for 9.0.8 include the following:
In Tableau Server, attempting to export a workbook that contained story points to PDF sometimes failed to produce a PDF.
This suggests that there was a known problem in versions prior to 9.0.8 that has since been resolved; therefore, when we next upgrade our installation of Tableau Server, the “Error Producing PDF” message will no longer be seen!
Lost in Space
Next, I opened up this PDF... and saw this:
The problem here is not the blurriness - I did that intentionally for the blog post. The problem is the layers of text that have been stacked on top of each other on the top left below the story point navigation and the vast expanse of white space on the page. That was not supposed to be there. There was a whole lot of stuff that was supposed to be there.
So this was quite disheartening. I was stuck. Much of my workbook had DISAPPEARED! Well, not really. The PDF pages had not rendered correctly - and when I said this to myself a few times, I started on a line of thinking that brought me towards a successful outcome.
The PDF pages had not rendered correctly
pages had not rendered correctly
not rendered correctly
*rendered*
Okay, so I figured that there was an issue with the rendering! Of course, I'm well aware that many of the error messages that we see when we're waiting for our views whether in Desktop or Server are somewhat rendering-related. I don't know the mechanics but I guess that the PDF-generation engine struggled to take the design from Tableau Desktop and then render it into a PDF.
From here I thought that maybe there should be one step taken out of the process .. so I tried to reduce the load on the PDF generation engine and ensure that the bulk of the rendering was taking place in Tableau Desktop. To do this, the only path I could think of was to click through every view, from the first to the second to the third to the 28th in this case, and then once Tableau Desktop had cached the views, then try the the PDF-generation process again.... and you betcha - success!
I Just Want To Fit In
Lastly, once I managed to see all the content rendered on every page of the PDF, I was disappointed to see that the content did not fit the page.
It seemed as though I had chosen unsuitable dimensions for my layout so I built a dashboard that was much wider and much taller with varying sized layout containers inside. I figured that I would be able to identify where the PDF cut off the right side and the bottom of my dashboard and that I could determine exactly what the ideal dimensions were.
So that didn't quite go to plan - it rendered the whole thing rather than cutting off the edges. This suggests to me that there is no ideal height and width. Your entire view will always be rendered when you generate a PDF. The trick is to get the same aspect ratio as an your page. In my case, I was using A4 which is 210mm x 297mm which approximately equals a height/length ratio 1:1.41.
I adjusted my view accordingly but found that this still left a wider right margin than the left margin. After a bit more investigation, I came across the ideal ratio which allowed for the 11mm margins that the PDF generation process applies which was 1:1.47 being a width of 1365 and a height of 927.
If you wish to produce a PDF for a different page size, eg letter, you will need to adjust the ratio accordingly which may involve a little trial and error but essentially all you need to keep in mind is that there will be a fixed margin size and within that boundary your Tableau view needs to match the aspect ratio that remains.
As always, if you have any questions or any thoughts on how to better solve these problems, please feel free to add a comment below.
If you wish to produce a PDF for a different page size, eg letter, you will need to adjust the ratio accordingly which may involve a little trial and error but essentially all you need to keep in mind is that there will be a fixed margin size and within that boundary your Tableau view needs to match the aspect ratio that remains.
As always, if you have any questions or any thoughts on how to better solve these problems, please feel free to add a comment below.
I have had similar issues only taken a step further to create a batch process to produce 100s of PDFs and switching parameters for each one and saving with a different file name.
ReplyDeleteThis is the first blog post I ave come across on this subject.
I usually have my team build for Letter Landscape with a .2 Margin in the Print Setup Options. This seems to work rather well but I haven't looked to see how 'exact' it comes out.
ReplyDeleteOur partner team in Data Engineering has also built a web-based interface that allows any user to then create a bursted report using those PDF links. You can have one page for example that allows a filter by region. Then assemble all of those individual pages into a single PDF that can be automatically emailed daily, weekly or monthly at a specified time. It is really cool stuff since it helps with Offline access.
Using Tableau is awesome on your phone, but not when you are stuck on a train with poor wifi access and going through corporate VPN.