Print Fromat Editor

Hi There,
Is there a file where I can directly edit-in-place a custom print format other than the the provided Web Editor? I am having issues saving my changes and also it would be a nicer experience doing the changes in an IDE. The saving problem takes place at random, where my small changes get lost when pressing the save button. I tried working with the exported customization in my custom app’s “print_format” directory but the exported format contains character escaping plus Python’s Unicode text representation (\u) for non-ascii languages. Any advice is really appreciated.

Dave,

Hi @dave-greeko,

It’s Possible first create a custom module then module set in custom app after that create a print format in custom module.
when you create a print format and save it then automatically print format add in custom app path like: custom_app/custom_app/custom_app/print_format/your_print_format_folder/your_print_format.json

Then Remove content in html line:

Then create a new file your_print_format.html and some code add to test your print format.

check code in image:
14

check in print format:

Thank You!

Thanks for your help but I am getting No Preview Available

I created a print format named “A4” and after “bench migrate” I was able to see it listed in the sales invoice print format drop down". The content of “a4.html” is:

    {{doc.name}}
    {{doc.customer_name}}

My custom app custom_print’s dir structure is as follow:
image

the content of my print format’s JSON (a4.json) file is:

{
 "absolute_value": 0,
 "align_labels_right": 0,
 "creation": "2022-03-19 02:57:43.695275",
 "css": "",
 "custom_format": 0,
 "default_print_language": "en-US",
 "disabled": 0,
 "doc_type": "Sales Invoice",
 "docstatus": 0,
 "doctype": "Print Format",
 "font": "Default",
 "html": "",
 "idx": 0,
 "line_breaks": 0,
 "modified": "2022-03-23 07:17:49.307332",
 "modified_by": "Administrator",
 "module": "Test",
 "name": "A4",
 "owner": "Administrator",
 "print_format_builder": 0,
 "print_format_type": "Jinja",
 "raw_printing": 0,
 "show_section_headings": 0,
 "standard": "Yes"
}

Something missing … :thinking:
Please, can you try again creating print format … … … … …

Thank You!

unfortunately same result (No Preview Available)

Hmm … :thinking:
Print format generate automatically or not?
remove css file for testing.
bench restart or migrate after code update.

for cross checking

try another way like added some code in

Then check your json file in html line is update or not.

Thank you.

If I do it from the UI it works just fine but it’s not picking up my changes in the .html file. I did both bench migrate and bench restart with no luck.
What are you working steps?

Here is how I did it:
From Print Format list view, I click “+Add Print Format

  1. Name” to “A4”
  2. Standard” to “Yes”
  3. DocType” to “Sales Invoice”
  4. Custom Format” to “Checked”
  5. Module” to “Test” (my module)
  6. Print Fromat Type” to “Jinja”
  7. HTML” to Sample jinja like “{{doc.name}}”

From my custom app print_format’s directory, I set “html”: “” in the “a4.json” and create “a4.html” with my custom text.

Lastly I execute “bench migrate” & " bench stop/start"