Save editable PDFs using Java iText PDF API - java

I'm experimenting with the iText5 library to generate an editable (i.e. allow user to enter values in fields like age, name etc) PDF, it looks like the user
can't save the filled in PDF on his work station and the only available functionality is to take a printout of the filled in PDF form.
I tried googling this issue and found that with Adobe Reader, users can't save filled in forms and they need to have Acrobat Pro.
Is there any solution to get this job done (saving the filled in PDF form and emailing it) without needing to get Adobe Pro software?
Please feel free to ask me questions if the problem description is not clear.
Thanks in advance.

There are other viewers that allow people to save filled out forms locally (Nitro? Foxit?). In the early years, there were also people that used iText to create a mini server on the desktop to which the data filled out in Adobe Reader was sent. This server then returned the filled out form. Once Adobe found out about this practice, they changed the EULA of Adobe Reader, saying that you are not allowed to use Adobe Reader for this purpose.
Summarized:
If you want a solution that involves your end users to use Adobe Reader: there is none. You'd violate the EULA of Adobe Reader.
If it's OK to use a PDF viewer other than Adobe Reader: pick another viewer that allows saving of filled out forms.
Note: this is not an iText question.

It looks like I was having older version of Adobe Reader (Version : X), which doesn't have the capability to save user entered data. Upgrading Adobe Reader to DC version seems to have fixed my problem where I can now save the filled in form data. Just trying to document here so that it can be useful for the fellows who may be are running into similar situations.

Related

Converting docx/ODT to image using Java

I am working on a Spring REST service based web application (UI is based on HTML5, backbone.js). The actual requirement is, an uploaded document (could be any document like excel, word, ppt, pdf etc) requires an preview option using which an user can view the document in the browser (user may or may not have office installed).
My idea is to convert the documents into images and display them to the user. On searching, i found multiple ways to convert a PDF to image but not much ODT to image (Note: I am looking for an open source). JODConverter, docx4j can be used to convert the documents to pdf. Then I can convert these PDFs to images. But is this the right way. Is there any other efficient way to achieve the same. Please suggest and point me to the right direction.
Thanks in advance.
Gopi
Yes, you won't do any better than .docx to .pdf to image. You really need a stable workflow, and this is as good as you'll find for this purpose, unless you're running on a Microsoft server and you have access to the official Microsoft Office stuff.
For previews, docx4j or similar will do just fine. Not everything converts perfectly, but it should be fine for a preview.

How to open, jump to a page, change page size (basic read only operations of PDF)

I am very beginner in this iText. I just want to know how to do basic things with PDF from Java.
How to open a PDF page so that the PDF file is opened in front of me?
How to jump to a page (by page number) so that I see seeked page in front of me?
How to change page size so that I see page size changed in front of me?
I know these things can be done using mouse and keyboard, but I just want to make a program that open PDF files according to parameters.
When I do search about iText, I just found topics that tackle creation/modification issues.
You have misunderstood what iText is for. It's not a library for PDF rendering, you won't be able to visualize a PDF file with iText.
As for your issue, most of the PDF viewers (Adobe Acrobat, Foxit Reader) accept parameters to achieve (partly) what you want.
It's just a matter of finding the proper reader. Remember that seeking advices about libraries, applications, frameworks is considered off-topic on StackOverflow, so your question is likely to be closed.

Reading a PDF Document in Android

this is my first question or rather Questions. I am in my last semester this college and Reading PDF is one of the components that im developing for my thesis.
I have been reading questions about reading a pdf document but there are no solid answer. I want to know what are the ways to read a PDF document? what i have read that there are API's available that can read PDF Document like PDFBox, muPDF, and iText. I have not seen any other API's but this is what i have read on other posts.
The problem here is first PDFBox i read that PDFBox can not be use because of AWT Dependencies and android is has no AWT and Swing related classes. PDFBox is out of the question. muPDF i have not read anything about muPDF, it was recommended to me but i want to know if it is usable to read PDF Document. iText this is the most common API that i encounter in PDF and android related questions. the problem here is its License?(Correct me if im wrong) I have not tried any of this 3 yet because i want know if there are another solutions beside this 3.
Other than APIs, i think PDF Reader Applications can be used too if im not mistaken? if it can be used then HOW?. I'm not looking for a Code but a explanation of how you did it and how you implemented it in your application.
i have thought another way but i do not know if this is possible. how about convert PDF Document into a .txt or .doc file? inside the android. it would be like when i load a PDF document inside the android a Code will convert that PDF Document into a .txt / .doc file and the application will search and extract text from the .txt / .doc file rather then the PDF Document.
if you are asking WHY do i need this kind of component, because i'm working on a application that would SEARCH and EXTRACT text from a PDF Document using Android.
This is my questions:
What are the ways to read a PDF Document in Android?
What are your experiences in using this kind of method?
How did you do it using this kind of method(just a flow/explanation would do)?
If the method has a License what would be the problem in the future?
PS: Correct me if i'm wrong.
Thank you.
This is a very iText specific answer so it does not answer all your questions, but it may still be of help to you.
What are the ways to read a PDF Document in Android?
I use the iText java bindings (Keep reading to find out about LGPL licensing)
What are your experiences in using this kind of method?
Great! It covers all things PDF related. (Older versions may be a little different)
How did you do it using this kind of method(just a flow/explanation would do)?
I assume this question is related to the "other way" that you thought of so it is not relevant to the iText PDF library?
If the method has a License what would be the problem in the future?
I still encourage you to use the updated version of iText, however if you use iText version 2.1.7 or older it falls under the old LGPL license, and has far more free reign and is more suitable for commercial or private/closed use with no real problems. From what I can tell all the functionality you are after is available in version 2.1.7 version.
The AGPL license for current version of iText is pretty decent, from what I understand you do need to publish your program under a similar license and make the code freely available to others (it would pay to check the details though), if sharing code is not a problem then the latest version of iText is worth looking into.
References:
LGPL License: http://www.gnu.org/licenses/lgpl.html
iText AGPL License: http://itextpdf.com/terms-of-use/agpl.php
I was also working on an Android Application, where i need to open PDF files in my android application. First i thought about doing this by using foreign API's. I tried to used mupdf, but it was not a good experience.
Then our team leader suuggested me to first install a pdf viewer application in your device and then use code to open pdf through the installed pdf viewer application.
You can easily download pdf viewer application from gogle play, then you can use the following code to open the pdf in your application,
File file = new File("/sdcard/MyPDFfile.pdf");
Uri path = Uri.fromFile(file);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path, "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
This code will automatically look for the installed pdf application in your device and will pass the intent to that application to open the pdf file.

PDF Open Office or MS Word

I am new to java, I have to read a PDF, Open Office or MS Word file and make changes in the file and render as PDF document on my web page. Please someone tell me which of these file's API or SDK is easy to use and also tell me best SDK for this. So I can read, Update and render easily. file also contains Table but there is no image.
We use Apache POI to read Microsoft Office files. There are many libraries for PDF in Java. iText is something I have used. Once you pick the tools, do a selective search on Stack Overflow. There are plenty of discussions around these tools.
Depending on the types of updates you are doing, modifying PDF is going to be a problem - it's not intended for editing. You might have to find some way of converting the PDF to something first, then edit. Depending on the types of changes you want to make and the documents you are working from even editing DOC and Writer files is going to be tricky. They are all different formats.
As Jayan mentioned, iText and POI may help you a little. OpenOffice Writer documents can be edited by unzipping then modifying the XML or using the UNO API. Word documents can be editied by using MS Office automation (bad idea), converting to OpenOffice first then editing, or if DOCX, unzipping and processing the XML.
Good luck.

How to show the printable document directly in acrobat with out saving?

I am using PD4ML to print a PDF file and It is working fine. Now the thing is I want show that file directly in acrobat with out save that file. In Local version I am using
Program.launch(getFilePath());
It is working fine but in web version I am unable to get that.
Can you please suggest me, Its very helpful.
Thanks,
Vara Kumar PJD
The web isn't like your desktop, so forget about doing things on the web the way you do them on the desktop without at least some effort.
Know that you don't read PDF files on the web using Acrobat without a browser plugin. Or some other reader like Foxit Reader.
My recommendation: forget about doing it this way. Either server your pdf as a file that can be downloaded, or read this SO post about embedding PDF in HTML.
I don't think this will be possible: "showing file outside browser in an application without user consent" because that is how browser are made for security reason. The best you can do is, as pointed in earlier post is by darioo, to show file in browser or prompt user to download/open.

Categories