Jinja Template not working in Print Format

I have a custom Print Format with Jinja code that inserts some values of a custom Doctype into the fields of the custom Print Format (HTML fields).
When I switch to the print view in the custom Doctype, everything works correctly, the custom Print Format is displayed and the Jinja code retrieves the values in the custom Print Format, but when I press the Print/PDF button, the Jinja code does not it retrieves the values in the custom Print Format and I do not know why this happens.

follow below steps

  1. go to print format.
  2. write HTML code with jinja in HTML section.
  3. Save it.
    like this.

Many thanks for your help! @hari.kishor
I had been stuck with this for a long time and I needed to fix it.

Out of curiosity, what kind of problem does this configuration solve exactly?
Is it something related to ERPNext or any of your PY files?