Why branding matters and starting a letterhead
Welcome back to Frappe Academy. In this video, we will learn how to configure print and branding for ERPNext. Let's say we have to send out a sales invoice, for that, we will take a print of the PDF that gets generated from the document. This PDF looks good, it has all the necessary fields from the invoice that we need here. But the look and feel are still very generic and not specific to my company. How would my customer even know that this invoice has been sent from Frappe Furniture? Any communication, especially written, that goes out of Frappe Furniture should speak for my brand. To achieve that, first and foremost, let us add the company's letterhead here. We will go to Letterhead and create the first one. We will add the name Frappe Furniture Standard. On adding the name we can automatically select if the letterhead is going to be based on an image or HTML. We will select letterhead based on image and choose my company logo as the header image. We will make this the default letterhead for my company. On saving this we can also see the same setting in HTML.
Let me go to the sales invoice and check the print preview after enabling the letterhead. On doing that we can see that the image takes up quite a lot of space here. We will go back to the letterhead and change the width of the image in the HTML code. To reduce the size of the image we can change the width from 100 to 50 percent. We can, of course, check the preview here itself or check it in the print preview of the sales invoice. The reduced size looks much better. For now we will keep the header as-is, you can position it in the center or increase the size if you wish by adding those tags in the HTML editor for the header. Similarly, we can add the footer as well over here. Since we have a text-based footer we will add it in HTML format by using basic HTML tags. These basic tags will be available on any platform that gives basic HTML understanding. We have also dropped in some links for the same in the description that you can use. Now when we see the print preview the header and the footer have been added. With this, we have completed the first step of establishing the branding of Frappe Furniture to my ERPNext account.
Next, we will see how we can customize the sales invoice layout which we'll call a print format. For invoices, different print formats are created by default in the system, you can take the prints in one of the formats available or even create your own formats here. Let's see how. We will first select the standard format and then we'll go to Customize under the Settings menu. We will create a new print format here which we can name Invoice Format. On clicking Start, we will be redirected to the Print Format Builder. Here, we can see that the complete layout of this format can be changed by simply dragging and dropping the elements from the left sidebar. Each element represents a field in the Sales Invoice document. But first, let me have a look at the heading. The heading of the printed document is the invoice number. In case we want to change the same we can click on Edit Heading and in doc.name instead of 'name', we will simply add the name of the required field name and the same will be updated. The print formats in ERPNext can be very easily templatized using Jinja, which is a web template engine. HTML as a language is static. It is great to use when we want to generate a web page to display static information. Jinja comes into the picture when we want to add dynamic elements, like a customer name or address. We can use HTML to build the static assets of a print layout and Jinja allows us to use templates to handle that data. The HTML values will be added in angle brackets while the dynamic values will be represented with curly braces. Jinja is used extensively throughout ERPNext and the Frappe Framework, especially to define web pages and layouts. We will see more of it in the upcoming sections and videos. You can also read about it from the links given in the description. I will let the header be the invoice number but in case you want any other field to be the heading of the printed invoice we can add the field name in this way. To know about doctypes and fields, do check out our previous videos.
In the layout, we can add or remove any of the sections of fields here. Let's say we do not want the section covering accounting dimensions here. We can remove that by dragging it out. Similarly, we can add the customer shipping address. We also want another section here for tax details. Here we will add my Tax ID as well as the customer's Tax ID and the tax breakup in the invoice. Once all the elements are added and removed, we will save this format. If we go back to the Sales Invoice and use this print format, we can see in the preview that all my required fields are added here. You can create new formats by going onto the Print Format Builder or edit other existing print formats for a Sales Invoice or any other document type.
If we go back to the Print Format Builder, we can also see an Edit Properties button wherein we can change the settings for this invoice format that we have created. This is the same page as the Print Format, so you can also retrieve this by looking for Print Format in the Awesome Bar. Properties here like section headings, line breaks, the font used, etc., can be changed using this form. We can also make this format the default print format for the Sales Invoices from here. We can also design a custom print format by using templatization. For more control over what we want to show in the documents that get printed out of ERPNext, we can use a custom print format. Let's see how we can create and design a whole new print format.
To enable the same, we will be adding a Jinja type format for the new Online Order Invoice. This will be the print format for the Sales Invoice that can be sent along with my deliveries for online orders. This will be a tabulated format that should cover delivery address details of the courier service that was used, details of the online order, the dimensions of the package, warranty details of the items, and so on. After adding the required code we can see the same in the print preview. As we said earlier, anything with the angle brackets will be an HTML tag, whereas anything inside curly braces will be a dynamic value. Let's start with the letterhead. Here, we use the Python if condition to first check whether the letterhead has been enabled. So in two conditions the letterhead will be visible here. One, where the letterhead option has been enabled or two, if the default letterhead for the invoice has been selected in the document itself. This becomes the first part of the code. Moving further there are some HTML formatting tags for the heading of the invoice. Then we create a table using HTML wherein we populate all the values of the required elements of the table using Jinja. For example, in the first section, we add our company name, which gets fetched using Jinja with the string doc.company. In the next line, frappe.db.get_value is a function that we use to fetch data from the database. So this line will simply fetch the registration details of the company, if available, and paste it after the company name. In a similar fashion, we will be defining the layout and populating the data throughout the print format.
Populating custom fields, tips, and final print settings
Since the invoice does not have any fields regarding the dispatch details, we will add those using Customize Form and then populate the same in the print format. So whatever details that you want to add can either be from the database directly using the frappe.db.get_value function or from the document itself using doc.field function. Since making a custom print format might require quite some technical expertise, it is recommended that you consult someone who has the technical capability to start formatting in Jinja. For more, you can refer to the links in the description. Using print format we can have fine control with which we can ensure that every element of a PDF or an attachment generated from ERPNext will reflect my brand in some or the other way. Let us go on to Print Settings. These are some settings that will be applied if you take a print of any document across ERPNext. Here we can select if we want all the prints to be taken in PDF format, or the page size for the prints in the page settings. We can select the properties like print with letterheads, allow printing draft and canceled documents, allow page breaks and print taxes with zero amount. Since my device may not always be physically connected to a printer we will enable a server for the prints and select a server for the same. After that, this way we can print documents from ERPNext over a Wi-Fi connection. We will also enable the raw printing of documents here. We will be able to take prints along with barcodes with this setting. Lastly, we have the print style. By default, ERPNext has three styles, Classic, Monochrome or Modern. We will select the Modern style. Any document printed from ERPNext will be done in this style. We can also build a custom print style using CSS. With all the above settings we can ensure that any communication that goes from ERPNext speaks for my brand. Every document in ERPNext is printable and can be printed in the formats given.
Outro and resources
videos.