> For the complete documentation index, see [llms.txt](https://docs.yansalabs.com/pdf-generator/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.yansalabs.com/pdf-generator/technical-docs/generating-a-pdf-document/create-from-script.md).

# Create from Script

Include the code below in any area where server-side scripting is allowed in order to generate & attach a PDF file.

```javascript
var pdfHelper = new x_yala_pdf.PDFGenerator();
var resultData = pdfHelper.generateFromHTMLWithSourceAndAttach(pdfTemplate, fileName, sourceRecord, attachRecord);
```

* **pdfTemplate**: GlideRecord of the **HTML to PDF Merge Template** to use
* **fileName**: File name of the resulting attachment
* **sourceRecord**: Source GlideRecord from which to derive any dynamic data in the PDF
* **attachRecord**: Target GlideRecord where the PDF file should be attached
