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

Trouble Loading Hosted PDF

6 Answers 104 Views
PDFViewer
This is a migrated thread and some comments may be shown as answers.
Naresh
Top achievements
Rank 1
Naresh asked on 29 Nov 2011, 05:56 PM
Hello,

I'm trying to load a PDF that is hosted on a remote server. The clientaccesspolicy.xml looks like this:

<?xml version="1.0" encoding="utf-8" ?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="*"> 
<domain uri="http://*"/>
<domain uri="https://*" /> 
</allow-from>
<grant-to>
<resource include-subpaths="true" path="/"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>

My code looks like this:

pdfViewer.DocumentSource = new PdfDocumentSource(new Uri("http://server_name/vir_dir_name/Test.pdf", System.UriKind.Absolute));

When the PDFViewer control loads it does nothing - no "Loading" message, no error message. If I point my browser to this PDF it loads fine. If I use the PDFViewer control to load it locally off of my hard
drive (using the open file dialog built into the control) it loads fine.

If I point to this same PDF on my local box (using http://localhost:port#/Test.pdf) I receive an "object null reference"
error message (no stack trace, no inner exception). 

Any suggestions of what I may be doing wrong would be greatly appreciated.

Thanks,
Brian

6 Answers, 1 is accepted

Sort by
0
Oscar Wahlen
Top achievements
Rank 1
answered on 30 Nov 2011, 09:52 AM
Have you tried downloading the PDF document with the WebClient and loading the stream instead?
0
Kammen
Telerik team
answered on 30 Nov 2011, 06:21 PM
Hi Brian,

As Oscar Wahlen has written (thanks Oscar), you should try to download the file with WebClient. Please also make sure the Uri is correct. If the problem persists, we will need more details about this problem in order to be more specific in our answer.

Greetings,
Kammen
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Naresh
Top achievements
Rank 1
answered on 30 Nov 2011, 09:15 PM
UPDATE: If I put the PDFViewer control on the first tab it works - the PDF is displayed properly. The error only occurs when the PDFViewer is on the 2nd, 3rd, etc. tabs. If I do not set the document source the error does not occur and the PDFViewer control is displayed on the 2nd tab.

Hi Kammen,

I just switched my code over to using WebClient to get a stream. I am successfully receiving the stream (verified with Fiddler and by inspecting e.Result - see below).

void client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {            
            pdfViewer.DocumentSource = new PdfDocumentSource(e.Result);
        } 

I do not receive an error on this line: pdfViewer.DocumentSource = new PdfDocumentSource(e.Result);. However, when I navigate to the viewer (PDFViewer is in a RadTab control), I receive the following error:

Message = "Object reference not set to an instance of an object."

This is the same exact behavior I was experience before when I hosted the PDF locally (to eliminate cross-domain issues). As I stated before, I can open this same exact PDF if I use the file open dialog. 

Any ideas?

Thank you,
Brian
0
Kammen
Telerik team
answered on 05 Dec 2011, 09:25 AM
Hello Brian,
We were unable to reproduce the problem you are facing. Can you send us (through a support ticket) a sample application demonstrating the issue, so we can investigate it further?

Greetings,
Kammen
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Naresh
Top achievements
Rank 1
answered on 05 Dec 2011, 04:41 PM
Hello,

I just submitted a sample app that reproduces the issue. The ticket # is: 489689.

Thank you,
Brian
0
Iva Toteva
Telerik team
answered on 06 Dec 2011, 10:08 AM
Hi Brian,

Thank you for providing a sample application reproducing the issue.
We will address your question in the support ticket you opened.

Best wishes,
Iva Toteva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
PDFViewer
Asked by
Naresh
Top achievements
Rank 1
Answers by
Oscar Wahlen
Top achievements
Rank 1
Kammen
Telerik team
Naresh
Top achievements
Rank 1
Iva Toteva
Telerik team
Share this question
or