Java agent to display dynamically generated graphic? - java

In Lotus Notes, I have a document that contains a PPT file attachment. Using Apache POI, I was planning to generate an image from a specific slide from that PPT and display it on the web browser by accessing the agent from the web probably with the use of Ajax. Is there a way to temporarily store the generated image and display it? If yes, how would you be able to do it?

You could achieve this even without saving the attachment by encoding it Base64 and embedding it in the source-code like this:
<img src="data:image/gif;base64,
R0lGODlhmwDFAPcAAAAAAAEBAQICAgMDAwQEBAUFBQYGBgcHBwgICAkJCQoKCgsLCwwMDA0N
DQ4ODg8PDxAQEBERERISEhMTExQUFBUVFRYWFhcXFxgYGBkZGRoaGhsbGxwcHB0dHR4eHh8f
HyAgICEhISIiIiMjIyQkJCUlJSYmJicnJygoKCkpKSoqKisrKywsLC0tLS4uLi8vLzAwMDEx
MTIyMjMzMzQ0NDU1NTY2Njc3Nzg4ODk5OTo6Ojs7Ozw8PD09PT4+Pj8/P0BAQEFBQUJCQkND
.... Lot of ascii characters ....
gww18FBEikHcgNkMRW5lmkJI/teaa0wNiOhshFFuiRSVpL34nqQRphZmcV5miORZQwnRpndI
nUmiiTStuaKbLl4Z45wuuADDDDfsgNKeMmy160w1hdaVSZfupyiXSgLoWpOQFjgpWUsKCGem
CEXFlIRlBefllxqKKlyblb45olWqosgmi29iGiudM+6Knp5F6LhrDYYCccQRQuzQp1cBAQA7">
If you need to store it, you could store it to a temp- folder and then attach it to a document. Then you could easily show it using an img- tag with src- url http://server/db.nsf/_/documentuniqueidOfSavedDocument/$File/nameOfImage.jpg

Related

exporting the webpage content to pdf and excel format

In my application i have a webpage created for the user, which display the content from the mysql workbench in the tabular format. this application is created using spring mvc(eclipse ide). in this page i have created a export button, on click of this button the contents present the table will be exported to pdf or excel format and the generated file should be downloaded to the download folder.
Can anyone help with:
extract these table content
export the content to pdf/excel(xls)
download of the file on click of the button.
I am totally confused how do i start with it. any reference for how to read the webpage content and proceed with this will be helpful.
Not exactly sure of what you want to do, but to extract a website content is easy with Jsoup, it is a great html parsing library and can be downloaded here. To produce excel file you could use a library developed by Apache - Apache POI. A tutorial on how to do this can be found here.
Here is what I think you can do-
Since you are displaying the contents in a webpage, you already have an API that fetches the data from the data source. You can utilize the same API for getting the data. You would then need to turn that data into a CSV format. On top of this you can have a little REST service that serves contents of type text/csv. Your download button in the UI can invoke this REST to get the CSV file downloaded. Hope this helps.

Display PDF in browser

I am developing a Java Web Application (jsp/servlet) using tomcat. I need to display pdf file from local machine. can you suggest what is best way to display it?
I used iframe to display pdf file.
<iframe src="resume.pdf" width="100%" style="height:60em">
[Your browser does <em>not</em> support <code>iframe</code>,
or has been configured not to display inline frames.
You can access the document
via a link though.]
</iframe>
I think you can try a Library called XPDF , I think you can convert from PDF to HTML page , or the second option is just let the user open a link to the page (www.yourwebsite.com/pdffolder/somepdf.pdf)
If you need display a pdf file using tomcat, you can access directly to the file using the specific url where the file is located in your navigator, depending on the path where you put the file, so you can access using 127.0.0.1/files/test.pdf for example. If you need generate a pdf, the best tool I think is iText, this is an easy example how to use id: Introducing PDF and iText

Exporting svg with foreignObject tag as an Image using PHP or Java

Is there a way to export an <svg> tag containing <foreignObject> as an Image using PHP or Java? I have tried https://github.com/sampula/SVG.toDataURL but it does not support foreignObject.
The only reason I want to be able to encode the foreignObject as to base64 is because that the foreignObject tag contains some HTML and an image inside.
Is there anyway to do this?
Old question but, yes I've successfully done it using phantomjs

Generation of pdf file using java

I am developing a standalone application in Java. I want to generate a pdf file using Java code. I have a display form in which all the details are fetched from database and displayed in the window. Details are Customer Name, Order Details etc.
Now I want to have a button there which says Convert to pdf.
I want to convert this to pdf file with proper alignment and formatting like tables, font etc.
What can be an ideal way to go about it?
I'd suggest you to use reporting tool like a jasperreports.
JasperReports is entirely written in
Java and it is able to use data coming
from any kind of data source and
produce pixel-perfect documents that
can be viewed, printed or exported in
a variety of document formats
including HTML, PDF, Excel, OpenOffice
and Word.
Have a look at other open source projects (pdf api):
Apache PDFBox
Apache Tika (Toolkit for detecting and extracting metadata and structured text content from various documents using POI and PDFBOX parser libs.)
PDFjet
Use iText:
http://itextpdf.com/

Show PDF file inside web browser with iText

I developed a report (without and independent of any db datasource) only with iText. I know that with JasperReports this is easy. But in my case I just storage the report in pdf file or I used acrobat for java beans to show the report to user. Now I need to change my implementation code to show this report in web browser instead to save in the file.
How I can do this?
You need 2 thinks, first the browser plugin installed on the browser and second to set the content disposition header as inline in the respose, otherwise the browser will try to download it.
response.setHeader("Content-Disposition","inline; filename=\"file.pdf\"");
I assume that you've already set the Content Type to application/pdf and know how to convert an iText document to a bytearray and transmit it to the user.
A word of caution: if people outside your organization will use this app, the might not have the pdf plugin installed, in which case, the browse will download the pdf instead of displaying the pdf.
if the browser has the appropriate add-on installed, you can just drag and drop a pdf-file into the browser and it will show it.
Or if you have a site on which you want to present the pdf, you just put a link to it:
link to your pdf
Or did you mean you want to generate html-output for your report instead of pdf?

Categories

Resources