> For the complete documentation index, see [llms.txt](https://docs.emobiq.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.emobiq.com/emobiq-client/006-actions-and-visual-logic/action-reference/cordova/pdf/pdfgenerate.md).

# pdfGenerate

## Description

Generates a PDF.

## Input / Parameter

| Name        | Description                                     | Input Type  | Default  | Options             | Required |
| ----------- | ----------------------------------------------- | ----------- | -------- | ------------------- | -------- |
| type        | The type of data to use.                        | String/Text | url      | url, html           | No       |
| value       | The value of the PDF file.                      | String/Text | -        | -                   | Yes      |
| result      | The result of the PDF file.                     | String/Text | base64   | base64, share       | Yes      |
| size        | The size of the PDF file.                       | String/Text | A4       | A4, A3, A2          | Yes      |
| orientation | The orientation of the PDF file.                | String/Text | portrait | portrait, landscape | Yes      |
| fileName    | The name of the PDF file.                       | String/Text | -        | -                   | Yes      |
| extra       | Extra parameters stored and passed to callback. | Any         | -        | -                   | No       |

## Output

N/A

## Callback?

### callback

The function to be executed if the PDF is generated successfully.

### errorCallback

The function to be executed if the PDF is not generated successfully.

## Video

Coming Soon.

## Example

In this example, we will generate a PDF from HTML and return the PDF file to the user.

### Steps

1. First we add a button component onto the canvas, and name it `btnGeneratePDFFromHTML`.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-549f9e31ad804aa81f25b62793080ac512feb5ff%2FpdfGenerate-step-1.png?alt=media)
2. Then we also add a label named `lblResult` which will display the PDF file once it is generated.
3.

```
![](/files/NdgzwRe2k6ZN7KD710Ke)
```

4. We click on the `btnGeneratePDFFromHTML` button from step 1 and select "Actions". We add the `pdfGenerate` function first. We add a `setComponentValue` to the flow, for when pdfGenerate returns `true`.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-26789cbff85c83bf16ae7e9795396ba5a9482497%2FpdfGenerate-step-3.png?alt=media)
5. For pdfGenerate function, open the inspector and add the following parameters:

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-d398d3fd7fbaf881171dad08726e788fbee81b58%2FpdfGenerate-step-4.png?alt=media)

   |        |                                                                            |
   | ------ | -------------------------------------------------------------------------- |
   | type   | html                                                                       |
   | value  | `<html><body style="font-size:120%">This is the pdf content</body></html>` |
   | result | share                                                                      |
6. For setComponentValue function, set the component to the label lblResult we created in step 2.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-6d831d1981260c494abc125aebe13fbf73439cd3%2FpdfGenerate-step-5.png?alt=media)

### Result

When the user clicks on the button, it will generate a PDF with the text "This is the pdf content".

![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-b41c0fea9dd709e954d53362abaae28ce8b6b09b%2FpdfGenerate-result-1.jpg?alt=media)

## Links
