Skip to content

Commit 4e55d49

Browse files
authored
Merge pull request #90 from syncfusion-content/XAMARIN-42575-LoadPDFFromURL
XAMARIN-42575-Add a topic to illustrate how to load a document from URL in Getting Started page
2 parents 2434d01 + 12bf0aa commit 4e55d49

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

xamarin-android/SfPdfViewer/Getting-Started.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,27 @@ protected override void OnCreate(Bundle bundle)
8383

8484
Deploying this project in the Android device would display the PDF document and allow you to scroll and zoom through the pages.
8585

86+
## Loading a PDF from an URL
87+
88+
PDF documents can be loaded from a given URL into the PdfViewer by downloading the PDF and then loading the stream of the downloaded file into the PdfViewer. In the following code sample, the `HttpClient.GetAsync( )` method sends a GET request to the specified Uri as an asynchronous operation and the `HttpContent.ReadAsStreamAsync( )` method will serialize the HTTP content and returns a stream that represents the content as an asynchronous operation. Finally, the obtained stream is passed to the `LoadDocument( )` method of SfPdfViewer.
89+
90+
{% tabs %}
91+
{% highlight c# %}
92+
93+
HttpClient httpClient = new HttpClient();
94+
HttpResponseMessage response = await httpClient.GetAsync("https://www.syncfusion.com/downloads/support/directtrac/general/pd/GIS_Succinctly1774404643.pdf");
95+
Stream pdfStream = await response.Content.ReadAsStreamAsync();
96+
pdfViewerControl.LoadDocument(pdfStream);
97+
98+
{% endhighlight %}
99+
{% endtabs %}
100+
101+
The sample that illustrates loading a PDF from an URL can be downloaded from the link below,
102+
103+
<https://www.syncfusion.com/downloads/support/directtrac/general/ze/LoadPDFFromURL-NativeAndroid-1933958599.zip>
104+
105+
N> An Internet connection is necessary to get the stream from an URL. Please ensure that the device has a proper internet connection before running the sample application.
106+
86107
## Unloading PDF document from the Viewer
87108

88109
The Xamarin.Android PDF Viewer (SfPdfViewer) control allows you to unload the PDF document from the viewer, when the PDF document is not in use anymore. This releases the PDF document and all its associated resources of the application.

0 commit comments

Comments
 (0)