Trouble Loading Hosted PDF

7 posts, 0 answers
  1. Naresh
    Naresh avatar
    31 posts
    Member since:
    Mar 2009

    Posted 29 Nov 2011 Link to this post

    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
  2. Oscar Wahlen
    Oscar Wahlen avatar
    33 posts
    Member since:
    Mar 2010

    Posted 30 Nov 2011 Link to this post

    Have you tried downloading the PDF document with the WebClient and loading the stream instead?
  3. DevCraft banner
  4. Kammen
    Admin
    Kammen avatar
    312 posts

    Posted 30 Nov 2011 Link to this post

    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 >>

  5. Naresh
    Naresh avatar
    31 posts
    Member since:
    Mar 2009

    Posted 30 Nov 2011 Link to this post

    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
  6. Kammen
    Admin
    Kammen avatar
    312 posts

    Posted 05 Dec 2011 Link to this post

    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 >>

  7. Naresh
    Naresh avatar
    31 posts
    Member since:
    Mar 2009

    Posted 05 Dec 2011 Link to this post

    Hello,

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

    Thank you,
    Brian
  8. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 06 Dec 2011 Link to this post

    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 >>

Back to Top
DevCraft banner