This is a migrated thread and some comments may be shown as answers.

Problems creating the Relative Path for the Telerik.Reporting.NavigateToUrlAction() for a Picture Box on a Report

6 Answers 624 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Tom Howe
Top achievements
Rank 1
Tom Howe asked on 16 Jul 2014, 05:37 PM
I have a report that I've created that is consumed by a Windows Form application that displays the report, and then exports the report to PDF and Microsoft Word.  

In one section of the report, I am using the PictureBox control to load the thumbnail image, and this works fine.  I also want the users to be able to drill down or click on the image and have it launch the actual image. 

My directory structure looks like this

C:\Reports                                               ---Main Report Directory
C:\Reports\0001                                      ---Client Directory
C:\Reports\0001\0002                             ---Project Directory
C:\Reports\0001\0002\Report                 ---Actual directory where the PDF / Word document versions of the reports are exported too.
C:\Reports\0001\0002\Report\Thumbs   ---Directory where the thumbnail sized images are stored.
C:\Reports\0001\0002\Report\Images    ---Directory where the full sized images are stored.

So, my code exports the PDF / Word documents to the directory named C:\Reports\0001\0002\Report

If I code my Action up like this, using a physical path, everything works fine:

            Dim strDrillDownURL As String = "file:///C:/Reports/0001/0002/Report/Images/12345.jpg"

            Dim UrlAction1 As New Telerik.Reporting.NavigateToUrlAction()
            UrlAction1.Target = UrlTarget.NewWindow
            UrlAction1.Url = strDrillDownURL

            Me.imgThumbNail.Value = "C:\Reports\0001\0002\Report/Thumbs\12345.jpg"
            Me.imgThumbNail.Action = UrlAction1

When the user opens the PDF or the Word Document and clicks on the thumbnail image associated with the picture, a new window pops open with the full sized image.

However, in my situation, I will need to copy this report directory to a thumb drive and send it to my client.  With this in mind, I want to be able to change the drill down action to use a relative path so that if this thumbnail drive becomes their E: drive, they will still be able to click through to the full sized images.

With this in mind, I've tried many variations of the file:/// relative path implementation, but have yet to find one that works.  My current rendition looks something like this:

            Dim strDrillDownURL As String = "file:///./Images/12345.jpg"

            Dim UrlAction1 As New Telerik.Reporting.NavigateToUrlAction()
            UrlAction1.Target = UrlTarget.NewWindow
            UrlAction1.Url = strDrillDownURL

            Me.imgThumbNail.Value = "C:\Reports\0001\0002\Report/Thumbs\12345.jpg"
            Me.imgThumbNail.Action = UrlAction1

I've spent many hours on Google to try to determine what the proper syntax to use for my drill down URL.  I've come close, in many cases, but I must I am at a loss here.

Does anyone have any suggestions?

Thanks.

6 Answers, 1 is accepted

Sort by
0
Hinata
Top achievements
Rank 1
answered on 21 Jul 2014, 09:31 AM
Hi Tom,

I'm not sure relative and absolute URI formats depend on the Reporting product at all. You can check the explanation here: http://stackoverflow.com/questions/7857416/file-uri-scheme-and-relative-files
0
Tom Howe
Top achievements
Rank 1
answered on 13 Aug 2014, 05:48 PM
Thank you for your input.  At the time I posted this, I was unsure of how the URL should look, but had already reviewed that article.

At this point, I'm confident that I know what the URL needs to look like in the Word document.  Ultimately, my hyperlink in word needs to be prefixed with "file://media/", and if it does, Word will look into the relative path for the media directory.  However, when Telerik exports the URL to Word, it transforms it into something unusable.

To get around the problem, I've temporarily come up with a workable solution.

First, I generate the hyperlink in the word document with code behind the report that looks like this:  (not the complete code, but the relevant code):

                Dim strURL As String = Replace(strValue08, "<a href='../media/", "")
                Dim strDrillDownURL As String = Replace("file:///media/" & Mid(strURL, 1, InStr(strURL, "'") - 1), "\", "/")
                Dim strLabel As String = strURL

                If System.IO.File.Exists(strMediaFilePath & "Media/" & Mid(strURL, 1, InStr(strURL, "'") - 1)) Then
                    txt08.Style.Color = Color.Blue
                    txt08.Style.Font.Underline = True

                    Dim UrlAction1 As New Telerik.Reporting.NavigateToUrlAction()
                    UrlAction1.Url = strDrillDownURL
                    UrlAction1.Target = UrlTarget.NewWindow
                    Me.txtValue08.Action = UrlAction1
                    txt08.Value = strLabel

                End If
                txt08.Value = strValue08

As you can see, I've generated the URL with a "file:///media/" prefix.  I want to generate it with a "file://media/" prefix, but if I do, the resulting hyperlinks in word won't be correct.

After I generate the Word Document exporting it from the report, I clean it up in word using Microsoft Interop with code like this:

            Dim oWord As Word.Application
            oWord = CType(CreateObject("Word.Application"), Word.Application)
            oWord.Visible = False

            blnOriginalPagination = oWord.Options.Pagination
            oWord.Options.Pagination = False
            oWord.Options.AllowOpenInDraftView = True
            oWord.Options.CheckGrammarAsYouType = False
            oWord.Options.CheckGrammarWithSpelling = False
            oWord.Options.CheckSpellingAsYouType = False
            oWord.ScreenUpdating = False

            Dim oDoc As Word.Document
            Dim oHype As Word.Hyperlink

            oDoc = oWord.Documents.Open(CType(filePath, Object))

            For Each oHype In oDoc.Hyperlinks
                If InStr(oHype.Address, "\media") > 0 Then
                    oHype.Address = Replace(oHype.Address, "\media", "media")
                End If
            Next
            oWord.Documents.Save()
            oWord.Documents.Close()
            oWord.Options.Pagination = blnOriginalPagination
            oHype = Nothing
            oDoc = Nothing
            oWord.Quit()
            oWord = Nothing

While this is extremely inefficient, it at least works.

If someone had the knowledge to tell me that if I want a URL prefix of "file://media/"  for all my media files in my resulting Word document, that I needed to generate my URL in the report as XXXXXX, that would help remove this inefficiency.  I'm just not sure what person would have that knowledge.  Or, it may simply be a bug in the Telerik Reporting export feature.

I also have to use the Microsoft Interop create all my bookmarks in the Microsoft Word document, because the Telerik export doesn't seem to support exporting the Document map as bookmarks in Word or to the PDF.

0
Nasko
Telerik team
answered on 18 Aug 2014, 11:17 AM
Hello Tom,

By default the hyperlinks are generated/configured by MS Word as shown in this screenshot. With that in mind you will need to specify the same URI in the report action Target URL: screenshot.
With the configuration shown above the URL actions will work correctly inside the exported DOC/DOCX file.

Regards,
Nasko
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Tom Howe
Top achievements
Rank 1
answered on 11 May 2015, 02:59 PM
This screen snapshots you provided apply to absolute paths; not relative paths.
0
Tom Howe
Top achievements
Rank 1
answered on 11 May 2015, 03:03 PM

This is definitely a bug in the Telerik reports product, and how it renders and creates PDF's and Word documents. 

 At first, I thought maybe it was a problem with the Action object, so I decided to just use HTML Text Boxes and render the relative hyperlinks as part of the report using the HTML Text Boxes.  I know for sure that my relative URL needs to be prefixed with "file://" in order to get the desired relative path effect in PDF and Word documents.  However, if I use that prefix, the hyperlinks are transformed as unusable.  So, instead, I have render the URL's with a prefix of "file:///" and then use a process after the fact to replace the "file:///" prefix with "file://" after the fact.  This makes the relative path URL's useable.

I don't know the process I need to go through to formally report this as a bug.

0
Nasko
Telerik team
answered on 14 May 2015, 07:02 AM
Hello Tom,

To submit a bug report you need to log into your Telerik account and post a new support ticket. Then from the support ticket types select Bug Report. When submitting a bug report, please describe the issue thoroughly and provide runnable samples and steps to reproduce the issue.

Regards,
Nasko
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Tom Howe
Top achievements
Rank 1
Answers by
Hinata
Top achievements
Rank 1
Tom Howe
Top achievements
Rank 1
Nasko
Telerik team
Share this question
or