Touch and DocumentSource binding

11 posts, 0 answers
  1. Paul
    Paul avatar
    3 posts
    Member since:
    Feb 2012

    Posted 22 Feb 2012 Link to this post

    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
  2. Kammen
    Admin
    Kammen avatar
    312 posts

    Posted 27 Feb 2012 Link to this post

    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 >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Paul
    Paul avatar
    3 posts
    Member since:
    Feb 2012

    Posted 27 Feb 2012 Link to this post

    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



  5. Kammen
    Admin
    Kammen avatar
    312 posts

    Posted 28 Feb 2012 Link to this post

    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 >>
  6. Paul
    Paul avatar
    3 posts
    Member since:
    Feb 2012

    Posted 28 Feb 2012 Link to this post

    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
  7. Kammen
    Admin
    Kammen avatar
    312 posts

    Posted 29 Feb 2012 Link to this post

    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 >>
  8. Mark
    Mark avatar
    15 posts
    Member since:
    Apr 2012

    Posted 21 Sep 2012 Link to this post

    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 


     

  9. Kammen
    Admin
    Kammen avatar
    312 posts

    Posted 24 Sep 2012 Link to this post

    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.

  10. Mark
    Mark avatar
    15 posts
    Member since:
    Apr 2012

    Posted 24 Sep 2012 Link to this post

    Thank you Kammen.  No problem after updating to 2012.2.912.40. Will update first next time.
  11. Mark
    Mark avatar
    15 posts
    Member since:
    Apr 2012

    Posted 30 Mar 2013 Link to this post

    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.   









  12. Kammen
    Admin
    Kammen avatar
    312 posts

    Posted 01 Apr 2013 Link to this post

    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.

Back to Top
UI for WPF is Visual Studio 2017 Ready