---
title: "Generate PDF with HTML Code as Source"
url: https://docs.catalyst.zoho.com/en/sdk/javascript/v1/smartbrowz/pdf-and-screenshot/pdf-from-htmlcode/
description: "This page describes the method to perform operations using the components in SmartBrowz Services."
last_updated: 2026-09-09T10:45:38Z
service: SmartBrowz
type: general
related_links:
- name: "Catalyst SmartBrowz"
url: /en/smartbrowz/
- name: "PDF \u0026 Screenshot"
url: /en/smartbrowz/help/pdfnscreenshot/introduction/
- name: "Templates"
url: /en/smartbrowz/help/templates/introduction/
- name: "Java SDK Documentation"
url: /en/sdk/java/v1/smartbrowz/generate-pdfnscreenshot/
- name: "Python SDK Documentation"
url: /en/sdk/python/v1/smartbrowz/generate-pdfnscreenshot/
- name: "REST API Documentation"
url: /en/api/code-reference/smartbrowz/generate-pdfnscreenshoturl/#PDF%26ScreenshotwithHTMLorURLasInput
repository:
name: "Repository"
url: https://github.com/catalystbyzoho/zcatalyst-sdk-js
---
# Generate PDF with HTML Code as Source
> **Notes:**
* Ensure you have installed the [required package](https://docs.catalyst.zoho.com/en/sdk/javascript/v1/smartbrowz/overview/#prerequisites) to use this SDK method.
* Any browser action or operation that you code using the Browser Logic function, or any browser automation or web scraping task that you perform using any component of *Catalyst SmartBrowz* is at **your own risk**. We strongly recommend that you use the SmartBrowz components to perform operations on domains that permit the actions, or with proper approval.
Additionally, while Catalyst does provide a secure infrastructure to code your functions, any consequence of the logic you code using Catalyst functions is yours alone.
Using the `convertToPdf()` SDK method, you can generate a PDF document using HTML code as source. The SDK method also allows you to implement multiple customization options including page orientation, size, [password protection](https://docs.catalyst.zoho.com/en/smartbrowz/help/templates/customize-templates/#password-protected-pdfs), and so much more.
The `smartbrowz` reference used in the code snippets below is the [component instance](https://docs.catalyst.zoho.com/en/sdk/javascript/v1/smartbrowz/create-smartbrowz-instance/) created to perform these operations.
```javascript
const result = await smartbrowz.convertToPdf("HI", {
pdf_options: {
display_header_footer: true,
footer_template: "Page Header",
margin: {
bottom: "20",
left: "10",
right: "10",
top: "20"
},
height: "100",
width: "100",
landscape: true,
page_ranges: "1-2",
scale: 1.0,
password: "****123"
},
page_options: {
css: { content: "body { font-size: 12px; }" },
javascript_enabled: true,
viewport: {
height: 800,
width: 600
},
device: "Blackberry PlayBook"
},
navigation_options: {
timeout: 30000,
wait_until: "domcontentloaded"
}
});
console.log("result::", result);
```