Meaningless Drivel is fun!*
The moose likes Other Open Source Projects and the fly likes iText for editable pdf Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "iText for editable pdf" Watch "iText for editable pdf" New topic
Author

iText for editable pdf

Vani Bandargal
Ranch Hand

Joined: Oct 06, 2005
Posts: 82
Does anybody know how to create editable pdf using iText?
I am able to produce a non editable pdf in Struts environmnet using iText. I know wnat that pdf to be editable.

Please advice me
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41083
    
  43
PDF files are not editable. Using Adobe tools a limited degree of editing can be done, but not in the general sense - PDF is not a word processing file format. Some modifications are possible -watermarking, digital signing, extraction of text, removing or adding of pages-, but editing - no.


Ping & DNS - my free Android networking tools app
Vani Bandargal
Ranch Hand

Joined: Oct 06, 2005
Posts: 82
Thanks for the reply.
While learning aboue iText, I have read in many places that iText allows to produce editable pdf's.
Could you please tell me in what context they were saying "editable pdf's"?

I thought editable means one can edit the pdf contents after producing pdf using iText. Am I missing abything?


Thanks
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Really? I did a Google search for the terms "itext editable pdf" and I didn't find anything that said that iText could produce an editable PDF. So maybe, if what you read is online, you could post links?

However it also appears you don't understand the term "editable PDF". I don't understand it either, but then I have never seen the term before. What are your actual requirements? What is it you want from the PDF that you are generating? (Try not to use the word "edit" in your requirements as it seems to just confuse the issue.)
Vani Bandargal
Ranch Hand

Joined: Oct 06, 2005
Posts: 82
I am usimg iText to produce letters. Some of the contents of letters are database driven and some are hard coded which is not a causing any issue.

But the real issue is this:
1.user may want to enter extra line
2.user may want to add/change middle name OR maiden name of patient.
3.user may want to change some of the dates that came up in initial letter generation.

How I am going to achieve this kind of behavior?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

By "the user" you mean the recipient of those PDFs, I suppose. What PDF editing software are these users using?
Vani Bandargal
Ranch Hand

Joined: Oct 06, 2005
Posts: 82
yes, users means the receipients of the pdf's.
This is for a web application built using struts. So, users will be using browser.
I did not expect that user need to have any pdf editable softward on their machine. I thought iText will take care of it.

At least to answer your question, users do not have any pdf editable softwars(altough it is possible that some may have but we cannot rely on this fact)

should I really be producing rtf from iText for my purpose?
Please advice me.
[ February 05, 2007: Message edited by: Vani D Bandargal ]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

You can't edit a PDF in a browser no matter what software produced the PDF. If your users want to edit PDFs they will have to get some software that can do that.

Likewise if you send RTF to your users, they will need some software that can edit RTF. You can't edit RTF in a browser either.
Vani Bandargal
Ranch Hand

Joined: Oct 06, 2005
Posts: 82
Thank you very much for clarifying my doubts on producing pdf using iText.

Now that regarding RTF. I have a sample solution working on machine that allows me to edit the contents in browser.
This is my action method(In Struts environment)
public ActionForward doGenerateLeterRTF(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse response) throws WebException {
try{
Document document = new Document();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
RtfWriter2 writer = RtfWriter2.getInstance(document, baos);
document.open();
document.add(new Paragraph("Your text may be html also .."));
document.close();

response.setContentType("text/rtf");
//response.addHeader("Content-disposition", "inline");
response.addHeader("Content-disposition", "inline; filename=\"test.rtf\"");
response.setContentLength(baos.size());
ServletOutputStream out = response.getOutputStream();
baos.writeTo(out);
}catch(Exception e)
{
logger.error("Exception: " + e);
throw new WebException(e);
}

return null;
}

when this action method is called using a button click on form, I can see "Your text may be html also .." text on the browser that I can edit
(This shows like how when you open a word document in browser)

My question is you just said we need some special software to edit rtf but I do not have any special softward but still can achieve this.
Please clarify.
Is this the MS word installed on my machine is doing this job for me? If at all I did not had Msword then I was not able to edit?
[ February 05, 2007: Message edited by: Vani D Bandargal ]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Originally posted by Vani D Bandargal:
Is this the MS word installed on my machine is doing this job for me? If at all I did not had Msword then I was not able to edit?
I suppose so. You probably also need to be using Internet Explorer as your browser for that to work. I would suggest you should do the experiment that your question implies before deploying this solution.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41083
    
  43
It the PDF you'd like to be editable has only a few well-defined fields where the user may enter/change data, look into the concept of AcroForms. iText can generate those, and the plain Adobe Reader can edit those fields (not the document in general, though). But I think you're quite limited in what you can do with the altered document. I'd suggest to check Adobes web site for what reader can do with PDF files that contain AcroForms.
arun Palakkad
Greenhorn

Joined: Dec 16, 2009
Posts: 1
Normally what you will do is:

1. You will read a pdf template from some source.
2. You will insert the data in to the template,from your application.
3. On the output pdf,you will get the pdf with information filled from your application but the whole pdf is non editable.

What is actually happening in the above operation is,all properties of PDF template you got from the source
is over written on the resulting PDF by the PDFStamper, when you are trying to fill your data in to the template.So it will become uneditable,
To make this editable create PDFStamper object using the below Constructor.

How can we over come this:



reader - the original document. It cannot be reused
prFormTemplate - the output stream
'\0' or version - the new pdf version or '\0' to keep the same version as the original document
true/false - if true appends the document changes as a new revision. This is only useful for multiple signatures as nothing is gained in speed or memory

Enjoy Friends
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Hi Arun and welcome to Javaranch!


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Marco Schoolenberg
Greenhorn

Joined: May 25, 2012
Posts: 2
Hi there,

I have done quite a lot in Itext PDF.
I think maybe you could use some acrofields see lowagie's site:
http://itextpdf.com/themes/keyword.php?id=247

You could do something cool like:
http://examples.itextpdf.com/resources/pdfs/datasheet.pdf

Kind regards
Marco Schoolenberg
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: iText for editable pdf
 
Similar Threads
Convert Editable Pdf into Non-Editable Pdf
convert word documents to PDF
Java DB Project
Can I read already pdf file
iText - fillable PDF saved in hard-drive