We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

PDF Viewer Not Displaying Documents?

Thread ID:

Created:

Updated:

Platform:

Replies:

126377 Oct 11,2016 08:44 PM Oct 13,2016 08:44 AM Xamarin.Forms 3
loading
Tags: PdfViewer
Adeem
Asked On October 11, 2016 08:44 PM

I'm having trouble getting the new SfPdfViewer to work properly. When looking at the component documentation for other platforms (none exist for Xamarin at the moment), it says to create a "PdfLoadedDocument" from a Stream and use it as the arg in LoadDocument(). However, LoadDocument() only accepts Stream as an argument type, so I tried the stream from GetManifestResourceStream() of an embeded resource, but nothing is popping up. I tried multiple PDFs and made sure to set the Content of ContentPage to the created PdfViewerControl with no luck. No syntax errors appear and I can see at runtime the PdfViewerControl accepts the stream, but it doesn't seem to parse it and get page numbers, etc. Any ideas?

Balasubramanian Sundararajan [Syncfusion]
Replied On October 12, 2016 10:23 AM

Hi Adeem,  

Thanks you for using Syncfusion product. 

We have created a simple sample which loads and display the PDF document in our PDF viewer Xamarin Forms (iOS/Android). Please find the sample from the following link, 



XAML Design: 

Please find the xaml design page which describes adding the PDF viewer control to a Grid. 

 
<Grid >    
    <sfpdfviewer:PdfViewerControl x:Name="pdfViewerControl"/> 
</Grid> 



C# Code: 

The below code example is for loading the PDF document in the PDF viewer control. 

 
protected override void OnAppearing() 
{ 
 
     base.OnAppearing(); 
 
     var fileStream = typeof(App).GetTypeInfo().Assembly. 
            GetManifestResourceStream("GettingStarted_PDFViewer.Assets.GIS Succinctly.pdf); 
 
      // Loads the PDF document in PDF viewer control. 
      pdfViewerControl.LoadDocument(fileStream);             
} 


Note: We are recommending to load the PDF document in the OnAppearing Method.  

We have also published the Xamarin Store PDF viewer getting Started documentation which explain the step by step procedure for Viewing the PDF document in PDF viewer Xamarin Forms. Kindly refer the following link for more details on the component. 


Please try the above sample and the code snippet in your project and let us know if you face any problems in adding the PDF viewer control. 

Thanks, 
Balasubramanian S 


Adeem
Replied On October 12, 2016 08:16 PM

Thanks for the reply, unfortunately I still can't get it to work properly. I made sure i have all the DLLs refrenced and "new SfPdfDocumentViewRenderer()" in the iOS project, but still no PDF is showing up. On a physical Android phone the app crashes and on the iOS simulator only a white screen appears. I used the same code sample you mentioned, no compilation errors happen, but when i run the app the reader doesn't seem to be correctly parsing the input stream. From what I can tell, it can get the pdf data from the stream, but it can't read or parse into page numbers etc

protected override void OnAppearing()
        {
            base.OnAppearing();
            Stream documenStream = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("The_Complete_Guide_To_APUSH.iOS.Docs.AMSCO2016Key.pdf");

            PdfViewerControl pdfViewer = new PdfViewerControl();
            pdfViewer.LoadDocument(documenStream);

            Content = pdfViewer;
        }

Balasubramanian Sundararajan [Syncfusion]
Replied On October 13, 2016 08:44 AM

Hi Adeem, 

Thank you for your update. 

A support incident to track the status of this query has been created under your account for your last updated query. Please log on to our support website to check for further updates 
 
Thanks, 
Balasubramanian S  


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;