allcolor / YaHP-Converter

YaHP is a Java library that allows you to convert an HTML document into a PDF document.
GNU Lesser General Public License v2.1
56 stars 23 forks source link

Not showing image in pdf #6

Closed janakjoshi closed 11 years ago

janakjoshi commented 11 years ago

HI, I am using yahp library, generating PDF from HTML I can see image in HTML but Not showing image in pdf.

allcolor commented 11 years ago

Hi,

do you correctly set the base url of your image ? If yes, could you try by setting an absolute url to your images ?

Like

or

Regards, Quentin

2013/1/23 janakjoshi notifications@github.com

HI, I am using yahp library, generating PDF from HTML I can see image in HTML but Not showing image in pdf.

— Reply to this email directly or view it on GitHubhttps://github.com/allcolor/YaHP-Converter/issues/6.

All those moments will be lost in time, like tears in rain.

janakjoshi commented 11 years ago

hi, thanks for reply my HTML has this image tag & image is there in location. < img src="D:/sanitize/logo.JPG" border="0" height="70"width="200" />

Following is my java Code

        CYaHPConverter converter = new CYaHPConverter();
        FileOutputStream out = new FileOutputStream(new File("D:/sanitize/x.pdf"));
        Map properties = new HashMap();
        List headerFooterList = new ArrayList();
        properties.put(IHtmlToPdfTransformer.PDF_RENDERER_CLASS,
                IHtmlToPdfTransformer.DEFAULT_PDF_RENDERER);

        converter.convertToPdf(strHtml,
            IHtmlToPdfTransformer.A4P, headerFooterList, "file://c:/temp/", out,
            properties);
        out.flush();
        out.close();
allcolor commented 11 years ago

Hi, your src is not correct.... an URL must have a protocol, in your case you should have:

<img src="file:///D:/sanitize/logo.JPG" border="0" height="70"width="200" />

Regard, Quentin

2013/1/23 janakjoshi notifications@github.com

hi, thanks for reply my HTML has this image tag & image is there in location. < img src="D:/sanitize/logo.JPG" border="0" height="70"width="200" />

— Reply to this email directly or view it on GitHubhttps://github.com/allcolor/YaHP-Converter/issues/6#issuecomment-12586089.

All those moments will be lost in time, like tears in rain.

janakjoshi commented 11 years ago

Hey , Thanks a lot. its worked. Thank you very much.

pankz709 commented 10 years ago

Hi,

Converte is working fine for me except the image is not coming into the pdf.

In my Source code image is is in base 64 format like this img name="digTechSigIMG" src="data:image/gif;base64.....

While generating the pdf image is not coming.

Please help !!

allcolor commented 10 years ago

Image in base64 are not supported. You have to use images in files... The url pointing to the image can be relative to the base url given to the convert function or an absolute url. (can be any URL supported by java, ie: file:// http:// etc)

Regards, Quentin

2014/1/3 pankz709 notifications@github.com

Hi,

Converte is working fine for me except the image is not coming into the pdf.

In my Source code image is is in base 64 format like this img name="digTechSigIMG" src="data:image/gif;base64.....

While generating the pdf image is not coming.

Please help !!

— Reply to this email directly or view it on GitHubhttps://github.com/allcolor/YaHP-Converter/issues/6#issuecomment-31519314 .

All those moments will be lost in time, like tears in rain. (Roy Batty/Rutger Hauer)

milkdeliver commented 9 years ago

img with url can't not be included in the pdf.Could you give me a suggestion?

<img src="http://www.zenefits.com/static/marketing/img/carriers/img.jpg" alt="Capture.jpg">
allcolor commented 9 years ago

It does work, make sure you can display it locally. Download it and replace with a local file:/// link.

Regards Le 16 juil. 2015 16:20, "Sam" notifications@github.com a écrit :

img with url can't not be included in the pdf.Could you give me a suggestion?

<img src="http://www.zenefits.com/static/marketing/img/carriers/img.jpg" alt="Capture.jpg">

— Reply to this email directly or view it on GitHub.

milkdeliver commented 9 years ago

Does it only convert local resources?

allcolor commented 9 years ago

No, but it has to have access to the resource, if the remote server check for a specific user agent or a cookie it might not work. If it work locally and not with the remote server, that means the server does not return the image or does not return the correct mimetype.

Regards Le 16 juil. 2015 16:48, "Sam" notifications@github.com a écrit :

Does it only convert local resources?

— Reply to this email directly or view it on GitHub https://github.com/allcolor/YaHP-Converter/issues/6#issuecomment-121962157 .

milkdeliver commented 9 years ago

Now the problem still raise.Could you give me a clue?

allcolor commented 9 years ago

So as I say, does it work with a file url with the same image? If it does then either the remote server does not return an image mimetype in the content-type http header, or the server does not return the image if a certain cookie is not present, or the server does not return the image if a certain user agent is not used, or the server takes too long to send it and there is a timeout.

That a browser is able to display it is irrelevant. First ensure it does work locally, then if it does, try to download the image in java, using a java Url object.

Regards Le 17 juil. 2015 09:54, "Sam" notifications@github.com a écrit :

Now the problem still raise.Could you give me a clue?

— Reply to this email directly or view it on GitHub https://github.com/allcolor/YaHP-Converter/issues/6#issuecomment-122198338 .

sayhello2ashutosh commented 8 years ago

YAHP api is taking 30-45 seconds to generate PDF first time. After that it is taking less time to generate pdf. Any clue or any help Why it is taking too much time first time.

allcolor commented 8 years ago

Class loading occurs the first time, but again you should not use the builtin classloader inside an application server.

Just put the following jar in the WEB-INF/lib:

https://bintray.com/artifact/download/allcolor/alc-web/org/allcolor/shaniparser/1.4.22/shaniparser-1.4.22.jar https://bintray.com/artifact/download/allcolor/alc-web/org/allcolor/shaniparser-xmlapi/1.4.22/shaniparser-xmlapi-1.4.22.jar https://bintray.com/artifact/download/allcolor/alc-web/org/allcolor/yahp/1.3a/yahp-1.3a.jar https://bintray.com/artifact/download/allcolor/alc-web/org/allcolor/yahp-core-renderer/1.3/yahp-core-renderer-1.3.jar https://bintray.com/artifact/download/allcolor/alc-web/org/allcolor/yahp-internal/1.3/yahp-internal-1.3.jar https://bintray.com/artifact/download/allcolor/alc-web/org/allcolor/yahp-itext/1.3/yahp-itext-1.3.jar https://bintray.com/artifact/download/allcolor/alc-web/org/allcolor/yahp-tidy/1.3/yahp-tidy-1.3.jar http://central.maven.org/maven2/jaxen/jaxen/1.1.6/jaxen-1.1.6.jar

This version does not use anymore the classloader. Just put an instance of CYaHPConverter in the servletcontext, and share it. The class is threadsafe.

Regards

2016-03-30 8:44 GMT+02:00 sayhello2ashutosh notifications@github.com:

YAHP api is taking 30-45 seconds to generate PDF first time. After that it is taking less time to generate pdf. Any clue or any help ahy it is taking too much time first time.

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/allcolor/YaHP-Converter/issues/6#issuecomment-203277356

All those moments will be lost in time, like tears in rain. (Roy Batty/Rutger Hauer)

sayhello2ashutosh commented 8 years ago

Thanks!..will load with above jars and let you know..if it is working fine or not.

sayhello2ashutosh commented 8 years ago

I have html content having data in hindi/chineese, but when i am trying to generate pdf through YAHP, generated pdf shows only english content and hindi/chineese content get disappeared.

i have set http response's content type to utf-8 but it didn't work. Any help on this will be appreciated.

allcolor commented 8 years ago

Hi, you have to use a unicode font like arial unicode and embed it. Regards

Le 23 août 2016 21:57, "sayhello2ashutosh" notifications@github.com a écrit :

I have html content having data in hindi/chineese, but when i am trying to generate pdf through YAHP, generated pdf shows only english content and hindi/chineese content for disappeared.

i have set http response's content type to utf-8 but it didn't work. Any help on this will be appreciated.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/allcolor/YaHP-Converter/issues/6#issuecomment-241856747, or mute the thread https://github.com/notifications/unsubscribe-auth/ABJ5B_GsUVhcMVig44Ue7c-ztp1r84Uyks5qi1CagaJpZM4AYO_j .

arunzz commented 8 years ago

Image inside a table td is not coming up in pdf. If its outside its coming up , pls help.