Converting HTML to PDF with images for a secure site - pdf-generation

Below is the HTML that I want to convert to a PDF.
Hi Hello how are you?
<p><img height="151" width="154" src="http://qa.openoffice.org/branding/images/bannerlogo.png" alt=""></p>
<p><img height="151" width="154" src="https://www.nprocure.com/nprocure_images/banner.jpg" alt=""></p>
I tried JODConverter, iText and some tools in the market to do so.
But the image for which the source is https doesnt get converted. The rest of the HTML does get converted.
Any clues on how we can embed the secure images in PDF?
I am looking for some java code snippets to do so.
Regards,
Tina Agrawal

The www.nprocure.com security certificate is not trusted. That could be the reason why the image is not converted.
Check out the Pdfcrowd HTML to PDF API for java: http://pdfcrowd.com/web-html-to-pdf-java/
You can test your HTML code online at pdfcrowd.com/#convert_by_input. The created PDF looks ok.

It sounds like the problem is the http client underneath the pdf libraries that you are using.
I would start off by abstracting the html resolution into it's own piece with something stand alone such as the apache http client. Once you get that going, you can hopefully plug in what you get from it into a PDF renderer and hopefully get what you need.
Good luck!

Related

How to convert jmeter dashboard report to pdf

How to convert jmeter dashboard report to pdf
I'm unable to convert html report to pdf. plz suggest me the solution
C'mon, have you done at least basic research before asking? There are a lot of options, for example:
Print it to file, all modern browsers allow saving web content as PDF, check out How to save a webpage as a PDF
There are online solutions like https://html2pdf.com/
There are offline solutions like http://www.pdflite.com/html-to-pdf/
There is BM.Sense online results analysis service which allows saving load test report as PDF
I tried many ways none of it works for Jmeter HTML report, other way was to zip all the artifacts and send over email but, that zip files contains .js files which get blocked by Gmail Yahoo
I written small code in Selenium to take screenshot (used Ashot API) of HTML report and sending over mail as attachment. Challenge here is headless mode of browser takes improper screenshot, so if you are on windows this can be achieved but as PNG, till now nothing works for PDF.

Convert emails to HTML or PDF programmatically

I'm trying to convert emails from my mailbox, into either HTML or PDF programatically.
My main motivation is to able to create summary of emails on a web page, and able to expand a particular email and view the entire content of the email.
I figured PDF might be an option since I do not have to worry about linking the contents in the email (eg. image) to the storage location of the image.
I'm starting with the ruby Mail gem and I also came across mhonarc. I'm not sure if mhonarc is a too much for what I'm trying to do, so I decided to ask here to see if there alternatives out there.
Gem pdfkit is used for generating PDFs. Please read readme, gem requires wkhtmltopdf library in your system.
I would approach email conversion via the IMAP library (there might be newer ones out by now) and then serve everything from a simple Sinatra app in the browser. You can use a template language to generate simple html output and logic. Of course you can also use prawn for pdf generation. Many different ways to get there... Not sure why you don't just load emails and show partial content. Life can be so simple.

Facebook can't scrape my page and linter tool says document returns no data

Can anybody tell me why Facebook doesn't scrape my page, and also the debug/linter tools cant scrape it? I've searched and searched and can't find a way to fix it.
As far as I can tell all the og:tags and scripts are implemented correctly.
The page is at http://www.coincident.dk
The debug url is this: http://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Fwww.coincident.dk
It looks to me like Facebook is scraping your page successfully, just not fully. Weird.
I would try moving the OG meta tags lower in the header. After your content-type meta tag at the very least.
These problems might be due to character encoding issues. If the Facebook scraper is relying on the content-type tag to know the encoding is UTF-8, they it might not be reading your OG tags correctly.
I hope that helps!

How to upload image to twitpic in bada

How to share images in twitpic. Social API in bada is not supporting twitpic. Is there another way for this? and what is meant by multipart form data?
By referring sample codes available in SDK we can upload image to server. The example code HTTPUpload with multipartFormdata helped to post the image to twitpic server.
You would need to write the protocol implementation yourself. I don't know it myself so I can't give you an exact answer but the bottom line is you should look at the sockets and web http namespaces, read the twitpic protocol for uploading and implement it... the hard way.
On the multipart side, look here http://en.wikipedia.org/wiki/MIME#Multipart_messages

Serving image using strange URL

Some website has images with strange URLs
For example below PNG image (Strange URL):
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAAAdCAYAAAA91+sfAAAAIElEQVRoge3BgQAAAADDoPlTX+AIVQEAAAAAAAAAABwDJF0AAcCDW58AAAAASUVORK5CYII=
What type of URL is this? and how this works in that website?
Thanks
data URI scheme
That's an embedded image whose binary contents were encoded by Base64 so that it fits in a "normal" String inside a HTML page. With other words, that's an embedded image. Also see this: http://www.w3.org/TR/xhtml-print/#s.4.1.2
However not all browsers do support it and it's also not really efficient. The image is now tied to the parent (X)HTML page and you cannot control its request nor (caching) headers separately. It's only useful when transferring images or any other binary data through real XML files.
Like everyone mentioned, it is data URL scheme. It was detailed in RFC 2397 back in 1998 and follows the following syntax:
data:[<mediatype>[;base64],<data>
IE 5 - 7 do not support it, other standard-compliant browsers such as Firefox, Safari, Opera and Chrome do support data URIs. Work arounds are available for older versions such as IE.
Just a side note, you can generate it with one line of PHP :
<?php echo base64_encode(file_get_contents("yourimage.gif")); ?>
It appears you are looking at a URI specified using the data URI scheme.
In this case I believe the PNG data is encoded directly into the URI.

Resources