• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

iText for editable pdf

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Vani Bandargal
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By "the user" you mean the recipient of those PDFs, I suppose. What PDF editing software are these users using?
 
Vani Bandargal
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Arun and welcome to Javaranch!
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic