# Html To Pdf

CodeMash's built-in function for generating PDF documents from HTML is a convenient and easy-to-use tool for creating PDF documents from your app or website. It is a serverless function deployed to the cloud, which means it runs on demand and is only charged for the execution time and resources used. This can be more cost-effective and scalable than running a traditional server-based solution.

To use the function, you simply provide the HTML content you want to include in the PDF document and any additional options or settings you want to apply. The function will then generate the PDF document and return it to you in a convenient format.

This built-in function can be especially useful for creating reports, invoices, or other documents that need to be delivered to customers or clients in a professional and standardized format. It can save you time and effort by automating the process of creating PDF documents, and it can help you to ensure that your documents are consistent and of high quality.

## Enable the Html To Pdf function

1. Log in to your CodeMash account and go to the Code module.
2. Click on the "Functions" tab.
3. Click on the "Add New" button.
4. Select the "Html To Pdf" function from the list.

   <figure><img src="/files/YlaRdkrUYBUdrDVr60ex" alt=""><figcaption></figcaption></figure>
5. Click the "Add Function" button to add the function to your project.

The function "Html To Pdf" has several properties that can be configured to customize its behavior. These properties include:

* **Display Name**: Function name.
* **Description**: This brief description of the function is displayed in the CodeMash user interface.
* **Tags**: These are keywords that can be used to organize and categorize the function.
* **File Account**: This is the name of the file account that will be used to store the generated PDF file.
* **Code**: This is the C# code that will be executed before the HTML template is rendered. This can be used to customize the data available to the template.
* **Template HTML**: This is the HTML template that will be used to generate the PDF file. The template can include tokens that will be replaced with data from the CodeMash database.
* **Configuration**: This is a set of general PDF configuration options, such as margins, header display, and scaling. These can be used to customize the appearance and layout of the generated PDF file.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.codemash.io/dashboard/code/codemash-functions/generate-pdf.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
