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

PdfViewer : FitToWidth on StartUp?

1 Answer 244 Views
PdfViewer
This is a migrated thread and some comments may be shown as answers.
Graham
Top achievements
Rank 1
Graham asked on 08 Feb 2019, 11:13 AM
PdfViewer : FitToWidth on StartUp?

 

Is there a setting to set the viewer to display fit to width when the pdf file opens?

 

<?xml version="1.0" encoding="utf-8" ?>
             xmlns:telerikPdf="clr-namespace:Telerik.XamarinForms.PdfViewer;assembly=Telerik.XamarinForms.PdfViewer"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:telerikCommon="clr-namespace:Telerik.XamarinForms.Common;assembly=Telerik.XamarinForms.Common"
             x:Class="TelerikXamarinApp1.Portable.Page1">
    <ContentPage.Content>
 
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition />
            </Grid.RowDefinitions>
            <telerikPdf:RadPdfViewerToolbar PdfViewer="{Binding Source={x:Reference pdfViewer}}">
                <telerikPdf:ZoomInToolbarItem />
                <telerikPdf:ZoomOutToolbarItem />
                <telerikPdf:NavigateToNextPageToolbarItem/>
                <telerikPdf:NavigateToPreviousPageToolbarItem/>
                <telerikPdf:NavigateToPageToolbarItem/>
                <telerikPdf:FitToWidthToolbarItem/>
                <!--<telerikPdf:ToggleLayoutModeToolbarItem/>-->
            </telerikPdf:RadPdfViewerToolbar>
            <telerikPdf:RadPdfViewer x:Name="pdfViewer" Grid.Row="1" FitToWidthCommand=""/>
        </Grid>
         
        <!--<Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <telerikCommon:RadUniformGrid>
                <Button Text="Zoom In"
                Command="{Binding Source={x:Reference pdfViewer}, Path=ZoomInCommand}" />
                <Button Text="Zoom Out"
                Command="{Binding Source={x:Reference pdfViewer}, Path=ZoomOutCommand}" />
                <Button Text="Fit To Width"
                Command="{Binding Source={x:Reference pdfViewer}, Path=FitToWidthCommand}" />
                <Button Text="Previous Page"
                Command="{Binding Source={x:Reference pdfViewer}, Path=NavigateToPreviousPageCommand}" />
                <Button Text="Next Page"
                Command="{Binding Source={x:Reference pdfViewer}, Path=NavigateToNextPageCommand}" />
            </telerikCommon:RadUniformGrid>
            <telerikPdf:RadPdfViewer x:Name="pdfViewer"
                                   Grid.Row="1"
                                   MinZoomLevel="0.3"
                                   MaxZoomLevel="4"/>
        </Grid>-->
         
        <!--<StackLayout>
            <Label Text="Invoice Viewer"
                VerticalOptions="CenterAndExpand"
                HorizontalOptions="CenterAndExpand" />
 
            <telerikPdf:RadPdfViewerToolbar PdfViewer="{Binding Source={x:Reference pdfViewer}}">
                <telerikPdf:NavigateToPreviousPageToolbarItem />
                <telerikPdf:NavigateToPageToolbarItem/>
                <telerikPdf:NavigateToNextPageToolbarItem />
                <telerikPdf:ZoomInToolbarItem/>
                <telerikPdf:ZoomOutToolbarItem/>
                <telerikPdf:FitToWidthToolbarItem/>
            </telerikPdf:RadPdfViewerToolbar>
            <telerikPdf:RadPdfViewer x:Name="pdfViewer" Scale="50"
                                      FitToWidthCommand="True"
                                     />
             
        </StackLayout>-->
    </ContentPage.Content>
</ContentPage>

 

 

Regards,

Graham

1 Answer, 1 is accepted

Sort by
0
Didi
Telerik team
answered on 08 Feb 2019, 02:33 PM
Hi Graham,

Thank you for the provided code.

The PdfViewer DocumentSource provides a read-only property IsBusy which indicates when the control is loaded. Basically, when the IsBusy changes its state to false the document is completely loaded and the FitToWidth command can be executed. 

Currently, the PdfViewer does not provide a DocumentLoadedEvent. We have this logged as a feature request in our Feedback portal and you could vote for the item on the provided link below:

https://feedback.telerik.com/xamarin/1384431-pdfviewer-expose-a-document-loaded-event

Please take a look at the attached project how the FitToWidth command is executed when IsBusy is false.

Regards,
Didi
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
Tags
PdfViewer
Asked by
Graham
Top achievements
Rank 1
Answers by
Didi
Telerik team
Share this question
or