Error trying to generate a PDF from custom Print Format

I have a custom Print Format. When I want to generate a PDF with a custom Production Order, I click on the PDF Button. At the moment of generating the PDF, some type of error is produced that makes the PDF blank, with no trace of any field of the custom Production Order.
The console shows this error:

Uncaught (in promise) TypeError: Cannot read property 'appendChild' of null
	at FilterContent.initialize_ (filter.content.js:148)
	at whenDomReady_.then (filter.content.js:21)
    initialize_ 				  		                             @ filter.content.js:148
    whenDomReady_.then 						                         @ filter.content.js:21
    Promise.then (async)
    FilterContent.opr.contentFilterPrivate.isWhitelisted.whitelisted @ filter.content.js:21
    safeCallbackApply 						                         @ VM848 extensions: uncaught_exception_handler:27
    handleResponse 						                             @ VM849 extensions::sendRequest:67

What is the meaning of this error? How could I solve it?

P. S.: If, from the print page, I right click on the form and choose the option Save as PDF …, the PDF is generated correctly with all the fields of the custom Production Order.

P. S.: The error is only related to the custom Print Format, not with the custom Doctype, since, if I generate a PDF with the standard Print Format everything goes correctly.