title: Creating pdf from html with xhtml2pdf
body: <p>I want to create a pdf report from an html file and I am running in to two problems. Allgnment and fonts</p>
  
  <p>For the first I have the following</p>
  
  <pre><code>&lt;style&gt;
  
      @font-face {
          font-family: "DejaVuSansMono";
          src: url("DejaVuSansMono-Bold.ttf");
          font-weight: bold;
      }
      @font-face {
          font-family: "DejaVuSansMono";
          src: url("DejaVuSansMono-Oblique.ttf");
          font-style: italic, oblique;
      }
      @font-face {
          font-family: "DejaVuSansMono";
          src: url("DejaVuSansMono-BoldOblique.ttf");
          font-weight: bold;
          font-style: italic, oblique;
      }
      @font-face {
          font-family: "DejaVuSansMono";
          src: url("DejaVuSansMono.ttf ");
      }
      .table {
          border: 1px solid black;
          background-color:#FCF0FB;
          text-align: center;
          padding-top: 3px;
      }
      @page {
          margin: 1cm;
          margin-bottom: 2.5cm;
          size: a4 portrait;
          margin-top:1cm;
          @frame header {
              -pdf-frame-content: headerContent;
              -pdf-frame-border:1cm;
              height:2cm;
              top: 2cm;
              margin-left:1cm;
              margin-right: 1cm;
          }
  
          @frame main {
              top:4cm;
              margin-left:1cm;
              margin-right:1cm;
              height:10cm;
              -pdf-frame-border: 1cm;
          }
  
          @frame footer {
              -pdf-frame-content: footerContent;
              -pdf-frame-border: 1cm;
              bottom: 2cm;
              margin-left: 1cm;
              margin-right: 1cm;
              height:1cm;
          }
      }
      *, html{
          font-family: "DejaVuSansMono";
          font-style:normal;
          font-size 10px;
  
      }
      .margin-10{
          margin-bottom:10;
      }
  &lt;/style&gt;
  
  
  &lt;div class="header" id="headerContent"&gt;
      &lt;h3&gt;Header content&lt;/h3&gt;
  
  &lt;/div&gt;
  &lt;div class="margin-10"&gt;&lt;/div&gt;
  &lt;div class="container"&gt;
      &lt;h3&gt;Today's appointments&lt;/h3&gt;
      &lt;table class="table"&gt;
          &lt;thead&gt;
              &lt;tr&gt;
                  &lt;th&gt;#&lt;/th&gt;
                  &lt;th&gt;Time&lt;/th&gt;
                  &lt;th&gt;Patient&lt;/th&gt;
                  &lt;th&gt;Comments&lt;/th&gt;
                  &lt;th&gt;Doctor&lt;/th&gt;
  
              &lt;/tr&gt;
          &lt;/thead&gt;
          &lt;tbody&gt;
              {%for doctor, entries in today.items%}
                  {%for entry in entries%}
                      &lt;tr&gt;
                          &lt;td&gt;{{forloop.counter}}&lt;/td&gt;
                          &lt;td&gt;{{entry.start|date:"H:i"}}&lt;/td&gt;
                          &lt;td&gt;{{entry.patient}}&lt;/td&gt;
                          &lt;td&gt;{{entry.comment}}&lt;/td&gt;
                          &lt;td&gt;{{entry.doctor}}&lt;/td&gt;
  
                      &lt;/tr&gt;
                  {%endfor%}
              {%endfor%}
          &lt;/tbody&gt;
      &lt;/table&gt;
  &lt;/div&gt;
  &lt;div class="footer" id="footerContent"&gt;
      &lt;p&gt;Για το Ιατρείο &lt;pdf:pagenumber&gt;&lt;/p&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I want to have a header some margin and then the footer. But the margin-10 class I created isn't adding any margin between header and html content </p>
  
  <p>In my footer I have a greek letter that is streesed greek letter. The letter won't appear normally but as a black square. I have added DejaVusans fonts in my media folders of my project, but still it won't work.</p>
  
  <p>The pdf creation code</p>
  
  <pre><code>path = os.path.abspath(os.path.join(MEDIA_ROOT, 'fonts'))
  print "Path: ", path
  def fetch_resources(uri, rel):
      path = os.path.abspath(os.path.join(rel, uri))
      print uri
      print "Path:", path
      print 'rel: ', rel
      return path
  
  def write_to_pdf(template, context_dict, filename=None):
      #template = Template(template_data)
      template = get_template(template)
      context = Context(context_dict)
      html = template.render(context)
      result = StringIO.StringIO()
      pdf = pisa.pisaDocument(StringIO.StringIO(html.encode("UTF-8")), result, path=path, encoding="UTF-8")
      if not pdf.err:
         response = http.HttpResponse(content_type='application/pdf')
          #response['Content-Disposition'] = 'attachment; filename=%s.pdf' % filename
          response.write(result.getvalue())
          return response
      return http.HttpResponse('Problem creating PDF: %s' % cgi.escape(html))
  </code></pre>
  
  <p>This is what is printed in terminal from the print statements above</p>
  
  <pre><code>DejaVuSansMono-Bold.ttf
  DejaVuSansMono-Oblique.ttf
  DejaVuSansMono-BoldOblique.ttf
  DejaVuSansMono.ttf 
  </code></pre>
  
  <p>That is it sees the fonts. What am I doing wrong?</p>