This is a migrated thread and some comments may be shown as answers.

Touch and DocumentSource binding

10 Answers 244 Views
PDFViewer
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 22 Feb 2012, 05:32 PM
I do not see a way of zooming using touch without adding code on my part.  I hope that full touch manipulations would be added in a future release.  In the mean time, any examples showing the easiest way in your opinion to add a simple two finger zoom would be nice.

An example of how to bind DocumentSource to a string, would also be nice.  I see a reference to a PdfDocumentSourceConverter in the docs, but I see no examples of how to use it, nor any clues as to what xlmns namespace we have to expose to see it. 

I would also like to understand what if anything we need to do to clean up when we switch DocumentSources. 

The documentation on this control is pretty sparse. 

Thanks
Paul

10 Answers, 1 is accepted

Sort by
0
Kammen
Telerik team
answered on 27 Feb 2012, 06:08 PM
Hi Paul,

1. Currently RadPdfViewer does not have implementations for touch operations. You can use the ScaleFactor property of RadPdfViewer to zoom the document in/out. 

2. Please find attached an example of how you can bind the DocumentSource. More information to the type of properties you can bind the DocumentSource to can be found in our online documentation

3. When it comes to cleaning up when changing the document source, this is not needed. The only thing you may want to do if is to close your stream on PdfDocumentSource Loaded event. This is when a stream is used to create a PdfDocumentSource instance.

Kind regards,
Kammen
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Paul
Top achievements
Rank 1
answered on 27 Feb 2012, 10:31 PM

Thank you for the response.

I see in the example where and how you are using the PdfDocumentSourceValueConverter to load the local document

"/PdfViewerDemo;component/SampleData/Sample.pdf"

If I try to use a uri that is on my local drive, it works.
C:\Projects\InAisleSystems\iStore\Docs\Workflows 2012-02-02.pdf

If I try to hit a uri that is of the form
https://idm.myserver.com/assets/pdf/ffa8d834-69ac-46a1-a52b-dfd137f8b007.pdf
or
http://idm.myserver.com/assets/pdf/ffa8d834-69ac-46a1-a52b-dfd137f8b007.pdf




I get the following error in my output.

A first chance exception of type 'System.NotSupportedException' occurred in System.dll
A first chance exception of type 'System.NotSupportedException' occurred in Telerik.Windows.Documents.Fixed.dll

Where is a list of the supported uri types for pdfs?  And how would I load a PDF from an internal web https: or http: uri?

Thanks
Paul



0
Kammen
Telerik team
answered on 28 Feb 2012, 06:42 PM
Hi Paul,

When you try to load а stream from an absolute Uri with WebClient, the resulting stream is ConnectStream which does not support the Seek operation. This operation is vital for PdfFormatProvider, so it throws an exception. We will make sure to update our documentation about this limitation.

In these cases you can download (read) the content of the stream, create a new MemoryStream with it and pass it as a parameter to the PdfDocumentSource constructor. This, however, is a slow approach and is not recommended. You should use only documents that you can open a direct stream that supports Read and Seek operations.

Greetings,
Kammen
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Paul
Top achievements
Rank 1
answered on 28 Feb 2012, 07:14 PM
So if I understand you correctly, the PDFViewer will only work with streams that support seek.

This means that we would have to copy local ( via a copy or using a memory stream ) any pdf's that we want to view using it.

Thats it?

Thanks
Paul
0
Kammen
Telerik team
answered on 29 Feb 2012, 03:10 PM
Hello Paul,

That is right - the stream must enable the seek operation in order to be able successfully show its content in RadPdfViewer. 
There are some other limitations to the files that RadPdfViewer can show - such as the fact that the PDF file should not be encrypted, but the cause of the NotSupportedException is the fact that the stream does not support seeking. Therefore, if you copy it to a MemoryStream and use the memory stream, this problem should be resolved.

Kind regards,
Kammen
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Mark
Top achievements
Rank 1
answered on 21 Sep 2012, 05:13 PM
Hi Kammen.

re: Your comment: When it comes to cleaning up when changing the document source, this is not needed.

When I run the sample PdfViewerDemo app and open, say, c:\temp\doc1.pdf, then open another pdf, say, c:\temp\doc2.pdf, the first pdf c:\temp\doc1.pdf is still in use by the app. I can't rename it or delete it until I close the app. In fact, every pdf opened by the app is considered "in use" until the app closes.

So, I think a way of cleaning up when changing the document source is needed.

I tried setting DefaultFormatProviderSettings="ReadAllAtOnce".

This did not help.  

I am using WPF RadControls version v.2012.1.326.40.

Mark 


 

0
Kammen
Telerik team
answered on 24 Sep 2012, 11:16 AM
Hi Mark,

There was indeed such an issue with the 2012.1.326 version of the controls. However, the problem is now fixed and in the latest version everything works as expected.

You can download the 2012 Q2 SP2 (2012.2.912) version from your account.


Regards,
Kammen
the Telerik team

Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

0
Mark
Top achievements
Rank 1
answered on 24 Sep 2012, 12:55 PM
Thank you Kammen.  No problem after updating to 2012.2.912.40. Will update first next time.
0
Mark
Top achievements
Rank 1
answered on 30 Mar 2013, 09:56 PM
This is just fyi 

My WPF app produces PDfs on the fly, saves them in a temporary folder and displays them in a RadPdfViewer control with DocumentSource="{Binding PreviewDocumentSource}".  The MainWindow's Closing event calls cleanup code that deletes the temporary folder.

To force RadPdfViewer to close the last PDF file, I set DocumentSource = Nothing before calling the cleanup code.  This works.  Perhaps this is obvious, but it took me a while to figure out that setting PreviewDocumentSource = "" in MainWindows' view model, which frees up the file so it can be deleted, also causes a NullReferenceException when MainWindow closes.   









0
Kammen
Telerik team
answered on 01 Apr 2013, 11:09 AM
Hi Mark,

Indeed, when you use the ReadOnDemand setting (this is by default) in order to show documents in RadPdfViewer, you will need to clean the DocumentSource manually. This is necessary because RadPdfViewer keeps the stream opened in order to read the information it needs on demand. By design, the stream is closed as soon as the DocumentSource is changed.

All the best,
Kammen
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
PDFViewer
Asked by
Paul
Top achievements
Rank 1
Answers by
Kammen
Telerik team
Paul
Top achievements
Rank 1
Mark
Top achievements
Rank 1
Share this question
or