How to autosize the control depending on displayed PDF

Hi,

I have a Grid with 3 rows:

<Grid HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="44" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="50" />
        </Grid.RowDefinitions>

        <sf:SfPdfViewer x:Name="SfPdfViewer"
                        InputFileStream="{Binding PdfDocumentStream}"
                        Grid.RowSpan="3"
                        HorizontalOptions="FillAndExpand"
                        VerticalOptions="FillAndExpand" />
</Grid>

My problem is, that the SfPdfViewer control is not being autosized. I can see the upper part of the displayed document, but I am unable to view the document as a whole. So, how can I tell the control to set its height automatically depending on the displayed document? I attached the document I am testing with.

Many thanks


Attachment: topbottommarker_e9eaad99.zip

2 Replies

HI Hendryk Irmischer August 23, 2018 11:12 AM UTC

Hi,

I just did some more testing to find out where the problem could be.

I stripped down my view (containing the PDF preview) to the bare minimum. First I tried to use a Grid inside a ContentPage like described here. I also tried to use a StackLayout as described here.

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
     xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
     xmlns:sf="clr-namespace:Syncfusion.SfPdfViewer.XForms;assembly=Syncfusion.SfPdfViewer.XForms"
     x:Class="FP.Sign.Apps.Forms.UI.Answer.AnswerPage"
     x:Name="AppAnswerPage"
     Title="{Binding Job.Name}">
    <ContentPage.Content>
        <StackLayout Margin="10" Orientation="Vertical">
            <sf:SfPdfViewer InputFileStream="{Binding PdfViewModel.PdfDocumentStream}" VerticalOptions="FillAndExpand"></sf:SfPdfViewer>
        </StackLayout>
    </ContentPage.Content>
</ContentPage>

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
     xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
     xmlns:sf="clr-namespace:Syncfusion.SfPdfViewer.XForms;assembly=Syncfusion.SfPdfViewer.XForms"
     x:Class="FP.Sign.Apps.Forms.UI.Answer.AnswerPage"
     x:Name="AppAnswerPage"
     Title="{Binding Job.Name}">
    <Grid Padding="10">
        <sf:SfPdfViewer InputFileStream="{Binding PdfViewModel.PdfDocumentStream}"></sf:SfPdfViewer>
    </Grid>
</ContentPage>

Both of the views produce the same result, that can be seen on the screenshot attached. I attached the displayed document too. It is just a test document with some chars at the top and the bottom of the PDF document to indicate its top and bottom borders. As you can see on the screenshot, the characters at the top are being displayed correctly, but regardless of the options, the SfPdfViewer never expands to a height so that the whole PDF-Page can be seen. The characters at the bottom are never visible.


Attachment: samplepdfandscreenshot_c84f713a.zip


KK Karthik Krishnaraj Syncfusion Team August 23, 2018 01:26 PM UTC

Hi Hendryk, 

Thank you for contacting Syncfusion Support, 

Currently we don’t have support to “AutoSize (Fit page PDF document in) the PDF Viewer control” in Xamarin Forms.  

We have already logged this feature request. Currently, we don’t have any plans to implement this feature. It will be available in any of our upcoming releases. We usually have an interval of at least three months between releases. The feature implementation would also greatly depend on the factors such as product design, code compatibility and complexity. We will let you know the details once the feature has been implemented. 
 
Regards, 
Karthik. 


Loader.
Up arrow icon