How to display pdf in browser from database using Xamarin and SQL Server

I have a listview in Xamarin form, which you can see in the screenshot here:

ListView

and this is my database structure

database

as you can see in database i have file content which is in binary format and these binary data are pdf files, i need to display these pdf in browser.

In my listview, I am retrieving data with button, what i want is when the user clicks on button, a PDF file should open in browser from the database based on id.

This is my xaml code

<ListView.ItemTemplate>
    <DataTemplate>
        <ViewCell>
            <StackLayout Orientation="Vertical" Padding="12,6">
                <Label Text="{Binding ReportName}" 
                       FontSize="24" 
                       Style="{DynamicResource ListItemTextStyle}" />
                <Label Text="{Binding Date}"  
                       FontSize="18" 
                       Opacity="0.6"
                       Style="{DynamicResource ListItemDetailTextStyle}"/>
                <Button Text="Download"/>
            </StackLayout>
        </ViewCell>
    </DataTemplate>
</ListView.ItemTemplate>

Answers

  • veezo2007pkveezo2007pk Member ✭✭

    I have a listview in Xamarin form, which you can see in the screenshot here:

    ListView

    and this is my database structure

    database

    as you can see in database i have file content which is in binary format and these binary data are pdf files, i need to display these pdf in browser.

    In my listview, I am retrieving data with button, what i want is when the user clicks on button, a PDF file should open in browser from the database based on id.

    This is my xaml code

    <ListView.ItemTemplate>
        <DataTemplate>
            <ViewCell>
                <StackLayout Orientation="Vertical" Padding="12,6">
                    <Label Text="{Binding ReportName}" 
                           FontSize="24" 
                           Style="{DynamicResource ListItemTextStyle}" />
                    <Label Text="{Binding Date}"  
                           FontSize="18" 
                           Opacity="0.6"
                           Style="{DynamicResource ListItemDetailTextStyle}"/>
                    <Button Text="Download"/>
                </StackLayout>
            </ViewCell>
        </DataTemplate>
    </ListView.ItemTemplate>
    
  • AlaxThomasAlaxThomas Member

    Thanks for sharing

Sign In or Register to comment.