Covert html to pdf, calculate the vertical space to the end of the last page faster
Ways to optimize:

Nested loops

You got nested while loops in convert.js script and that requires a particular attention.The outer while loop contains the construction:

...
if (getPageAmount(buffer) === originalPages) {
    while (getPageAmount(buffer) === originalPages) {
...


where if conditional redundantly checks the condition getPageAmount(buffer) === originalPages whereas the underling while loop would check the same condition by itself. Therefore, remove the redundant if "wrapper".



getPageAmount function

Deserves a separate attention (frequently invoked function).


'/Count '. Many-times hardcoded search string '/Count ' begs for extracting into a variable

let searchStr = '/Count ';

index + '/Count '.length. Duplicated expression points to a starting offset for input buffer slicing. Worth to be a variable:

let pos = buffer.indexOf(searchStr);
let startOffset = pos + searchStr.length;
let str = buffer.slice(startOffset, startOffset + 32).toString();

splitting a string by pattern and get the 1st chunk (~~string.trim().split(/\n|\/|\[|\&gt;/)[0]). What it does is splitting the input string by regex pattern /\n|\/|\[|\&gt;/ into array of substrings. Though it creates a new array of strings/chunks in memory - whereas we only need the 1st leftmost chunk .[0].Instead, a much more efficient way is to just find the position of the 1st occurrence of the pattern and slice the input string to that point.That's achievable with String.search + String.slice combination and will go smashingly faster compared to the initial approach.
Eventually the optimized function would look as:

function getPageAmount(buffer) {
    let searchStr = '/Count ',
        pos = buffer.indexOf(searchStr),
        startOffset = pos + searchStr.length;
    let str = buffer.slice(startOffset, startOffset + 32).toString();
    return ~~str.trim().slice(0, str.search(/[\n\/\[\&gt;]/))
}



DOM tree scanning

The "hero" of this section is document.querySelector('#padding-container') which appears in many places within while loops and queries the current document for a specific tag/element.
Such DOM queries become an expensive operations if used frequently, moreover - in massive traversals. Depending on markup complexity and "amount" of traversal such repetative queries may make the processing +50% slower.The solution here is to extract the reference to an element into a top-level variable and reference it in all needed places. 

# top-level variables
...
let passes = 0;
let paddingContainer = document.querySelector('#padding-container');


Extracting "padding container" height

Expression ~~paddingContainer.style.height.replace('px', '') is duplicated in many places and is candidate for Extract function technique.Could be even defined as unified function for getting height for the element passed as parameter:

function getElHeight(el):
    return ~~el.style.height.replace('px', '')

...

    ...
    _ =&gt; {
        let padding_height = getElHeight(paddingContainer);
        paddingContainer.style.height = `${padding_height * 1.5}px`
    }