Viewing and streaming of remote PDFs via PDFNet WinRT SDK

58 views
Skip to first unread message

Support

unread,
May 2, 2013, 6:46:37 PM5/2/13
to
Q:
 

I recently downloaded an evaluation of PDFNet Mobile SDK for WinRT platform. I have a question about opening the PDF file. I looked at the Getting started tutorial which shows opening a PDF file from the file system. Can I open a PDF directly from the Http response? I got a exception about missing header.

 

This is what I would like to do :

1.       Send a Http request to get PDF document.

2.       Once the response is received ( I would prefer not to save the response to local disk  to create PDF file)

InMemoryRandomAccessStream rs = new InMemoryRandomAccessStream();

DataWriter writer = new DataWriter(rs.GetOutputStreamAt(0));

Writer.WriteBytes(await response.Content.ReadAsByteArrayAsync());

PDFDoc doc = new PDFDoc(rs);

MyPDFViewCtrl.setDoc(doc);

 

 Can I display the pdf document without saving the Http response to file system?

 

Also I’d like the feature to draw on the PDF document. How to achieve that? Is it by using annotation?



------------
A:

We do have a constructor that takes a stream as an argument. In fact, our PDFViewCtrl demo opens documents by creating a stream from a StorageFile and passing that to the constructor of PDFDoc. 
 
PDFViewCtrl also supports incremental & on-demand loading of remote PDF documents via OpenURLAsync(). This means that you do not need to download the entire file before seeing the content. Similar to movie streaming you can see the first page without any delays. You can also jump to any page and PDFNet will download data for the visible pages. For this to work the remote PDF needs to be linearized (see What is a linearized PDF file? - https://groups.google.com/d/msg/pdfnet-sdk/3j1wVxz_OVw/q-z-YJbc2eoJ)

Please note that direct viewing of PDF files via HTTP response is not technically feasible (or at least you may run into very strange results).

As for drawing on the document, we have a tools library that does just that. The PDFViewCtrlDemo in the samples solution uses this library. As you suggested, the are using annotations to do this.

The source code for these tools is shipped to licensed customers, which means that you will be able to modify the tools to suit your app better. 

 

Reply all
Reply to author
Forward
0 new messages