Completed
Last Updated: 11 May 2022 16:03 by ADMIN
Dan
Created on: 06 Jun 2019 15:51
Category: PdfViewer
Type: Feature Request
14
Share PDF for print, email, text, etc

Most PDF Viewers come with the ability to print, email, text etc the PDF that is loaded.  For example, in the default iOS PDF viewer there is a "share" icon.  When the "share" icon is tapped, multiple options and apps come up that allow users to "print", "message/text", "email" the PDF.  It would be a great feature to have in the Xamarin UI PDF Viewer.  It could just be part of the PDFViewer Toolbar options.

7 comments
ADMIN
Didi
Posted on: 11 May 2022 16:03

Hello,

For Sharing and Saving Pdf documents through the PdfViewer Toolbar we have created a how-to article. Here is the link: https://docs.telerik.com/devtools/xamarin/knowledge-base/pdfviewer-share-save-pdf-documents 

We have created a demo in our Telerik Xamarin Sample App. It is located inside the Examples/PdfViewerControl/SaveSharePdfExample folder. You can use this demo to implement sharing mechanism in your application for sharing pdf files. 

Note that we have decided to not include the sharing mechanism as s built-in option in the control. The demo shows how to share pdf documents using the Xamarin.Essentials Share API. In addition there is a save option which saves the current document to the local application data.

Regards,
Didi
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Sadanan
Posted on: 08 Oct 2019 13:53
Thank You! that works as desired.
ADMIN
Yana
Posted on: 07 Oct 2019 09:46

Hi Sadanan,

Yes, you can add a toolbar item of type PdfViewerToolbarItemBase to the PdfViewerToolbar and set its Text/FontFamily and Command properties. Text / FontFamily could be used to apply an icon and Command could be bound to any Xamarin.Forms.Command.

Please check the following sample implementation:

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition />
    </Grid.RowDefinitions>
    <telerikPdfViewer:RadPdfViewerToolbar PdfViewer="{Binding Source={x:Reference pdfViewer}}">
        <telerikPdfViewer:ZoomInToolbarItem />
        <telerikPdfViewer:ZoomOutToolbarItem />
        <telerikPdfViewer:NavigateToNextPageToolbarItem/>
        <telerikPdfViewer:NavigateToPreviousPageToolbarItem/>
        <telerikPdfViewer:NavigateToPageToolbarItem/>
        <telerikPdfViewer:FitToWidthToolbarItem/>
        <telerikPdfViewer:ToggleLayoutModeToolbarItem/>
        <telerikPdfViewer:PdfViewerToolbarItemBase Text="Save" Command="{Binding SavePdfDocumentCommand}" />
    </telerikPdfViewer:RadPdfViewerToolbar>
    <telerikPdfViewer:RadPdfViewer x:Name="pdfViewer" Grid.Row="1"/>
</Grid>

and the code-behind:

public partial class MainPage : ContentPage
{
    public ICommand SavePdfDocumentCommand { get; set; }
    public MainPage()
    {
        InitializeComponent();

        this.BindingContext = this;

        Func<CancellationToken, Task<Stream>> streamFunc = ct => Task.Run(() =>
        {
            Assembly assembly = typeof(MainPage).Assembly;
            string fileName = assembly.GetManifestResourceNames().FirstOrDefault(n => n.Contains("pdfviewer-overview.pdf"));
            Stream stream = assembly.GetManifestResourceStream(fileName);
            return stream;
        });
        this.pdfViewer.Source = streamFunc;

        this.SavePdfDocumentCommand = new Command(this.SavePdfDocumentCommandExecute);
    }

    protected void SavePdfDocumentCommandExecute()
    {
      //custom implementation for saving the document
    }
}

Let me know if any additional questions on this pop up.

Regards,
Yana
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Sadanan
Posted on: 06 Oct 2019 18:15
Thanks for the clarification. If so, is there a possibility to create custom command in pdf toolbar space, something like SAVE PDF button/icon inside which we can write our custom implementation to save or share pdf. This will enhance UX instead of creating Save button somewhere else on the page.
ADMIN
Yana
Posted on: 01 Oct 2019 09:37

Hi Sadanan,

Thank you for your comment. 

Currently this functionality is not in our immediate plans for the upcoming release.

As for the Save PDF option - this could be achieved as of now with a custom implementation as you have the pdf as a stream/file (depending on how it is loaded). Additionally, this functionality deals with the device permissions and we would like to leave managing the permissions requested by the app to the app development team.

Thank you for the understanding.

Regards,
Yana
Progress Telerik

Sadanan
Posted on: 30 Sep 2019 17:31
Please consider this enhancement. Or at the very least Save PDF option should be provided so that the user can save the pdf in local device and then do share, print, email etc. 
ADMIN
Yana
Posted on: 11 Jun 2019 11:37
Hello Dan,

Thank you for sending this feature request, I've updated its status to "Approved" - we'll keep an eye on it and will plan it according to the demand.

I've updated your points for your involvement.

Regards,
Yana
Progress Telerik