Some test text!
Online PDFs can be viewed the same way as one can stream an online video. For example, you can see the beginning of the content almost immediately, and if you move to the middle of the content, it is prioritized and loaded very quickly, before other parts. Showing partial PDF content while downloading on demand provides fast and responsive PDF viewing experience. While most viewers require the entire file to be downloaded before it can be opened and viewed, with PDFTron technology, viewing partial content for online PDF is made simple.
Due to the variety of PDF files and their hosting source, not every PDF can be viewed before the entire file is downloaded. To make this happen, the following are required:
A linearized document has two important properties:
PDFTron SDK can linearize new and and existing PDF documents when they are saved. Once you have a
PDFDoc object (by either opening an existing PDF or creating a new one), it can be saved with the
e_linearized flag, for example:
var pdfdoc = new PDFDoc("in.pdf"); pdfdoc.Save("out.pdf", pdftron.SDF.SDFDoc.SaveOptions.e_linearized);
Another potential option is to use Acrobat to save a document for "Fast Web View", which will also linearize a document.
Secondly, a web server that supports byte-range requests is required. A byte-range request asks the server to send a certain set of bytes from a file that don't necessarily start from byte zero or comprise the entire file. For example if the HTTP GET headers include the following key value pair
~97 KB will be sent from the requested file by a byte-range supporting server, starting at byte 1495454.
To test whether your webserver supports this feature, use cURL on your favourite *nix system (or using the native Windows version) as follows:
curl -H Range:bytes=16- -I https://www.pdftron.com
If the server responds with
HTTP/1.1 206 Partial Content
then it supports byte ranges. (If it responds with “HTTP/1.1 200 OK”, then it does not support byte ranges.)
A couple of small notes:
With a linearized PDF and a webserver that supports byte-range requests, use the following to view the online PDF:
(Xamarin.Android) Using DocumentActivity :
DocumentActivity.OpenDocument(this, "http://example.com/sample.pdf", "password");
(Xamarin.Android) Using PdfViewCtrlTabHostFragment2 :
PdfViewCtrlTabFragment2.CreateBasicPdfViewCtrlTabBundle(this, Android.Net.Uri.Parse("http://example.com/sample.pdf"), "password");
(Xamarin.Android) Using PDFViewCtrl :
mPdfViewCtrl.OpenUrlAsync("http://example.com/sample.pdf", "cache_path", "password", null);
(Xamarin.iOS) Using PTTabbedDocumentViewController :
tabbedController.OpenDocumentWithURL(new NSUrl("http://example.com/sample.pdf"), "password");
(Xamarin.iOS) Using PTDocumentController :
documentController.OpenDocumentWithURL(new NSUrl("http://example.com/sample.pdf"), "password");
(Xamarin.iOS) Using PDFViewCtrl :
mPdfViewCtrl.OpenUrlAsync("http://example.com/sample.pdf", "password", "cache_path", null);
And that is it! You will see the document starts to show up shortly after.
By default, the file will be downloaded continuously until the entire file finishes downloading. However, if you are concerned about data usage, it is possible to only download parts of the PDF document that is currently on-screen. Everything that is off-screen is not downloaded to keep minimum data usage.
As more and more data heads to the cloud, it's important that information that is stored remotely can be accessed in a fast, responsive manner. Using linearized PDF documents with PDFNet's OpenURL method is a way to deliver a top-notch remote PDF viewing experience.
Get the answers you need: Support