[英]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));
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.