Jump to content
Changes to the Jaspersoft community edition download ×

Dynamic PDF Report w/ Hyperlink

2005 IR Help

Recommended Posts

By: Thomas Leverwitz - tleish

Dynamic PDF Report w/ Hyperlink

2005-02-09 11:01

When I generate a dynamic report with Hyperlinks, it looks and acts perfect when previewing it in the JRViewer. But when I save it to a pdf file, the file size is almost 0KB and when I try to open it in Adobe Acrobat I get the error "Adobe Reader could not open pdf file because it is either not a supported file or because the file has been corrupted"


If I generate the same report "using empty data source" it saves as a PDf just fine, and Acrobat Reader can open the file... but I get none of my dynamic data.


In other words, it seems Hyperlinks only work when you aren't using a datasource. Anybody else experienced this problem, or am I just doing something wrong?


IReport 0.4.0

JasperReports 0.6.1

iText 1.02b





By: Thomas Leverwitz - tleish

RE: Dynamic PDF Report w/ Hyperlink

2005-02-11 08:40

Problem Solved:


Here's the scoop. When creating a LocalAnchor, it appears it must reference an existing anchor in the current report, not necessarily the current pdf file. I'm sure you are thinking "duh!". But it wasn't as obvious as that.


I created a phone directory report with group headings of "A" for above the A names, B above the B names, etc.


I then created a menu of "A, B, C..." as sub report with hyperlinks to all the different group headings to be included at the top of every page for quick navigation of a long report.


This worked fine in the JasperViewer, but wouldn't save properly as a pdf, because the LocalAnchor from the subreport referenced the parent report, not itself, even though the final report was one file.


The solution to get this to work was to use RemoteAnchor instrad of LocalAnchor and reference itself:


INCORRECT: Won't save as pdf


Report Filename: phoneDir.pdf

Hyperlink Type: LocalAnchor

Hyperlink Anchor: "phone_" + $F{alpha}



CORRECT: will save as pdf


Report Filename: phoneDir.pdf

Hyperlink Type: RemoteAnchor

Hyperlink Ref: "./phoneDir.pdf"

Hyperlink Anchor: "phone_" + $F{alpha}

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...