src tag for pdf in Thymeleaf - spring-boot

I'm working in Thymeleaf, I uploaded image using base64, but can't upload pdf documents using base64.
I'm wondering what will be the src value of pdf like images.
I already used image in Thymeleaf with base64 like this...
<img th:src="${'data:image/jpg;base64,' + image.profileImg}" alt="">
But I don't understand how to accept pdf src in base64. I tried like this
<iframe th:src="${'data:file/pdf;base64,' + myfile.profilePdf}" height="200" width="300"></iframe>
But it doesn't work...

Try this:
<iframe src="data:file/pdf;base64,myfile.profilePdf" height="200%" width="300%"></iframe>

Related

Sphinx doc: Process image directive to create HTML with base64 image data URI

When Sphinx compiles an RST file with image directive, it results in a HTML that has tag where the "src" attribute points to the image file.
Sample RST file
..image:: path/image.jpg
Resulting HTML
<img src='path/image.jpg'>
This means that the image is not contained within the HTML. The image file is a separate document from the HTML.
How can image directive be processed such that the resulting HTML has the tag with 'src' attribute containing base64 encoded image data as shown below
<img width="64" height="69" alt="Treehouse Logo" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABF...">
In the above example, the image data is embedded into the HTML. How can this be achieved?

cant use local image as src laravel-mix vuejs

I have a Vue component located at resources/js/modules/MyComponent.vue and inside it, I'm trying to use a local image as an src for the img tag, and the image is located at public/assets/myproj/image/myimage.png.
I've tried using the following :
<img src="#/assets/myproj/image/myimage.png"/>
<img src="require('assets/myproj/image/myimage.png')"/>
<img src="../../../public/assets/myproj/image/myimage.png"/>
<img src="/assets/myproj/image/myimage.png"/>
but none of them work...
I know this is a straightforward question but I hope someone can help me because I've been trying to find an answer for almost an hour now but I still can't figure it out.
If you want to use this in javascript you can do like this
<img :src='getImage(name)'/>
then you will need to import your image in your javascript code
getImage(name){
return require(`#/assets/myproj/${name}`);
}

How to display an ascii85 encoded picture

I try to display an ascii85 encoded image, like:
<img src='data:image/jpg;base85,...'/>
or
<img src='data:image/jpg;ascii85,...' />
I found several examples on base64 files, but nothing about ascii85...
What do you think?
Thanks
You can't do it because, as far as I know, only PostScript and PDF are able to handle ascii85 (base85). Browsers are only handling base64 for now.
If you already have data in this encoding you will need convert it to base64 before putting it into the browser.
It can be done with some javascript/typescript.
Have the code crawl the DOM
find img/#src attributes that is base85 encoded
write the code to decode base85 and re-encode it in base64
update the IMG src attribute back

How to display uploaded images in pdf using wkhtmltopdf

I am using Carrierwave to upload images in rails4.
In the html view page the image is showing. But, when generating the pdf, from this view, the image is not showing.Instead , a blank box is showing.
From the view, while inspecting the path is showing as below:
<img alt="Small images" src=" http://127.0.0.1:3000/upload_
files/6/student/image/1/small_images.jpg">
The code i used is:
<%=image_tag Student.find(id).image_url(:small) %>
If the image is stored in app/assets/images, then the images will appear.But, i need to upload the image in this location only.
Can u pls help...
Thanks in advance.
I could do it with php Laravel this way >>
<img alt="Small images" src="{{base_path().'path/to'image.jpg'}}">
I have no experiences with Ruby , but try to find something similar.

Exporting JSP data into excel with image

In our project we are having the requirement to export the JSP page into excel.
We cannot use Apache POI or any other open source APIs.
I came across the below mentioned simple way of doing
<%
response.setHeader("Content-Disposition",
"attachment;filename=\"mult-table.xls\"");
%> <%# page
contentType="application/vnd.ms-excel"
%> <table><tr><td> using image src to
load images </td></tr></table>
The excel is generated but the image is not shown in the excel.
In our JSP pages we are having many images which should also get exported into excel along with other data.hanks
Please let me know how to do it.
Thanks
Ravi
I use the complete URL in HTML image code, because when you download the excel, it's a text xls file, with format HTML, and the images embeddable and the absolute path, intead it can solve the image source.
like this:
<%
// Java CODE
...
String url=request.getRequestURL().toString(); // URL base page
String imageUrl=url.substring(0,url.indexOf(request.getRequestURI()))+"/images/logo.gif"; // image absolute url
...
%>
...
<!-- HTML CODE -->
...
<img src="<%=imageUrl%>" width="198" height="36" /></th>
...
As far as I know you can not insert an image in xls file, when this html xls

Resources