You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Yannick Pierson <pi...@gmail.com> on 2016/09/28 12:52:39 UTC

HTML to PDF

Hi,

I'm new to PDFBox and I would like to know if it is possible to create a
PDF file from HTML file and how to do it? Moreover is it possible to add a
css stylesheet for creating the PDF?

Thanks,

Regards.

Re: HTML to PDF

Posted by Yannick Pierson <pi...@gmail.com>.
Thanks!

openhtmltopdf seems to be a good choice. I quickly tryied it and it's easy
to use it. Moreover CSS running elements are working which is really useful
for creating header and footer.

Running elements example :
header {
display: block;
position: running(pageHeader);
}

footer {
div.page-num span:before {
content: counter(page);
}
display: block;
position: running(pageFooter);
}

@page {
margin: 100px;
@bottom-center {
content: element(pageFooter);
}
@top-center {
content: element(pageHeader);
}
}

2016-09-28 16:39 GMT+02:00 Evan Williams <ev...@zapprx.com>:

> For this purpose, most people I am aware of (including me) use Flying
> Saucer
> <https://github.com/flyingsaucerproject/flyingsaucer>, which does not use
> PDFBox but rather a very ancient version of iText. It has worked well for
> me but has definite quirks that I have had to work around and does not seem
> to be under very active development (please correct me if I am wrong).
>
> There is a project called OPEN HTML TO PDF
> <https://github.com/danfickle/openhtmltopdf> which is a fork of flying
> saucer that *DOES* use PDFBox 2.0.
>
> I am watching the project closely and plan to try it in my 'copious free
> time', but it looks very promising, and I would love to hear about people's
> experiences with it.
>
> On Wed, Sep 28, 2016 at 8:52 AM, Yannick Pierson <pi...@gmail.com>
> wrote:
>
> > Hi,
> >
> > I'm new to PDFBox and I would like to know if it is possible to create a
> > PDF file from HTML file and how to do it? Moreover is it possible to add
> a
> > css stylesheet for creating the PDF?
> >
> > Thanks,
> >
> > Regards.
> >
>
>
>
> --
> *Evan Williams*
> Sr. Software Engineer
> evan.williams@zapprx.com
>
> *www.ZappRx.com <http://www.zapprx.com/>*
>

Re: HTML to PDF

Posted by Evan Williams <ev...@zapprx.com>.
For this purpose, most people I am aware of (including me) use Flying Saucer
<https://github.com/flyingsaucerproject/flyingsaucer>, which does not use
PDFBox but rather a very ancient version of iText. It has worked well for
me but has definite quirks that I have had to work around and does not seem
to be under very active development (please correct me if I am wrong).

There is a project called OPEN HTML TO PDF
<https://github.com/danfickle/openhtmltopdf> which is a fork of flying
saucer that *DOES* use PDFBox 2.0.

I am watching the project closely and plan to try it in my 'copious free
time', but it looks very promising, and I would love to hear about people's
experiences with it.

On Wed, Sep 28, 2016 at 8:52 AM, Yannick Pierson <pi...@gmail.com> wrote:

> Hi,
>
> I'm new to PDFBox and I would like to know if it is possible to create a
> PDF file from HTML file and how to do it? Moreover is it possible to add a
> css stylesheet for creating the PDF?
>
> Thanks,
>
> Regards.
>



-- 
*Evan Williams*
Sr. Software Engineer
evan.williams@zapprx.com

*www.ZappRx.com <http://www.zapprx.com/>*