簡體   English   中英

如何使用Xamarin和SQL Server在數據庫中的瀏覽器中顯示pdf

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

我有Xamarin形式的列表視圖,您可以在以下屏幕截圖中看到它:

列表顯示

這是我的數據庫結構

數據庫

正如您在數據庫中看到的那樣,我具有二進制格式的文件內容,而這些二進制數據是pdf文件,我需要在瀏覽器中顯示這些pdf。

在我的列表視圖中,我正在使用按鈕檢索數據,我想要的是當用戶單擊按鈕時,應基於ID從數據庫中的瀏覽器中打開PDF文件。

這是我的XAML代碼

<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 Clicked="ShowPDF" Text="View" CommandParameter="{Binding FileContent}"></Button>
            </StackLayout>
        </ViewCell>
    </DataTemplate>
</ListView.ItemTemplate>

protected void ShowPDF(object sender, EventArgs args)
        {

            Button button = (Button)sender;

            string path = button.CommandParameter.ToString();



            Navigation.PushAsync(new PDFView(path));
        }

那么通常當我有使用xamarin我使用的WebView形式來顯示PDF文件中的最好的例子,我可以為你提供的這個

另外,我最近在github上看到了這個工作示例

祝好運!

萬一您遇到問題,請退回!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM