Render Html as Image - html

I have a page with a form and button called preview. I need a method to generate a preview, converting the generated HTML to an image.
Clicking on the preview button starts an ajax call to a controller action (I'm using Yii Framework), so I collected all the data from the form and generated a preview with the filled data.
I need to convert the generated HTML to an image; in this way I'm able to re-size to my needed dimension.
I've tried generating a .pdf on the fly and then generate the image from the pdf, and using mpdf extension and imagick. But imagick requires the pdf to be an existing file, while I prefer to generate a .pdf string with mpdf (I can't generate and delete a pdf for each click on preview button).
What is a good method to generate an image from html or from pdf string generated "on the fly"?
This is the code that I've used, but it return an error from imagick, saying image without dimension:
$html2pdf = Yii::app()->ePdf->mpdf('','A4');
$html2pdf->WriteHTML($this->render('preview', array("data" => $data, "imageProvider" => $arrayImage),true));
$content_PDF = $html2pdf->Output('', EYiiPdf::OUTPUT_TO_STRING);
$im = new Imagick();
$im->readImageBlob( $content_pdf );
//$im->setIteratorIndex(0);
$im->setResolution( 800, 600 );
$im->setImageFormat( "jpeg" );
header( "Content-Type: image/jpeg" );
echo $im->getImage();

You need to rethink the requirement to take HTML and generate an image file of it.
I need to convert the generated HTML to an image; in this way I'm able
to re-size to my needed dimension.
You can easily resize the dimension and all elements within a form using proper CSS. This is the route I would take.
Generating an image seems like overkill.

In order to use Imagick, you need to set the SIZE of the picture, not only the solutions:
Can you try something like this first and see what happens?
$thumb = new imagick("/path/".$filename);
$thumb->setImageFormat( "png" );
$thumb->thumbnailImage( 128, 128);

Related

Rendering a pdf file from an html view to display it on a web page as a image preview

I need to create a pdf preview that should be displayed on a web page as an image. The pdf file is just a simple report build on almost plain HTML. Essentially I had a problem with displaying checkboxes, now I replaced them with pics of checkboxes but the issue remains the same.
Here how I create the pdf report from my HTML view with help of groovy and grails:
def html = htmlRenderService.getReport(info)
ByteArrayOutputStream out = new ByteArrayOutputStream()
HtmlImageGenerator htmlImageGenerator = new HtmlImageGenerator()
htmlImageGenerator.loadHtml(html)
BufferedImage bi = htmlImageGenerator.bufferedImage
ImageIO.write(bi, "PNG", out)
byte[] bytes = out.toByteArray()
String base64bytes = encoder.encodeToString(bytes)
String src = "data:image/png;base64," + base64bytes
out.flush()
def getReport(Info info) {
return groovyPageRenderer.render(view: REPORT_VIEW,
model: [info: info])
}
Then I send the src string to my view and render it as:<img src="${src}" alt=""/>
Then my checkbox pic looks like this: <div style="/*style stuff*/ background-image: url(data:image/png;base64,LINK_TO_THE_IMAGE"></div>
In the end, I received a picture of my pdf report rendered pretty well displaying as an image on my page, BUT without checkboxes. Here is the picture of one part of it:
And here is the same part but from the pdf document which I rendered all the same way, but just downloaded directed from my webapp:
Here is an example where I combined both options(input checkbox and image checkbox) and rendered it as an image:
So what could cause this issue? Thank you in advance.
UPDATE: I came across today to this comment under another issue with HtmlImageGenerator:
HtmlImageGenerator seems to use a JEditorPane for rendering the HTML. Swing HTML support does not extend to the ability to render data images. It might be possible by digging into the HTMLEditorKit and changing the image loading element to support data images, but then you'd need to find a way to get HtmlImageGenerator to use the altered editor pane.
Seems that HtmlImageGenerator doesn't work well with images inside HTML files, but it's still unclear why it doesn't render checkbox inputs as well.
Without seeing the code you end up with after page load, check the chrome dev tools panel to see if the image has actually loaded correctly to the page which will tell you it's at least accessible to use. Then check if the url is output correctly to the div as the background-image. If it looks correct and there aren't related errors in the console, it is likely a css setting.
With background images, your container will need to contain content or else you will need to specify:
width
height
a display setting
background-position, and a
background-size
If you can upload more info, I might be able to be more specific.

Embed image in HTML r markdown document that can be shared

I have an R markdown document which is created using a shiny app, saved as a HTML. I have inserted a logo in the top right hand corner of the output, which has been done using the following code:
<script>
$(document).ready(function() {
$head = $('#header');
$head.prepend('<img src=\"FILEPATH/logo.png\" style=\"float: right;padding-right:10px;height:125px;width:250px\"/>')
});
</script>
However, when I save the HTML output and share the output, of course the user cannot see the logo since the code is trying to find a file path which will not exist on their computer.
So, my question is - is there a way to include the logo in the output without the use of file paths? Ideally I don't want to upload the image to the web, and change the source to a web address.
You can encode an image file to a data URI with knitr::image_uri. If you want to add it in your document, you can add the html code produced by the following command in your header instead of your script:
htmltools::img(src = knitr::image_uri("FILEPATH/logo.png"),
alt = 'logo',
style = 'float: right;padding-right:10px;height:125px;width:250px')

Convert Dynamic HTML to PDF

I am using jsp to display html and css3. When I display my html page, I will have a pdf icon, if that is clicked then I need to convert the html page to pdf and download it.
I have tried using XMLWorker, but there I need to send my html link through URL. But its saying this exception, "RuntimeWorkerException: Invalid nested tag head found, expected closing tag script.". I cant hard code my html.
Is there any easy way where I just click the button, so that all the html content from page can be downloaded as pdf? As I am new to programming I couldn't fix this issue. I went through other question but there were no clear explanation regarding this.
You can use jsPDF to convert HTML to PDF online, just using JavaScript on the client side.
The initialisation code is very simple:
// You'll need to make your image into a Data URL
// Use http://dataurl.net/#dataurlmaker
var imgData = 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4ge4SUNDX1BST0ZJTEUAAQEAAAeoYXBwbAIgAABtbnRyUkdCIFhZWiAH2QACABkACwAaAAthY3NwQVBQTAAAAABhcHBsAAAAAAAAAAAAAAAAAAAAAAAA9tYAAQAAAADTLWFwcGwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAtkZXNjAAABCAAAAG9kc2NtAAABeAAABWxjcHJ0AAAG5AAAADh3dHB0AAAHHAAAABRyWFlaAAAHMAAAABRnWFlaAAAHRAAAABRiWFlaAAAHWAAAABRyVFJDAAAHbAAAAA5jaGFkAAAHfAAAACxiVFJDAAAHbAAAAA5nVFJDAAAHbAAAAA5kZXNjAAAAAAAAABRHZW5lcmljIFJHQiBQcm9maWxlAAAAAAAAAAAAAAAUR2VuZXJpYyBSR0IgUHJvZmlsZQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAbWx1YwAAAAAAAAAeAAAADHNrU0sAAAAoAAABeGhySFIAAAAoAAABoGNhRVMAAAAkAAAByHB0QlIAAAAmAAAB7HVrVUEAAAAqAAACEmZyRlUAAAAoAAACPHp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AAEAAAH0AAAAAP/bAEMAAgEBAgEBAgIBAgICAgIDBQMDAwMDBgQEAwUHBgcHBwYGBgcICwkHCAoIBgYJDQkKCwsMDAwHCQ0ODQwOCwwMC//bAEMBAgICAwIDBQMDBQsIBggLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLC//AABEIAfQB9AMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1EQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/APzLooor+sD8nCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKK4z4yfFb/hWOl2zWUMVxe3jkRpISFVQOWOOepUfjXJj8dRy2hLE4h2hHf8vzNqFCeJqKnTV2zs6K+bm/aQ8VliReW4z2FsnH6VLaftL+KLaQNNLZXAB+7JbgA/98kGvjI+I+Vt2cZr5L/5I9l8OYpdY/e/8j6Morx3QP2sY3ZV8UaUyDPMltJu/wDHGx/6FXo/hX4jaL40Uf8ACPahBNKRnySdso/4Aea+iy7iTLc1ajh6ycuz0f3O1/lc87E5bicJrUg7d91+Bt0UUV7hwhRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRVLXPEVj4aszca/dwWkQ/ilcLn6DufpUVKkKUXObSS3b0Q4xc3aKuy7RXl3ib9qXStNneLw5Zz6jtBHms3lRk+2QSR+ArjdU/ah8Q3jn+zorCzXttjLt+bHH6dq+TxnHOUYNuKqObX8qv+OifyZ61HI8ZWV+Wy89Pw3PoOivm7/ho/wAV/wDP7B/4DJ/hXbfB/wDaBu/FPiC30nxbHbB7hWEdwgKF36gEdORkcY5xWWA48yzH144ePNFydlzJWu9lo3/kXXyHFYeDqOzS7P8A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5/wAaP+Gl/C//AD1vf/Ac/wCNYlr+z54LvmxZa7dzHGcJewMcfglXk/ZX8OSKGS+1lgeQRNEQf/Ide9TxPFNVXgqL9Hf9TglTyqPxOf8AXyNWP9ovwm7gNqEqA9zbSYH5LV62+N3hW6AMWs2wz/fV0/8AQgK5SX9lDSWX9zqeoq3qwRh+WBVG6/ZJjYf6FrrqeeHtA2fTkOMVf17iynvhacvR2/8AbxewymW1WS+X/wBqekR/Evw7KgZde0cA+t5GD+RNFeUP+ybqAc+Xq9mV7ExMD/Oij+3OI1vl6/ayaKTSluAUUUUwCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooA//2Q==';
var doc = new jsPDF();
doc.setFontSize(40);
doc.text(35, 25, "Octonyan loves jsPDF");
doc.addImage(imgData, 'JPEG', 15, 40, 180, 180);
This is a HTML5 client-side solution for generating PDFs.

How to display word file in popup windows using mvc 4 razor

I want make display word file in pop window using mvc 4 razor. the file has been taken from specific path and the file already stored in my project.
If you need a popup with smaller size than the full-screen window, you could try with some javascript:
fileDownloadLink variable is your download link, pointing to the Action method in your controller
The second and third arguments are explained in MDN reference for window.open function here MDN: Window.open
window.open(fileDownloadLink, 'insertPopupNameHere', 'width=400,height=400')
Otherwise you can just use an anchor tag with atribute target="_blank" (this will just open new tab in most browsers).
Preview File
The code for your action method:
//Insert your mime type here, if you know it
var fileType = "application/octet-stream";
if (inline)
{
var showInlineHeader = new System.Net.Mime.ContentDisposition
{
// for example foo.bak
FileName = result.FileName,
// always prompt the user for downloading, set to true if you want
// the browser to try to show the file inline
Inline = inline,
};
Response.AppendHeader("Content-Disposition", showInlineHeader.ToString());
return File(result.Content, fileType);
}
I have added to my method the if statement in order to directly download files that I don't want to be previewed.
Original answer for forcing preview if availabale, taken from Returning a file to View/Download in MVC

html is blank in a blackberry cascades webview (C++, QT, QML)

in Blackberry Cascades (C++, QT, QML), I am trying to read the html of a webview - but it is returning blank. This webview uses "setUrl(url") to set the url, and does not use "setHtml(html)". Anyway - I have this code:
WebView {
id: loginView
objectName: "loginView"
onMicroFocusChanged: {
console.log("html: " + html);
}
}
And the webview url has two textfields, and when I put my cursor into those text fields or when I type in them, the html of the webview shows up as blank - but I need to see the html, because I am trying to be able to parse that html to get the content of those textfields.
How come the html is blank - and how can I get access to this html?
The Html property of the WebView only returns the code that was inserted with setHtml. (Documentation)
Even if it did report code loaded from a web address, I doubt it would be updated with the current value of textboxes.
To read their content, I recommend you look into the messageReceived signal of the WebView. If you can change the html-code that contains your text boxes, you can use javascript navigator.cascades.postMessage() to send the data to your application.
If you do not control the html, you can still use the evaluateJavaScript method to extract the values of the textboxes with DOM functions from inside your app.