Java generate PDF from RTF - java

I want to generate PDF file from RTF file.
I have tried following.
Itext
It's already outdated and new version doesn't support rtf.
JDocConverter
It uses OpenOffice on the background. it is working fine, there is only one problem. Open office doesn't support drawing object in RTF.
Any other possible and reliable solutions?
Note: It would be fine don't use any commercial software.

Windows has native convert RTF to PDF using command line, however it will to a degree be limited, so it will use direct convert text and images, but it will depend on rtf syntax as to which drawn objects are supported. WORD ART drawing objects need MS Word to print
The output looks reasonable but here is the source in MSWord where the art was clearly not handled by the non-word printout.

Under Windows you could print to CutePDF Writer. This freeware uses Ghostscript as a back end.

You may try Aspose.Words for Java to convert RTF file to PDF format. You can load a file in RTF format into Aspose.Words for Java and then save it to PDF format. Please note that while loading specify RTF as LoadFormat value and pass PDF as SaveFormat value while saving the document. This doesn't require OpenOffice or any other software to be installed for the conversion to work.
Disclosure: I work as developer evangelist at Aspose.

Best way to do it is use MS Office. And Ms Office is able to save file in PDF format (you need install some addons I think).

Related

Convert .doc/.docx documents to .odt (Open document text) and vice versa using java.

Is there any java library which can be used for converted Microsoft Word files (doc/docx) to Open Document Text format(.odt) formats. Free library would be preferable.
I don't know about any libraries that do it directly, but it should be relatively easy to exact the bits you're interested from a .docx using poi:
http://poi.apache.org/
and then write them to an ODT format using ODFDOM:
http://incubator.apache.org/odftoolkit/odfdom/index.html
This should be relatively straightforward for simple documents, but if your use case calls for complex doucments containing pictures etc, this might become a LOT harder.
Anyway, hope this helps at least some ;)
I believe everything you need is in this post: http://angelozerr.wordpress.com/2012/12/06/how-to-convert-docxodt-to-pdfhtml-with-java/
For instance:
JODConverter : JODConverter automates conversions between office
document formats using OpenOffice.org or LibreOffice. Supported
formats include OpenDocument, PDF, RTF, HTML, Word, Excel, PowerPoint,
and Flash. It can be used as a Java library, a command line tool, or a
web application.

How to manipulate .doc files

I need to create a little desktop app in Java that creates for me a .doc file and writes a bit of text into the file. I found an interesting tool called Aspose, but i saw it is not free at all.
Do yoy know what kind of, java API can i use for doing that(for free)?
Is it possible to do that only with the java SE libraries?
What do you think would be the easiest and fastest way to achive this goal?
I suggest you have a look at the Apache POI framework, specifically the HWPF - Java API to Handle Microsoft Word Files:
HWPF is the name of our port of the Microsoft Word 97(-2007) file format to pure Java. It also provides limited read only support for the older Word 6 and Word 95 file formats.
if you are going with .doc then as a learning excercise, open a Word document with some content (ideally similar to what you want to create) then save that as XML, and review the contents.
you will need to do some basic DOM parsing and management in your code to insert the right stuff.
By .doc file, I assume you mean Microsoft Office? Reading and writing Office file formats is something of a black art. Does it have to be a .doc format file specifically? A lot easier would be to write out a Rich Text Format file (.rtf) that Word could load.
And if you don't need to use .doc specifically I would suggest you use .odt, http://www.jopendocument.org/.

Is there a way to extract text from PostScript (.ps , .eps) files using Java?

I am looking for a solution similiar to PDFBox for PDFs of Apache Tika, however, for PS files.
thanks.
Like James Black says, it's probably best just to convert to PDF and use your familiar tools.
However, there does exist pstotext which is available in, e.g., the Ubuntu universe in its own package.
Ghostscript itself also comes with both ps2txt and ps2ascii which can also do this.
You could use Ghostscript to convert to a pdf, http://www.osalt.com/ghostscript, then there are various libraries to handle a pdf.
This has an advantage in that you are only pulling from PDFs, so you can handle other formats as long as you can convert them to PDFs.

Creating PDF, HTML, and optionally RTF documents from the same source using Java?

I was looking at using iText to create both a pdf and html version of a document with RTF as a possible option. According to this question this is no longer possible with iText. Is there a library that will allow me to create a document in Java and output it as both PDF and HTML? The ability to output RTF would be nice but is not required.
As that answer to the other question states, you can just use the iText RTF Library.
I have used PD4ML to convert HTML to pdf. Even though it is a commercial app. It is very reliable and supports CSS well.
JasperReports. If you look at this package it supports export to:
pdf
html
rtf
xls
xml
You have two options to create the documents:
via iReport - a visual designer for reports
via an API, where you construct everything with Java code.
Note that even though JasperReports's main function is to create reports, it can very well create other documents, with no tabular data for example.
You could also try Docmosis since that supports the output formats provided by OpenOffice (including the ones you specified) and you can often do the job with a lot less code.

Parse Pdf File and write content in word file using java

how to Parse a PDF file and write the content in word file using Java?
For parsing a PDF file in Java, you can use Apache PDFBox: http://incubator.apache.org/pdfbox/
For reading/writing Word (or other Office) file formats in Java, try POI: http://poi.apache.org/
Both are free.
Try the iText java library:
iText is an ideal library for developers looking to enhance web- and other applications with dynamic PDF document generation and/or manipulation.
It can be used for your parsing step.
As for generating word documents - the OpenOffice Java API might be able to generate Word compatible docs (no personal experience with this API).
You might want to try any of these:
http://incubator.apache.org/pdfbox/
https://pdf-renderer.dev.java.net/
Once you are reading the contents of the PDF file, you can as well store them in a ODT file or a text file. For ODT file, try http://odftoolkit.openoffice.org.
Best!
You could use iText if the source PDF is mostly text. Images and such are quite hard to handle while parsing. If it's text only, it's as easy as 10 lines of code. See the iText manual for examples.
For writing word files there's only Apache POI. It can be a little tricky to figure out, but for such a simple task it shouldn't be any problem.

Categories

Resources