Search code examples
cssdjango-templatesprincexml

Set string variable content in princexml


I'm using PrinceXML and Django Templates to generate a PDF. I'm able to set the content of a url but unable to set a string for the bottom left

@media print{
  @page { 
    @bottom-right {
      /* works */
      content: url({{ user.logo }})
    }
    @bottom-left {
      /* doesn't work */
      content: {{ user.uuid }};
    }
  }
}

Do you have to set the content differently for a string?


Solution

  • Put the template variable between double quotes like this :

    content: "{{ user.uuid }}";
    

    Django will only replace the template variable by its value. So if for example you have :

    user.uuid = "My unique id"
    

    Then

    content: {{ user.uuid }};

    will become

    content: My unique id;

    Which will not be interpreted as a string by PrinceXML