Closed derrick2012 closed 10 years ago
Could you send me your html ? (as html, not an image)
Thank you
2013/6/6 derrick2012 notifications@github.com
Hi there,
I used YaHP-Converter to convert the following HTML to PDF but I found the style colour green was not showing.
[image: styletest]https://f.cloud.github.com/assets/2483552/617515/302e7f8c-ce97-11e2-8993-9f44fcc014b1.png
Here is my jsp code:
File htmlIn = new File(filename); Scanner scanner = new Scanner(htmlIn).useDelimiter("\\Z"); String htmlContents = scanner.next(); CYaHPConverter converter = new CYaHPConverter(); Map properties = new HashMap(); List headerFooterList = new ArrayList(); properties.put(IHtmlToPdfTransformer.PDF_RENDERER_CLASS, IHtmlToPdfTransformer.FLYINGSAUCER_PDF_RENDERER); OutputStream os = response.getOutputStream(); response.reset(); response.setContentType("application/pdf"); String[] fname = filename.split("\\\\"); if (fname[0].equals(filename)) { fname = filename.split("/"); } response.setHeader("Content-Disposition", "attachment; filename= \""+fname[fname.length-1]+".pdf\""); converter.convertToPdf(htmlContents, IHtmlToPdfTransformer.A4P, headerFooterList, "file:///temp/html/", os, properties); response.flushBuffer();
Please let me know if I did anything wrong. Thanks a lot!
— Reply to this email directly or view it on GitHubhttps://github.com/allcolor/YaHP-Converter/issues/8 .
All those moments will be lost in time, like tears in rain.
I do not know how to attach the file as html. Here is the html content:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Hi,
I've done a test here and all is working as expected.
I've attached the resulting PDF and html.
2013/6/7 derrick2012 notifications@github.com
I do not know how to attach the file as html. Here is the html content:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Example To Convert HTML File with Images to PDF Using Java iText b { color: green; }
Transform HTML document with Pictures We have converted a HTML File with Images to PDF document Using Java!!
Let us add an image to the HTML Document
— Reply to this email directly or view it on GitHubhttps://github.com/allcolor/YaHP-Converter/issues/8#issuecomment-19084185 .
All those moments will be lost in time, like tears in rain.
Well the attachment did not pass. So here is the html: http://www.allcolor.org/test.html and the resulting pdf: http://www.allcolor.org/test.pdf
Hmm... no I've found a problem... in fact in the html I've forgotten to close the style tag and then it did work. If I correctly close it, it doesn't. I'm looking into the problem now.
Thank you so much for your help!
Ok, the thing is all b tag are replaced by strong tag by the validator.
So ==> <style type="text/css"> b,strong { color : green; } </style>
To avoid any problem, it is best to use class (or id) instead of directly stiling a tag type.
Do you know why tag
would add extra page break in the PDF? When I used flying saucer to convert the same html, it did not add extra page break in the PDF.
Do you know why tag "< br />" would add extra page break in the PDF? When I used flying saucer to convert the same html, it did not add extra page break in the PDF.
a br where ? Have you an example of that ? and a page break ?? br doesn't do a page break.
Please take a look at my HTML image file above, there is a br tag in the 12th line, just after the line "We have converted a HTML File with Images to PDF document Using Java!!".
Ok.. and what happen at this br tag ?
This tag caused an extra page break in the PDF using YaHP to convert. However, when I used flying saucer to convert, it did not have this extra page break. I am just curious what caused this difference.
I've done what you asked here: So here is the html: http://www.allcolor.org/test.html and the resulting pdf: http://www.allcolor.org/test.pdf
I don't see the problem.
Well, could you try again using the following image please?
It's because of the size of the image, not the <br/> tag.
Size it to fit the page and all works well as you can see in the sample here:
http://www.allcolor.org/test.pdf http://www.allcolor.org/test.html
2013/6/7 derrick2012 notifications@github.com
Well, could you try again using the following image please? [image: marbles]https://f.cloud.github.com/assets/2483552/624119/c800977e-cf7c-11e2-9895-861a81955219.png
— Reply to this email directly or view it on GitHubhttps://github.com/allcolor/YaHP-Converter/issues/8#issuecomment-19109479 .
All those moments will be lost in time, like tears in rain.
just wonder why it does not behave the same like flying saucer. is it because flying saucer has a different page size setting?
Maybe, or that you don't use the same version... Don't know. but your image doesn't fit in a page (it's 35 cm high). Also yahp by default (if not changed) add a 1cm margin, so you really only have 27 cm high. It tries not to cut in the middle.. so it puts the image on the second page.
You shoud use styling to set a correct size to fit in the page.
Regards, Quentin
2013/6/7 derrick2012 notifications@github.com
just wonder why it does not behave the same like flying saucer. is it because flying saucer has a different page size setting?
— Reply to this email directly or view it on GitHubhttps://github.com/allcolor/YaHP-Converter/issues/8#issuecomment-19110690 .
All those moments will be lost in time, like tears in rain.
I guess it's probably due to the margin setting. Anyway, thanks a lot for your help!
Hi there,
I used YaHP-Converter to convert the following HTML to PDF but I found the style colour green was not showing.
Here is my jsp code:
Please let me know if I did anything wrong. Thanks a lot!