Create an entity print template

You can use the print templates functionality to create a PDF based on entity properties and relations, for example a PDF report of annotations made on an asset.

After your working folder has been initialized, it contains the following files:

RequestResponse
[working folder]
├── template.json
├── template.cshtml
├── template.css
├── template.csproj
├── lib
  ├── RazorLight.dll
  └── Stylelabs.M.Print.dll

This walkthrough describes how to:

Validate your entity print template

The validate command validates the formatting of the JSON file, the properties and relations described in the JSON file against the entity definition, and the variables used in the razor files.

You can run validate at any time, to be certain there are not errors in your print template.

To validate the entity print template, run the following command:

RequestResponse
ch-cli print validate -d <ENTITY_DEFINITION_NAME> -f <YOUR_FOLDER_PATH> 

Alternatively, do the following:

  1. In the Terminal menu, click Run Build Task.

  2. Select the Validate Entity Print Template task.

    CLI Print Template validate template task
  3. Enter the name of the entity definition.

    CLI Print Template entity definition task argument

Validation errors are shown in the Problems and Terminal views:

CLI Print Template problems view
CLI Print Template terminal view

Push your entity print template

After you have validated your template, you can push it from your working directory to the connected Content Hub instance.

Note

The push command runs the validate command before uploading the entity print template to the connected Content Hub instance.

To push your entity print template, run the following command:

RequestResponse
ch-cli print push -n <ENTITY_PRINT_TEMPLATE_NAME> -d <ENTITY_DEFINITION_NAME> -f <YOUR_FOLDER_PATH>

Alternatively, do the following:

  1. In the Terminal menu, click Run Task.

  2. Select the Push Entity Print Template task.

    CLI Print Template push template task
  3. Enter the name of the entity definition.

    CLI Print Template entity definition task argument
  4. Enter the name of the entity print template.

    CLI Print Template template name task argument

Generate your entity print template

To review the final PDF file, run the following command:

RequestResponse
ch-cli print generate -n <ENTITY_PRINT_TEMPLATE_NAME> -i <ENTITY_ID> -c <CULTURE>

Alternatively, do the following:

  1. In the Terminal menu, click Run Task.

  2. Select the Push Entity Print Template task.

    CLI Print Template generate template task
  3. Enter the name of the entity print template.

    CLI Print Template template name task argument
  4. Enter the ID of the entity.

    CLI Print Template entity id task argument
  5. Enter the culture.

    CLI Print Template culture task argument

From your browser, you can now open the downloaded PDF file.

Do you have some feedback for us?

If you have suggestions for improving this article,