Convert multiple files into PDF - java

My questions is rather theoretical. I need to implement an application that takes different file extensions such as [asp,bmp,doc,docx,html,jpg,pdf,pdf,png,pptx,sql,txt,xls,xlsx] and converts them all into a consecutive PDF file for print.
I did my research in terms of coding and found multiple libraries that do the job
such as Apache POI, iText, aspose.pdf.jar and others I tested them out on individual portions of the idea. They work great but require a lot of women-hours to implement the desired application. My question is, is there anything more complete that will speed up the job. For example a library such as apache POI that does not require specifying every single padding and background color.
Any suggestions are appreciated.

As per my knowledge and experience not a single API is present there who provide all solution without this. Because of that we need to use Apache POI, iText, aspose.pdf.jar , FOP.
In java(using jquery as per my knowledge) you are able take snapshot of rendered page using stream which you will need to proceed at serverside and generate PDF which generate pdf file same like html page without any extra formatting but it having limitation that you can't use landscape. If page data is big then it shrinks pdf which causes small font(in very large page even you unable to read pdf).

Related

Java utility for printing PDF

I'm making a utility to grammatically making a document and printing it.
I am gonna apologize, I'm not good at formulating this and there may be some confusion, please bare over with me :(
This project is mostly for making a user friendly utility for creating documents in your program and printing it and also as a learning experience.
It uses objects which I will convert to MarkDown as its easy to work with, I convert it to HTML as its going to be used in a web form.
The problem occurs when I want the program to print this HTML file that i have now created to a PDF.
I've searched for a solution for a very long time but have yet to find results, all that I've found was either out of date, filled with bugs or just could not do what I wanted.
I have tried iText as that seems to be the most popular choice but as stated above, everything I found was out of date and no longer useful, mostly because the classes they speak of do no longer exist.
What I do want is eventually independence of other libraries so that is my ultimate goal, but for now I want a way to print a locally stored HTML file as a PDF, it needs to be CSS compatible.
As an extra thing if anyone could point me in the direction of learning how to make MarkDown to HTML and printing HTML to PDF I would be more than happy.
Edit 1:
Stephan C pointet the question is too wide and difficult to answer, I will try to explain:
Main thing I want is to print a PDF file using an HTML file and CSS which is stored locally.
Optional solutions is I would love to learn how to code this myself instead of implementing libraries, for example markdown4j and iText. Yes I know that's a lot to take on, but as stated this is a learning experience for me.
Have a look at Converting HTML files to PDF. It has sample code for using with iText and also other suggestions. If you run into problems with approach suggested post specifics here. Either modify your original question or ask new question.
Printing directly from HTML to pdf can be also worse than using iText or other libraries.
I just made some iText PDF not using low level pdf classes but compiling a PDF form from it.
If you need to fill a PDF form, you can use iText as following.
Make your html form a PDF form. (acrobat or other free softwares)
Use iText classes AcroFields to get the PDF form fields (you get them by names or you can return a map of fields using AcroFields.getFields();
Compile the required informations using AcroFields.setFields() or .setField();
PdfReader class allow you to open an existing PDF (the template)
PdfStamper allow you to write the stream to another one (the result)
Adding images and other binary stuff is really easy!
By this way, you can do it quickly and layouts will be fast and good too.
The limit is that you need as many template as many data you need. (if you have fields that is some cases are many in other just one, you need twice templates).
For a static number of fields is a good solution.
Hope it helps.

library to bring a pdf to code

I have the need to create some pdf through java code, pdf templates are fixed and are very complex too. Each pdf represents a module and I have to fill it with informations I get from other sources in my application and finally create the complete pdf.
So, is there a library which, given a pdf, scans it and creats some java code which will eventually create it back? This way once I get the pdf template in java code I just have to edit it adding my informations and create it back.
You can check these 2 link it's have all information regarding PDF CRUD operation.
How to read PDF files using Java?
http://mrbool.com/how-to-create-write-and-read-pdf-files-using-pdfone-and-java/27058
I have used with success iText http://itextpdf.com/ for various tasks involving creating, parsing and modifying pdf files. Please not that this one is not free for commercial use and the pricing isn't cheap either.
However, your question is a possible duplicate of the folowing one, so be sure to check the answers there:
https://stackoverflow.com/questions/6118635/what-is-the-best-pdf-open-source-library-for-java
itext is one of best approach for your need..
itext API'S

PDF manipulation with placeholders

I am looking for a Java tool that can manipulate an existing PDF containing placeholders like ${foo}. I want to generate mail merge documents from that.
I found a lot of solutions with forms but this seems not suitable for me. Currently I generate the PDF with iText but this is a really annoying task to convert existing Word files or similar. I didn't find another solution with iText so far.
I also used JODReports in conjunction with JODConverter but it is necessary to run OpenOffice as a service and the performance is bad.

How can I merge individual selected PDF files into one PDF upon download?

How can I merge individual selected PDF files into one PDF upon download?
I want to achieve the following:
http://annualreport2010.landsecurities.com/create-your-own-report.aspx
Do I require an ASP website, or could I do something similar using a static HTML site?
Static HTML won't do it.
You need something on the server side. The other answers have options that would work, I just wanted to also mention pdftk, which you could then call from the server side. Be sure to escape all file names and such, though, because you would have to use system calls.
pdftk is really easy. The very first example from their documentation shows how to merge several PDFs, named 1.pdf, 2.pdf and 3.pdf, into one PDF called 123.pdf:
pdftk 1.pdf 2.pdf 3.pdf cat output 123.pdf
For PHP, there even is pdftk-php, if you want to look into that.
I think that the Apache PDFBox project can be good for you.
In particular, take a look at the PDFMerger class.
You can also use iText but in my opinion it's less easy to use.
See if itext can help in merging. A quick search gives many links - like Java: Merging multiple PDFs into a single PDF using iText.
There is a Java PDF merging software at http://codesforus.blogspot.com/.
p.s. They link to this download page: http://messiahpsychoanalyst.org/Documents/Downloads.html#part1
You can find Source code for PDF split and Merge Source forge PDF SAM

Generate PowerPoint 2007/2010 file using Java

Does anyone know of any API (commercial or open-source) that can generate/edit PowerPoint 2007/2010 presentations through Java. I have a template in the PowerPoint 2007/2010 format that I require to edit/update. So far I have been converting the .pptx file to xml and then editing and storing it back as .pptx. But the file gets corrupted while opening.
Is anyone aware of any other method or API that do this in Java?
We have done it programmatically (closed source at the moment, sorry) so might be able to help, but beware of a few gotchas.
One is that the POI project (at least when we looked at it last year), was quite incomplete. It didn't do PPTX Charts - which is the one feature we wanted. Infact the POI site may not be upto date, but they don't appear to support PowerPoint 20087 format (http://poi.apache.org/slideshow/index.html). Everybody recommends this project, but our evaluation was that it was pretty much useless for generating PowerPoint 2007 files via Java. Your milage may vary.
Apose also had some significant limitations when we looked at it; not doing Charts in PowerPoint 2007 being the blocking issue for us.
Another issue is that PowerPoint 2007 can be quite buggy. We have had a number of progammatically produced PPT files that caused lock ups, but when testing, we found that we can repro crashes and lock ups with simple PPTX documents created in PowerPoint 2007 - i.e. not our code.
In the end, we did the following: Unpacked a 'template' PowerPoint file to a folder, then on demand, filled the template XML with new values, zipped it up, renaming various elements & delivered it to the user as a valid PPTX. Works OK, other than the odd PowerPoint crash when people edit the file. If there was a market for it, I guess we could package up the code as a webservice (i.e xml/csv -> PPTX) or put together a commerical package, but we wouldn't do it for free.
docx4j (apache license) now includes a pptx4j component, which can open/edit/save pptx documents.
Yes. Check this out http://poi.apache.org/, they just released version 3.6 which now supports Office 2007 format documents. The best part is that it's free!
To generate a PowerPoint presentation from a template file, you can use PPT Templates.
This library provides a fluent API to replace variables inside the PPT template:
try(FileOutputStream out = new FileOutputStream("generated.pptx")) {
new PptMapper()
.text("variable", "Hello")
.text("other_variable", "World!")
.processTemplate(PptTemplateDemo.class.getResourceAsStream("/title.pptx"))
.write(out);
}
With this library, you can process text and images in the template.
Another solution that may work for you is Windward Reports (disclaimer, I'm the founder & CEO there). It uses PPTX as one of the supported template formats and merges in data to then generate a PPTX (or PDF, etc.) output.
If the edit/update you need can be handled via the data tags in Windward, this should be trivial for you. If what you need cannot be handled by the tags, then this won't work for you.
Well as mentioned by GrantB best way is to create a template, then load the template , traverse the xml graph,update the data and stream out to a output ppt. We recently did it to generate reports for clients that had complex visuals and charts in ppt. You can have a look here generate ppt in java

Categories