Skip to Content
0
Former Member
Nov 29, 2011 at 10:19 PM

PDF hyperlink export problem, and programmatic hyperlink formula update

321 Views

Crystal Reports XI R2 SP3 .NET

Our application generates reports using the ReportDocument SDK (Load/Export/etc.). The report files (.rpt) are created in-house by our report development team using the CR Designer and they contain database fields, formula fields, and text objects that may have formatting formulas behind them to build special hyperlink URIs that have internal meaning to our application (e.g. providing navigation data to a field in our application). For example, they may define a database field that has a hyperlink formula that takes some other data from the DB and builds out something like custom://name=blah,id=1541654. The idea, then, is that when the end user (customer) views the report from our application, clicking on the hyperlink would take them to a specific data field in our application. We use the "File" CR hyperlink type for this.

Historically, to accomplish this, we exported the reports to HTML and previewed them in a web browser in order to "flatten" the subreports so that all the hyperlinks were accessible without forcing the user to dive into the subreports. This worked well enough but provided a somewhat clunky interface. We are moving to a PDF file format instead, and had planned to pre-process the hyperlink clicks within our own PDF viewer (e.g. intercept the "custom://" ones and route accordingly).

Because of the custom:// URI we've always used for this purpose in the report files, we've already had to add the DisableScriptsInHyperlinks entry to the Registry. Otherwise, the hyperlinks would never have shown up in the HTML we were exporting. However, and I can only assume that its a CR bug, when you export to PDF the only hyperlinks that "survive" are HTTP, HTTPS, and MAILTO (even with that same Registry setting). This obviously presents a huge problem because all those hyperlinks that worked before (HTML) now won't show up when we move to PDF. We're talking about 1000s of reports, and digging through each one to update all the hyperlink formulas to use HTTP:// just isn't going to happen.

So, we decided to attack this bug with a workaround plan that would programmatically update all the custom:// URI schemes with standard http://, right inside the ReportDocument on-the-fly, so that they would export correctly. We would then parse the URI on the client end when the user clicks a hyperlink and intercept it if the format of the link matches our internal format. Otherwise, we'd let it pass through to the user's web browser like normal http hyperlinks would. But I can't find this in the report model anywhere! I thought I was on to something when I ran across this thread: [HyperlinkText Property - Object Model Availability - Foreign Language issue;, but none of my ReportObjects had hyperlink text. So even though I had defined a database field with a hyperlink formula, I couldn't find that in the ReportDocument or ReportClientDocument (RAS) models.

What I really want to do is find those hyperlink formulas in the model somewhere, and change them right after loading the report file so that when the hyperlinks are generated, they have http instead of custom. I already know that I want to change anything that says "custom://" with "http://", but I can't find those definitions anywhere. Technically, I'm willing to do it anywhere prior to the Export call, but I figured doing it right after Load would be easiest.

Actually, I wish the PDF Export didn't remove the hyperlinks in the first place. 😊

Thank you for any guidance you might provide!

Mark