lampnick/doctron

Custom HTML

noelmathewisaac opened this issue · 6 comments

Is it possible to pass in custom HTML as a parameter instead of pointing to a URL?
I want to generate a pdf from HTML templates (using Jinja/Nunjucks)

Is it possible to pass in custom HTML as a parameter instead of pointing to a URL?
I want to generate a pdf from HTML templates (using Jinja/Nunjucks)

Do you want to use local file path?

Not local path. Instead of passing in URL, I wanted to pass in plain HTML directly?

Not local path. Instead of passing in URL, I wanted to pass in plain HTML directly?

Could you give me an example?

My use case is as follows:

Let's say I have an HTML template called sample.html

<html>
   <div class="container">
      <h1 class="title">
         {{ title  }}
      </h1>
      <h2 class="subtitle">
         {{ subtitle }}
      </h2>
   </div>
</html>

I want to use a templating engine like Jinja to pass in data to the template and generate the HTML
(render_template('sample.html', title = "Foo", subtitle="bar")) to get

<html>
   <div class="container">
      <h1 class="title">
         Foo
      </h1>
      <h2 class="subtitle">
         Bar
      </h2>
   </div>
</html>

Using this generated HTML, I want to create an image or pdf.

Is there a way to do this using Docton?

My use case is as follows:

Let's say I have an HTML template called sample.html

<html>
   <div class="container">
      <h1 class="title">
         {{ title  }}
      </h1>
      <h2 class="subtitle">
         {{ subtitle }}
      </h2>
   </div>
</html>

I want to use a templating engine like Jinja to pass in data to the template and generate the HTML
(render_template('sample.html', title = "Foo", subtitle="bar")) to get

<html>
   <div class="container">
      <h1 class="title">
         Foo
      </h1>
      <h2 class="subtitle">
         Bar
      </h2>
   </div>
</html>

Using this generated HTML, I want to create an image or pdf.

Is there a way to do this using Docton?

You may upload your generated html to your http server where the uri can reach by Doctron.

Doing this is tricky because Docton needs to fetch the HTML via a GET request. But passing in large amounts of data to an HTML template through a GET request is not easy/recommended.

It would be really useful to have an enhancement to pass in an HTML string directly. But thanks for your help!