This quick start will guide you through the steps of adding FlexViewer control to the application, binding it with a document source, i.e., GcPdf, and loading the PDF in the FlexViewer control.
To achieve it, follow these steps:
The following image shows how the FlexViewer control appears after completing the steps above.
QuickStart.xaml
) to your Mobile App (Xamerin.Forms) and include references as shown below.XAML |
コードのコピー
|
---|---|
<?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:FlexViewerXamarin" xmlns:c1="http://schemas.grapecity.com/xf/2019/xaml" x:Class="FlexViewerXamarin.QuickStart"> </ContentPage> |
XAML |
コードのコピー
|
---|---|
<c1:FlexViewer x:Name="flexViewer"/> |
C# |
コードのコピー
|
---|---|
using Xamarin.Forms; using Xamarin.Forms.Viewer; |
C# |
コードのコピー
|
---|---|
Assembly assembly; //PDFにFlexViewerコントロールを連結します assembly = IntrospectionExtensions.GetTypeInfo(typeof(MainPage)).Assembly; Stream stream = assembly.GetManifestResourceStream("App4.Resources.DefaultDocument.pdf"); |
Load the PDF document in the FlexViewer control using the following code. In this example, we have added a PDF document to the Resources folder to load it in the viewer.
C# |
コードのコピー
|
---|---|
//ビューアにPDFドキュメントをロードします
flexViewer.LoadDocument(stream);
|
The following code shows the class constructor App() after completing this step.
C# |
コードのコピー
|
---|---|
public App() { // アプリケーションのルートページ MainPage = new QuickStart(); } |
C# |
コードのコピー
|
---|---|
C1.Xamarin.Forms.Viewer.Platform.iOS.FlexViewerRenderer.Init(); |
C# |
コードのコピー
|
---|---|
C1.Xamarin.Forms.Viewer.Platform.UWP.FlexViewerRenderer.Init(); |
(Optional) In case you compile your UWP application in Release mode, you need to explicitly add the following code to the OnLaunched method in your App.xaml.cs to include the correct assemblies within your application.
C# |
コードのコピー
|
---|---|
var assembliesToInclude = new List<Assembly>(); assembliesToInclude.Add(typeof( C1.Xamarin.Forms.Viewer.Platform.UWP.FlexViewerRenderer).GetTypeInfo().Assembly); assembliesToInclude.Add(typeof(C1.UWP.Viewer.FlexViewer).GetTypeInfo().Assembly); Xamarin.Forms.Forms.Init(e, assembliesToInclude); |