[C# Syntax] using Viscomsoft.UWP.PDFViewerSDK;
public sealed partial class MainPage : Page {
private PDFDisplayManager _pdfDisplayManager = null;
private async void open(StorageFile file) {
DocumentFactory factory = new DocumentFactory();
IDocument doc = factory.createDocument(file.Name);
bool opened = await doc.openAsync(file);
_pdfDisplayManager = new PDFDisplayManager();
_pdfDisplayManager.Width = (int)Window.Current.Bounds.Width;
_pdfDisplayManager.Height = (int)Window.Current.Bounds.Height;
_pdfDisplayManager.Document = doc;
_pdfDisplayManager.GotoPage(1);
uiViewPanel.Child = createScrollViewControl();
IPage page = _pdfDisplayManager.Document.LoadPage(1);
Windows.Storage.Streams.IRandomAccessStream stream = await page.drawAsync(pageWidth, pageHeight);
}
private UIElement createScrollViewControl() {
ScrollViewControl svc = new ScrollViewControl();
svc.DataContext = _pdfDisplayManager;
svc.Name = "uiScrollView";
svc.SetBinding(ScrollViewControl.ItemCountProperty, new Binding { Path = new PropertyPath("PageCount") });
svc.SetBinding(ScrollViewControl.ItemIndexProperty, new Binding { Path = new PropertyPath("CurrentIndex"), Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.Default });
svc.StartIndex = _pdfDisplayManager.CurrentIndex;
return svc;
}
|