Contact Us

Print templates in Sitecore Content Hub, are used to specify the structure of the PDF file using entity properties and relations. Using this, one can create a print template from the Print template management page which can then be easily accessed from the Manage page. The Print entity generation action is used to generate the PDF file based on the print template.

The Generate PDF operation can be configured in some page components such as the EntityOperations component. By calling this operation, the Print entity generation action is followed by the actual creation and generation of the desired PDF.

Follow the steps below to use Print Template to create PDFs based on entity properties and relations.

Step 1: Go to the Manage page and click to locate the Print Template.

Image 1

Step 2: Select the Print Template and click on the new ‘Print templates.’

Image 2

Step 3: In the New Print Template dialog box, enter the template name and select the target definition like Asset (M. Asset)

 Image 3

Note: The ‘target definition’ of the print template is the definition of the entities from which the PDF file is generated. For example, if the PDF file is structured to contain a list of Asset entities, the target definition would be Asset.

Step 4: Click on Create and then the ‘upload print template’ opens where you can select the zip file for the template.

Image 4

Step 5: Create a print template package zip file containing .cshtml, .json and .css files that define the structure of the PDF file.

Step 6: Below are examples of print template packages used with an entity named Module containing a list of related entities named Feature:

  • Module.json: This is the main file that specifies the module properties to use as well as any related entities (in this case, Feature entities).
  • Module.cshtml: This file specifies the structure of the defined Module properties in the PDF file using HTML format. This file can reference other .cshtml files to embed them within the structure.
  • Feature.cshtml: This file specifies the structure of the defined Feature properties in the PDF file using HTML format. This file can be embedded within other .cshtml files.
  • CSS file: This file specifies the CSS related to the .cshtml files.

 

Step 7: Below are the files along with their symbolic representations for reference:

  • Module.Json file

Image 5

  • Module.Cshtml file

Image 6

  • Feature.Cshtml file

Image 7

Step 8: Store all the files in a folder such as (Module.cshtml, Module.Json and Feature.Cshtml) and create a zip file.

Step 9: Upload the zip file and follow Step 4 once more.

Step 10: Once done, the Print template will be created and you can use it upon downloading the zip file.

Image 8

Image 9

Conclusion

This blog has outlined the importance of the Print Template functionality while elucidating the various steps involved in implementing it to generate PDFs. If you are keen on understanding how Sitecore can play a role in the context of your business, then reach out to us for consultation and implementation assistance from our team of certified Sitecore experts.

Need Help?