sgolestane Posted November 10, 2008 Share Posted November 10, 2008 I generate reports in HTML and PDF, there are some hyperlinks in the report which i want to render only in HTML and not in PDF.Is there any way that based on format, render or not render hyperlinks?Thanks! Link to comment Share on other sites More sharing options...
Teodor Danciu Posted November 12, 2008 Share Posted November 12, 2008 Hi,There are two ways to achieve this:1) Duplicate the elements that have hyperlinks and make one copy with and the other without hyperlinks, one on top of the other. Make sure you mark these elements with different keys (key attribute): "hyper" and "nohyper", for example. Then, when you export them to HTML and PDF, make use of a key-based element filter to filter out hyper or nohyper elements from the generated output.See the ElementKeyExporterFilter class and the JRExporterParameter.FILTER exporter parameter for more details.2) Use custom hyperlink support in JR. You invent a new type of hyperlink, let's say "MyHyperlink". This type of hyperlink of yours has some parameters that you define yourself (at a minimun, this hyperlink could have only one parameter, which is the entire target URL itself). Then, you create custom hyperlink handlers for both the HTML and the PDF exporter, to deal with this type of hyperlink of yours. In HTML, you will produce normal hyperlinks, while in PDF, your handler will ignore those hyperlinks and not create them.For more details about custom hyperlinks, see the Javadocs starting here:http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/export/JRHyperlinkProducer.htmlI hope this helps.Teodor Link to comment Share on other sites More sharing options...
sgolestane Posted November 13, 2008 Author Share Posted November 13, 2008 Thanks Teodor,This how I addressed this requirement. As we don't want to have any hypelink in PDF exports, i extended JRPdfExporter and overloaded setHyperlinkInfo with a method with and empty body. Code:public class JRPdfExporterWithoutHyperlinks extends JRPdfExporter{ @Override protected void setHyperlinkInfo(Chunk chunk, JRPrintHyperlink link) { //do nothing, we don't want Hyperlinks in pdf }} Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now