html to pdf, sometimes no images using my own java code

305 views
Skip to first unread message

rooswelt

unread,
Nov 3, 2009, 3:47:29 AM11/3/09
to JODConverter
I'm trying to convert an html page to pdf using my own code:

DocumentFormatRegistry registry = new DefaultDocumentFormatRegistry();
OfficeManager officeManager = new DefaultOfficeManagerConfiguration
().buildOfficeManager();
officeManager.start();
.....

OfficeDocumentConverter converter = new OfficeDocumentConverter
(officeManager, registry);
File inputFile = new File("c:/temp.htm");
File outputFile = new File("c:/output.pdf");
converter.convert(inputFile, outputFile);

temp.htm contains images that sometimes are missing in pdf.
I tried different size images but the problem seems not to be relatad
to image's size.

I found a discussion about lack of pages during html -> pdf conversion
here:
http://www.oooforum.org/forum/viewtopic.phtml?t=66772&postdays=0&postorder=asc&start=15&sid=841e5b7b19ad2fe7d8998e6c5e0085f0
could it be the same problem?

Mirko Nasato

unread,
Nov 3, 2009, 8:15:52 AM11/3/09
to jodcon...@googlegroups.com
Hi Marco,

There was this OOo issue but it's supposedly fixed now

http://qa.openoffice.org/issues/show_bug.cgi?id=81829

Kind regards

Mirko

2009/11/3 rooswelt <rosett...@gmail.com>:

rooswelt

unread,
Nov 3, 2009, 10:39:48 AM11/3/09
to JODConverter
I use office 3.1 and JODConverter 3.0 beta.
Should I open a new OOo issue?

On 3 Nov, 14:15, Mirko Nasato <mirko.nas...@gmail.com> wrote:
> Hi Marco,
>
> There was this OOo issue but it's supposedly fixed now
>
>  http://qa.openoffice.org/issues/show_bug.cgi?id=81829
>
> Kind regards
>
> Mirko
>
> 2009/11/3 rooswelt <rosetti.ma...@gmail.com>:
>
>
>
> > I'm trying to convert an html page to pdf using my own code:
>
> > DocumentFormatRegistry registry = new DefaultDocumentFormatRegistry();
> > OfficeManager officeManager = new DefaultOfficeManagerConfiguration
> > ().buildOfficeManager();
> > officeManager.start();
> > .....
>
> > OfficeDocumentConverter converter = new OfficeDocumentConverter
> > (officeManager, registry);
> > File inputFile = new File("c:/temp.htm");
> > File outputFile = new File("c:/output.pdf");
> > converter.convert(inputFile, outputFile);
>
> > temp.htm contains images that sometimes are missing in pdf.
> > I tried different size images but the problem seems not to be relatad
> > to image's size.
>
> > I found a discussion about lack of pages during html -> pdf conversion
> > here:
> >http://www.oooforum.org/forum/viewtopic.phtml?t=66772&postdays=0&post...

Mirko Nasato

unread,
Nov 3, 2009, 2:48:13 PM11/3/09
to jodcon...@googlegroups.com
I don't know if it's an OOo bug or not. Could be that images are
always loaded async'ly, like any web browser would do.

2009/11/3 rooswelt <rosett...@gmail.com>:

rooswelt

unread,
Nov 4, 2009, 3:19:21 AM11/4/09
to JODConverter
Ok, so looking forward, is there a way to tell JODC to wait start
conversion until all images have been downloaded?

Thanks

On 3 Nov, 20:48, Mirko Nasato <mirko.nas...@gmail.com> wrote:
> I don't know if it's an OOo bug or not. Could be that images are
> always loaded async'ly, like any web browser would do.
>
> 2009/11/3 rooswelt <rosetti.ma...@gmail.com>:

Mirko Nasato

unread,
Nov 4, 2009, 4:39:32 AM11/4/09
to jodcon...@googlegroups.com
I'm not aware of any way to be notified by OOo when all images have
been loaded. JODConverter does a refresh() on the document once
loaded, which should ensure it is ready. I'd need some time to
investigate this issue to give you a proper answer, but I don't have
it at the moment. You can open an issue and I'll look at it when I
have time, or you can investigate yourself.

To be honest, if I needed to convert HTML to PDF, personally I
wouldn't use OOo at all.

Kind regards

Mirko

2009/11/4 rooswelt <rosett...@gmail.com>:

rooswelt

unread,
Nov 6, 2009, 9:59:22 AM11/6/09
to JODConverter
I know that is not the best idea but my situation is a little more
complicated:
I have an xml file and an associated xlst transformation that produce
an HTML file, but what I need is a PDF file...so I decided to make it
in two steps:
1. xml -> html
2. html -> pdf

Have you got better ideas?
Do you know about something that produce an xsl for PDF starting from
an xsl for HTML?

Thanks a lot
Marco

On 4 Nov, 10:39, Mirko Nasato <mirko.nas...@gmail.com> wrote:
> I'm not aware of any way to be notified by OOo when all images have
> been loaded. JODConverter does a refresh() on the document once
> loaded, which should ensure it is ready. I'd need some time to
> investigate this issue to give you a proper answer, but I don't have
> it at the moment. You can open an issue and I'll look at it when I
> have time, or you can investigate yourself.
>
> To be honest, if I needed to convert HTML to PDF, personally I
> wouldn't use OOo at all.
>
> Kind regards
>
> Mirko
>
> 2009/11/4 rooswelt <rosetti.ma...@gmail.com>:

Mirko Nasato

unread,
Nov 7, 2009, 10:07:23 AM11/7/09
to jodcon...@googlegroups.com
Hi Marco,

I don't really know enough about your project to tell you what's the
best tool in your case.

For use with OOo the best option would be to generate OpenDocument -
which the native OOo format and is XML-based - rather than HTML.
JODReports is another project I started that generates OpenDocument
output using FreeMarker as the templating language.

Since you mention XML/XSL you may have a look at Apache FOP as well.

Or maybe the simplest option would be to keep HTML as the intermediate
format and find another way to convert HTML to PDF; there must be some
Java library out there that can do this without requiring OOo.

I've opened an issue to investigate the missing images problem anyway

http://code.google.com/p/jodconverter/issues/detail?id=58

Kind regards

Mirko

2009/11/6 rooswelt <rosett...@gmail.com>:

boderg

unread,
Nov 12, 2009, 7:26:24 PM11/12/09
to JODConverter
I think i have the same problem, but only with converting to .DOC
format, not to PDF.
With pdf, it works fine but also, i'm using FOP for converting html to
pdf.
I tried to play with image size and found, that it works only for
small images, that can be inserted without resizing.
And if the image is to big (for example- 1152*864) - after converting
to doc file, image is missing.

Using jodconverter version 2.2.2 and OO 3.1
Does anyone has some ideas?
Reply all
Reply to author
Forward
0 new messages