# The PDF Module

Learn how to use Wijmo's PDF Module to create PDF documents in this tutorial

## Content


__PdfDocument__ is the main class used in the __wijmo.pdf__ module to create PDF documents. The implemenation is an extension of __PDFKit__, a JavaScript PDF generation library.

The key differences are:

* A page is divided into three sections: header, body and footer. Each of these sections represents a drawing area with its own methods for drawing text and graphics.
* Text of the header and footer areas can be defined declaratively and support macros for automatic page numbering.
* The graphics state management methods such as __fillColor__, __lineWidth__ are incapsulated within the pen and brush entities, that acts in more friendly way for .NET developers.
It provides API for drawing text, vector graphics and images.

## Using __PdfDocument__

Here is a typical sequence of steps when using __PdfDocument__:

1. Create the __PdfDocument__ class instance with the ended event handler declared. The Blob object containing document data will be passed to this event handler when document rendering is done, where it can be saved to a file.

Following is the minimal code required to generate a single page blank document:


```javascript
import * as wjPdf from '@mescius/wijmo.pdf';

var doc = new wjPdf.PdfDocument({
    ended: function (sender, args) {
        wijmo.pdf.saveBlob(args.blob, "Document.pdf");
    }
});
```


2. Draw the document using the instance members.

```javascript
doc.drawText("Lorem.");
doc.drawText("Ipsum.", 0, 30);

doc.drawImage("resources/wijmo1.png");
```


3. Finally, call end method of the instance to finish rendering and raise the ended event.

```javascript
doc.end();
```
