Create and load PDF Forms in Universal Applications using Windows Store and Windows Phone PDF library. Written by Apitron Documentation Team

Similar documents
Create PDF Forms in ios applications using Xamarin PDF library by Apitron. Written by Apitron Documentation Team

Create PDF invoice in Windows Forms application. Written by Apitron Documentation Team

What's New in Bomgar 13.1

Windows Presentation Foundation Tutorial 1

The full setup includes the server itself, the server control panel, Firebird Database Server, and three sample applications with source code.

Essentials of Developing Windows Store Apps Using C# MOC 20484

Windows Presentation Foundation

Bonita Open Solution. Introduction Tutorial. Version 5.7. Process Design User Guidance Profile: Business Analyst

ArcGIS Viewer for Silverlight An Introduction

System Requirements for Microsoft Dynamics NAV 2016

STEP BY STEP to Build the Application 1. Start a. Open a MvvmLight (WPF4) application and name it MvvmControlChange.

Implementing multi-user multi-touch scenarios using WPF in Windows* 8 Desktop Apps

Features List Contents

All About Android WHAT IS ANDROID?

ArcGIS Web Mapping. Sam Berg, esri

Take Your Team Mobile with Xamarin

WatchDox SharePoint Beta Guide. Application Version 1.0.0

Microsoft Dynamics AX Windows 8 App Starter Kit. App Development Guide Version 1.0

Software Development Interactief Centrum voor gerichte Training en Studie Edisonweg 14c, 1821 BN Alkmaar T:

3M Cloud Library Reading Apps User s Guide Revision Date: September 2014

Skynax. Mobility Management System. System Manual

End-User Software Development: Tool Support for Mobile Data Collections

UPK Content Development Rel 12.1

This course provides students with the knowledge and skills to develop ASP.NET MVC 4 web applications.

System Requirements for Microsoft Dynamics NAV 2016

Setting up Visual Enterprise Integration (WM6)

paragraph(s). The bottom mark is for all following lines in that paragraph. The rectangle below the marks moves both marks at the same time.

Windows Intune Walkthrough: Windows Phone 8 Management

Submitting UITests at the Command Line

Evaluation of Xamarin Forms for MultiPlatform Mobile Application Development

TIBCO Spotfire Automation Services 6.5. User s Manual

XML-API Application Interface

Windows Presentation Foundation (WPF)

Foxit MobilePDF for ios Quick Guide

vcenter Orchestrator Developer's Guide

Making Mobile a Reality

Essential Mapping Apps

WebSphere Business Monitor

AppDev OnDemand Microsoft Development Learning Library

PEGA MOBILITY A PEGA PLATFORM WHITEPAPER

SQL Server 2016 BI Any Data, Anytime, Anywhere. Phua Chiu Kiang PCK CONSULTING MVP (Data Platform)

UPK Content Development Rel 11.1

Einführung in die Windows Store App Entwicklung mit C# und XAML. Modul 2 Datenbindung und Zugriff auf das lokale Dateisystem

Microsoft Visual Studio: Developing Cross-Platform Apps With C# Using Xamarin

Rapid Game Development Using Cocos2D-JS

Manual English KOI Desktop App 2.0.x

Made by You - Display Scaling in Windows 10

Digital Asset Management in Museums

Microsoft Office 2013

Microsoft Virtual Labs. Building Windows Presentation Foundation Applications - C# - Part 1

Welcome The webinar will begin shortly

System Requirements. Microsoft Dynamics NAV 2016

Integration Overview. Web Services and Single Sign On

System Requirements for Microsoft Dynamics NAV 2016

Enterprise File Share and Sync Fabric. Feature Briefing

Information Server Documentation SIMATIC. Information Server V8.0 Update 1 Information Server Documentation. Introduction 1. Web application basics 2

Creating a Poster in PowerPoint A. Set Up Your Poster

System Requirements for Microsoft Dynamics NAV 2016

Joomla! 2.5.x Training Manual

Relationships in WPF Applications

Splunk for.net Developers

Petroleum Web Applications to Support your Business. David Jacob & Vanessa Ramirez Esri Natural Resources Team

User Guide FOR TOSHIBA STORAGE PLACE

Xerox Mobile Link App Benefits Examples

System Requirements for Microsoft Dynamics NAV 2015

Step by Step. Use the Cloud Login Website

DuPont Diagnostics takes food safety test results mobile with Xamarin.Forms

آموزش DataGrid در WPF به همراه صفحه بندي و جستجوي انتخابی. کلیک کن

Overview. About Interstitial Ads: About Banner Ads: About Offer-Wall Ads: ADAttract Account & ID

How to deploy fonts using Configuration Manager 2012 R2

New Features in XE8. Marco Cantù RAD Studio Product Manager

Mobile Print/Scan Guide for Brother iprint&scan

A smart app integrated with a Webbased advisory system for designing and managing grain drying and storage

HTML5. Turn this page to see Quick Guide of CTTC

Interactive Church LIFE is a Mobile App Publishing Platform

KonyOne Server Prerequisites _ MS SQL Server

Set Up SOS Video Chat and Screen-Sharing

Developing Apps with the ArcGIS Runtime SDK for Android. Ben Ramseth Esri Inc. Instructor Technical Lead

5.1 Features Denver CO 80202

Terminal 4 Site Manager User Guide. Need help? Call the ITD Lab, x7471

Notepad++ The COMPSCI 101 Text Editor for Windows. What is a text editor? Install Python 3

Getting started with Adobe Reader

Viewing LogicalCHOICE ebook/epub Files

Welch Allyn Connectivity SDK Development

Braindumps.C questions

Understanding In and Out of XAML in WPF

Microsoft Excel 2007 Level 2

Applicant Workflow Hiring Managers

How to Develop Accessible Linux Applications

Generate Android App

Transcription:

Create and load PDF Forms in Universal Applications using Windows Store and Windows Phone PDF library Written by Apitron Documentation Team

Introduction Universal Windows Store application project provides a good way to share code and develop Windows Phone and Windows Store version of the application at the same time. In case of our library it s even more fun because API remains the same and you can use the same PDF.NET library for both projects. PDF files can contain forms consisting of fields where the information can be stored for later use and processing. If you d like to read more about PDF forms and fields, official PDF specification is an invaluable resource. This topic is also covered in our pdf cookbook Apitron PDF Kit in action (available for free by the following link), see sections 3.7 Interactive Forms and section 4.4 Content Element And Controls. There are examples on how to create, edit or read data stored in PDF forms, written in C# with detailed explanation. A good example demonstrating how to work with PDF forms is a questionnaire app gathering some data from the user and storing it in PDF document as a form. So we decided to go through and prepared sample universal app using our Apitron PDF Kit library that generates, saves and loads product questionnaire data.

Solution overview To keep this sample as simple as possible we used single XAML page representing form layout and providing the data bound view for questionnaire data. Data Model Data model is represented by base class called ProductQuestionnaireForm and by its specific implementation ApitronProductQuestionnaireForm. See the diagram below. Pic. 1 Class digram, Apitron questionnaire sample Page controls are bound to properties of ApitronProductQuestionnaireForm instance, so we don t have to write any code to handle form updates if user changes their content.

Windows Phone App The view is represented by XAML app page, see picture below showing desktop and phone versions. They are almost identical and use same markup except some minor changes needed to fit content on the phone screen. Pic. 2 Questionnaire App, Windows Phone version

Windows Store App Form layout for Windows Store app is shown here, below is a screenshot from Visual Studio XAML designer. Pic. 3 Questionnaire app, Windows Store version Workflow Using this app the user can fill the questionnaire form provided, in our case it s a test form collecting opinions about Apitron products. After that, he can save entered data to local app storage as PDF form or load an existing form from it. For simplicity, data is being saved as file form.pdf located in local app folder, which can be opened by using the following known folder: ApplicationData.Current.LocalFolder.

Output Generated questionnaire pdf form is shown on the image below. Both apps generate identical PDF files. Pic. 4 Generated questionnaire pdf form This file can be found by the following path: C:\Users\[user name]\appdata\local\packages\[deployed package guid]\localstate\form.pdf

Same form but opened in design mode is shown below. You can see field names assigned to each widget annotation present on page. Widget annotations are special kind of controls used to define visual representation of form fields data. In our case all controls created for this PDF form are made read-only, however it s possible to make form data editable after generation if needed. Pic. 5 Generated questionnaire pdf form opened in design mode

The code Complete app sample can be found in Apitron PDF Kit download package available on our website, check out this link. Here we d like to highlight PDF specific code that is responsible for form generation. It can be found in ProductQuestionnaireForm class and is provided below. PDF Form generation and saving /// <summary> /// Creates FlowDocument that represents PDF form. /// </summary> private FlowDocument CreatePDFDocument() FlowDocument document = new FlowDocument()Margin = new Apitron.PDF.Kit.Styles.Thickness(10); // add form fields and set text values based on form data document.fields.add(new TextField("SelectedProduct", SelectedProduct)IsReadOnly = true); document.fields.add(new TextField("UsagePeriod", UsagePeriod) IsReadOnly = true ); document.fields.add(new TextField("SatisfactionLevel", SatisfactionLevel) IsReadOnly = true ); document.fields.add(new TextField("UserCompanyName", UserCompanyName) IsReadOnly = true ); document.fields.add(new TextField("Feedback", Feedback) IsReadOnly = true, IsMultiline = true); // register styles defining controls appearance document.stylemanager.registerstyle(".formheader",new Apitron.PDF.Kit.Styles.Style() Display = Display.Block, Font = new Font(StandardFonts.HelveticaBold, 20)); document.stylemanager.registerstyle("textblock, TextBox", new Apitron.PDF.Kit.Styles.Style() Font = new Font(StandardFonts.Helvetica, 14)); document.stylemanager.registerstyle("textblock + TextBox", new Apitron.PDF.Kit.Styles.Style() BorderColor = RgbColors.Black, Border = new Border(1), Height = 20, Background = RgbColors.LightGray); document.stylemanager.registerstyle("br", new Apitron.PDF.Kit.Styles.Style() Height = 10); // add document content elements document.add(new TextBlock("Product questionnaire form")class = "formheader"); document.add(new TextBlock("Generated on " + DateTime.Now.ToString("dd/MM/yyyy HH:mm"))); document.add(new Hr()Height = 2, Margin = new Thickness(0,5,0,5)); document.add(new TextBlock("Selected product:")); document.add(new TextBox("SelectedProduct")); document.add(new Br()); document.add(new TextBlock("Usage period:")); document.add(new TextBox("UsagePeriod")); document.add(new Br()); document.add(new TextBlock("SatisfactionLevel:")); document.add(new TextBox("SatisfactionLevel")); document.add(new Br()); document.add(new TextBlock("User company name:")); document.add(new TextBox("UserCompanyName")); document.add(new Br()); document.add(new TextBlock("Feedback:")); document.add(new TextBox("Feedback")Height = 100); return document;

/// <summary> /// Saves current form data to local storage. /// </summary> public async Task<bool> SaveToLocalStorage(string filename) try FlowDocument pdfdocument = CreatePDFDocument(); StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync(fileName,CreationCollisionOption.ReplaceExisting); using (Stream outputstream = await file.openstreamforwriteasync()) pdfdocument.write(outputstream, new ResourceManager(), new PageBoundary(Boundaries.A4)); catch (Exception e) Debug.WriteLine(e.Message); return false; return true; Loading stored PDF form data /// <summary> /// Load form data from PDF file using given filename. /// </summary> public static async Task<ProductQuestionnaireForm> LoadFromLocalStorage(string filename) try StorageFile file = await ApplicationData.Current.LocalFolder.GetFileAsync(fileName); using (Stream inputstream = await file.openstreamforreadasync()) // use fixed document for reading form data FixedDocument pdfdocument = new FixedDocument(inputStream); // create and initialize form object instance ProductQuestionnaireForm form = new ApitronProductQuestionnaireForm(); form.selectedproduct = ((TextField)pdfDocument.AcroForm["SelectedProduct"]).Text; form.usageperiod = ((TextField)pdfDocument.AcroForm["UsagePeriod"]).Text; form.satisfactionlevel = ((TextField)pdfDocument.AcroForm["SatisfactionLevel"]).Text; form.usercompanyname = ((TextField)pdfDocument.AcroForm["UserCompanyName"]).Text; form.feedback = ((TextField)pdfDocument.AcroForm["Feedback"]).Text; return form; catch (Exception e) Debug.WriteLine(e.Message); return null;

Conclusion This approach can be used to create PDF forms in Windows Forms, WPF, Xamarin (Android and ios), console, web or cloud applications. As you can see from samples above it takes less than 30 lines of code to produce a basic form having all necessary content set. But Apitron PDF Kit library is not limited to just PDF forms, it provides full support for PDF features defined in official specification and can be used to create apps targeting all of the modern mobile, desktop or web platforms. Free evaluation is available for all our products. We d be happy to get any feedback from you, feel free to contact our support with any questions you may have.