Print Format - HTML file not working

I’m working for a company that has created multiple apps for internal use. We have been creating custom Print Formats for native DocTypes in the old fashion: With the html code in the .json. But we think that it would be nice to have those Print Formats as .html files, as it can be done when the Print Format is for a DocType native to the app that has the Print Format.

This will make the Print Formats much more easy to maintain and will not break any existing functionality.

I’ve maked a GitHub issue and a PR for this:
https://github.com/frappe/frappe/issues/15417
https://github.com/frappe/frappe/pull/15418

Let me know what do you think and if you have faced the same problem before.

1 Like

why are you not writing html code at the specified box inside the print format ?

1 Like

That’s how we are doing it. But working as a team with lots of custom apps and lots of people maintaining them is hard to maintain a jinja template in a .json file (when the Print Format is exported). It will be much nicer to maintain a .html file.
It seems like the intended functionality was to allow the .html Print Format. And it is allowed, but just for DocTypes that are in the same app as the Print Format.

For example:
If i have my app “Test App” and i want to create a Print Format for my DocType “Test DocType” i can do it via .html file and we are all happy. But if i want to create a Print Format for, let’s say, “Sales Invoice” (native to ERPNext), i can’t use an .html file and i should use the html field that you mention.
By using the html field, the template is saved in a field of a .json file, all escaped and in one line. This make it impossible to maintain in an easy way (if i want to change it i have to migrate the site, start the site, copy the html field content to a propper code editor, edit it, paste it again in the html field).

3 Likes

Simple but that’s a great feature.
I have a similar problem before and this will save a lot of time!!

2 Likes

same issue here, the HTML codes in the Print Format Does not allow the use of javascript.
however javascript is running the full page view instead of preview / pdf view.

i have coded scripts in the header of the html and added it seems its not loaded

hi pro is this issue solved ?
as i have the same issue when try to make print format with html file for ‘payment entry’ doc not working in custome app

but when register the print format with ‘Accounting’ module its working