In this article you will learn how to generate a PDF without using any APIs.
Now, I’m going to create a Project with Employee Information as an example to generate the Selected Employee Details as a PDF.
Step 1: Open Visual Studio 2013, click New Project, choose Windows Apps, select Blank App, and name as GeneratePdfFile. After that click OK.
Step 2: Add a Class, name it as Employee and add the following code. This contains two classes i.e Employee and EmployeeModel; Employee class is having all the properties and EmployeeModel contains all the Methods to access the employee data.
Step 3: In MainPage.Xaml.Cs add the following code to display the data in a List View.
Step 4: In order to display the data I used Data Binding concept. Now in MainPage.Xaml add the following code. Add this line in the beginning of the url:
Then add the following code,
Now run the application and see the output.
Step 5: Now to get the data into the textboxes I used selected Index changed event of combo box. Add the following code in MainPage.xaml.cs.
Now run and select the Employee Id and observe the output.
Step 6: Now is the time to generate pdfthe PDF. Double click on "Generate Pdf" button and add the following code, this code has the reference from the following link: PostScript Language Reference
Now click on the PDF and observe it. If you want to add borders add them easily by appending to string builder.
Thanks for reading my article. If you have any questions, then please mention in the comments section.
Universal Windows Platform - Complete Solution