Ejemplo n.º 1
0
 def pdf(self):
     return PDFStreamer(
         HTMLParser(self.generate, CSS("".join(self.css))),
         os.path.join(settings.MEDIA_ROOT,
                      self.letterhead.letterhead_pdf.name)
         if self.format == "email" else None,
     )
Ejemplo n.º 2
0
 def test_html_to_pdf(self):
     output = BytesIO()
     for chunk in PDFStreamer(HTMLParser(self.html, CSS(''))):
         output.write(chunk)
     pdf = PdfReader(fdata=output.getvalue())
     self.assertEqual(pdf['/Info']['/Producer'], '(bericht)')
     self.assertEqual(pdf['/Root']['/Pages']['/Count'], '3')
Ejemplo n.º 3
0
 def pdf(self):
     return PDFStreamer(
         HTMLParser(self.generate, CSS(self.css)),
         os.path.join(settings.MEDIA_ROOT,
                      self.letterhead.letterhead_pdf.name),
         "landscape",
     )
Ejemplo n.º 4
0
    So, for example, at Tesla, we’ve never spent any money on advertising. <br/>
    We’ve put all the money into R and D and manufacturing and design to try and make the car as good as possible. <br/>
    And, I think that’s the way to go. For any given company, keep thinking about, <br/>
    “Are, these efforts that people are expending, are they resulting in a better product or service?"<br/>
    And if they’re not, stop those efforts. <br/>
    And then the final thing is, is to sort of, don’t just follow the trend. <br/>
    So, you may have heard me say that it’s good to thinking terms of the physics approach, the first principles. <br/>
    With is, rather than reasoning by analogy, <br/>
    you boil things down to the most fundamental truths you can imagine, and then you reason up from there. <br/>
    And this is a good way to figure out if something really makes sense, or is it just what everybody else is doing. <br/>
    It’s <i>hard</i> to think that way, you can’t think that way about everything. <br/>
    It takes a lot of effort. But if you’re trying to do something new, it’s the best way to thing. <br/>
    And that frame<b>work</b> was developed by physicists to figure out counter intuitive things, like quantum mechanics. <br/>
    It’s really a powerful, powerful method. <br/>
    <br/>
    And anyways, so that’s, and then the final thing I would encourage you to do is now is the time to take risks. <br/>
    You don’t have kids, you’re obligations, well! Some of you… Hahaha, you probably don’t have kids. <br/>
    But as you get older, your obligations start to increase. <br/>
    So, and, once you have a family, you start taking risks not just for yourself, but for your family as well. <br/>
    It gets <i>harder</i> to do things that might not <b>work</b> out. So now is the time to do that. <br/>
    Before you have those obligations. So I would encourage you to take risks now, and to do something bold. <br/>
    You won’t regret it. Thank you....<br/>
    <br/>
    ...I don’t know if it was helpful. Great.<br/>
"""


with open('example.pdf', 'wb') as output:
    for page in PDFStreamer(HTMLParser(html, css)):
        output.write(page)