Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Print to pdf: insert pagebreaks
rklerck
Hi,<br />
<br />
I'm building a report which has a different layout in PDF than HTML. I've inserted a script which sets the 'Column page break interval' for my crosstabs. The script is run in the beforeRender of the report. This all works fine when I run my report in the webviewer or run it as PDF. The only big problem is printing as PDF IN the webviewer. Should I place this script somewhere else? It looks like the beforeRender isn't called when printing as PDF..?<br />
<br />
This is the script, placed in beforeRender:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
format = reportContext.getOutputFormat();
if(format == "pdf"){
reportContext.getReportRunnable().designHandle.getDesignHandle().findElement("crosstab1").setProperty("pageBreakAfter","Always");
reportContext.getReportRunnable().designHandle.getDesignHandle().findElement("crosstab1").setProperty("columnPageBreakInterval",9);
reportContext.getReportRunnable().designHandle.getDesignHandle().findElement("crosstab2").setProperty("columnPageBreakInterval",9);
}
</pre>
<br />
<br />
Hope someone can help. Thanks in advance!
Find more posts tagged with
Comments
mwilliams
So, when you run directly to PDF, it works, but if you run in the web viewer, then export to PDF, it doesn't? Is this the issue? Let me know! Also, let me know your BIRT version! Thanks!
rklerck
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="84859" data-time="1320345189" data-date="03 November 2011 - 11:33 AM"><p>
So, when you run directly to PDF, it works, but if you run in the web viewer, then export to PDF, it doesn't? Is this the issue? Let me know! Also, let me know your BIRT version! Thanks!<br /></p></blockquote>
<br />
Thanks for your reply!. Yes, this exactly is my problem! My birt version is 2.6.1.
rklerck
<blockquote class='ipsBlockquote' data-author="'rklerck'" data-cid="84879" data-time="1320395351" data-date="04 November 2011 - 01:29 AM"><p>
Thanks for your reply!. Yes, this exactly is my problem! My birt version is 2.6.1.<br /></p></blockquote>
<br />
Anyone..?
mwilliams
Sorry for the delay. I was out part of last week for a conference. I remember seeing this issue. That when you exported from the viewer, the exported pdf had the same layout as the web viewer. I believe this was because of some changes that were being made to make page breaking in PDF better. I am not sure if this was just something that happened in the designer, however. Have you tried deploying this and calling the report with the url parameter format=pdf in the URL? Maybe the same issue will not happen except in the designer. Let me know. I'll also test myself. I don't believe this same issue happens in the newest version, btw.
mwilliams
Ok. This does still happen in the deployment in 2.6.1 and also, still in 3.7.0. A workaround could be to remove the export button from the viewer and just put a label with a hyperlink in your report that says "Export to PDF" and call your url with run instead of frameset. This should get you the output you're wanting from this.
rklerck
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="85279" data-time="1321292949" data-date="14 November 2011 - 10:49 AM"><p>
Ok. This does still happen in the deployment in 2.6.1 and also, still in 3.7.0. A workaround could be to remove the export button from the viewer and just put a label with a hyperlink in your report that says "Export to PDF" and call your url with run instead of frameset. This should get you the output you're wanting from this.<br /></p></blockquote>
<br />
Never mind my reply.<br />
<br />
Now I only want to know how I can make all this dynamically. We have multiple environments and it should work on each one off course. Therefore, I'm not quite sure how my url should look like.
mwilliams
A typical URL is like:
http://yourHostServerAddress/birtViewer/runOption?__report=yourDesign.rptdesign
The runOptions are preview, run, and frameset.
So, you'd want to use something like:
http://yourHostServerAddress/birtViewer/run?__report=yourDesign.rptdesign&__format=pdf
Hope this helps!
Viewer usage info:
http://www.eclipse.org/birt/phoenix/deploy/viewerUsage.php