generate and embed file into doc programmatically - java

I have a project which generates a report (doc file) programmatically. I have a hard time finding a solution to the following problem:
I would like to create a text file (or another doc file, whatever) with a given content, then I want to embed this file into the report programmatically. (I guess it should be done with the help of OLE Objects).
I am finding solutions in vb, I need it in java!
Apache POI or Aspose.Words has this possibility?
If anyone had done this before, I would really appreciate a simple code example for this embbedding.
Thanks, cheers!

Related

Java Doc to PDF Convertor

I'm looking for a solution in my "JAVA" project to convert documents (including MS-word files) to PDF. I already used OpenOffice+JodConvertor but the result most of the time is not as good as I expect. Does anyone knows a framwork or a solution rather OpenOffice?
Best
I would take a look at this.
http://poi.apache.org/

Need a simple open source solution to export 2D table data into PDF and Word format

guys. In our project, we need to add a new feature which is to export some test result data into PDF and Word format file for user. The structure of test result data in our system is generally simple 2D table (some may be a little complex that has cell consolidation). Is there any stable and mature java open source solution for this? Or should we use any report solution like BIRT (but we feel such solution may be too heavy weight for this feature)? Because the deadline of this project is tough, to save some investigation time I post a question here and want to get some suggestions. Any suggestion will be very appreciated, thanks. By the way, our project is a Swing application.
JasperReports allow export to PDF and DOC, it might be easier than using POI and iText.
As time is short and this is a new feature, you might temporize by writing a comma-separated-value file with a name acceptable to Excel. At a later time, implement a more robust solution using Apache POI or something similar that your research identifies.

How to convert pdf to doc file in java

need to convert a pdf file to a doc file. I found different type of example to generate pdf file but not got pdf to doc.
What your asking is actually very difficult
I recommend you start here and look for a good parsing library. then you would have to write it out in .doc format. Inevitably a lot of the formatting and extra information would be lost. it would be a lot easier to output to docx format, but i assume thats not what your looking for.
I see few possible solutions:
Davisor Publishor 6.2 probably can be used, but it is commercial, and seems that generates only txt from pdf... just have a look
parse pdf with iText, and then
generate doc with Apache POI -
another way to try (free one ;)
look for command line tools, like
Convert PDF To DOC and execute
them from java
Otherwise take a look at Con's answer, there is a link to the list with java pdf processing libraries, maybe some library can do it directly, or can be used to parse pdf (better than iText), and then just use Apache POI to generate doc. Hope it helps ;)

Design PDF template and populate data at runtime using java,xml etc

well i have been looking for a java based PDF solutions...we dont have a clean way i guess-still.. all solutions are primitive and kind of workarounds... No easy solution for this requirement -
1. Designing a PDF template using a IDE (eg. Livecycle designer ..which is not free)
2. Then at runtime using java, populate data into this PDF template...either using xml or other datasources...
such a simple requirement and NONE has a good "open-source and free" solution yet ! Is anyone aware of any ? I have been searching for since 3-4 years now..for a clean way out...
Eclipse BIRT comes close.. but does not handle Barcode elements ..OOB.
Jasper - ireport is also good but that tool does not have a table concept and is kind of annoying ! Also barcode support is not good.
XSL-FO has not free IDE for design .
Looking for a better answer .. got one ?
If it's a "simple requirement", you could create a report designer around iText and release it as FOSS yourself.
What are your key requirements? Does your input have to be a PDF? If so, you'll be probably working uphill for a long time still. Obviously you want to inject data and output a PDF.
If your templates can be something other than PDF, you could try using the OpenOffice API to get OpenOffice to do manipulate documents and produce a PDF. JODReports or Docmosis would be better ways of interacting with OpenOffice and Docmosis allows you to treat documents (doc and odt) as templates.
You can create a PDF file with AcroField through iText API AcroField values can be populated.
Note: Using OpenOffice you can create PDF document with FormFields.
http://blog.rubypdf.com/2007/08/01/freely-fill-pdf-form-with-the-help-of-itext-or-itextsharp/
You could use OpenOffice's UNO API. It looks rather heavyweight but at least you get something full-featured.
Have a look at XDocReport. You create your templates in word .docx or OpenOffice .odt files, then turn them into populated PDF files with Java code.

How do I use Apache POI to read a .DOC file in Java to separate images from text?

I need to read a Word .doc file from Java that has text and images. I need to recognize the images & text and separate them into 2 files.
I've recently heard about "Apache POI." How I can use Apache POI to read Word .doc files?
The examples and sample code on apache's site are pretty good. I recommend you start there.
http://poi.apache.org/hwpf/quick-guide.html
To get specific bits of text, first create a org.apache.poi.hwpf.HWPFDocument. Fetch the range with getRange(), then get paragraphs from that. You can then get text and other properties.
Here for an example of extracting an image. Here for the latest revision as of this writing.
And of course, the Javadocs
Note that, according to the POI site,
HWPF is still in early development.
It's not free (or even cheap!) but Aspose.Words should be able to do this. Their evaluation download will let you play with small files.
Do the destination files also have to be Docs? You could open the docs in Office and save them out as HTML. Then the separation becomes trivial. RTF is also a viable option, but I can't recommend a good RTF parser off the top of my head.
Edit to say: I just remembered another possible solution: Jacob, but you'll need an instance of Office running on the same machine. It's short for Java COM Bridge and it lets you make calls to the COM libraries in Office to manipulate the documents. I'm sure it's not as scary as it might sound!

Categories