Skip to main content

Getting 'Paged is Not Defined' Error When Converting HTML to PDF

Updated over a month ago

You may encounter an error such as:

Precompile script is not valid or ReferenceError: Paged is not defined

when rendering certain HTML templates.

Why This Happens

This issue typically arises due to the order of your <script> tags in the HTML. When custom JavaScript, like Handlebars helpers or external libraries (e.g., Paged.js), is not loaded in the right sequence, it can lead to reference errors or failed precompilation.

How to Fix It

To fix this, you'll need to reorder your <script> tags in the HTML template:

  1. Place Handlebars Helper Scripts First
    Ensure that any script that defines Handlebars helpers or template logic goes at the top of your script list.

  2. Move Other Scripts Below
    JavaScript libraries or custom scripts (like Paged.js) should go after your Handlebars-related scripts.

This reordering ensures all necessary variables and functions are available when needed during template rendering or precompilation.

Did this answer your question?