How to replace string in existing pdf using pdfbox?

My requirement:
Your loan amount @loanamount is approved.
I wanted to replace @loanamount to 5,00,000. If i try with pdfbox api,i am not able to replace. i am getting empty space in pdf.
If i use same api and if try to replace @loanamount to abcd. now its replacing
replaceFirst("@loanamount","5,00,00"); - not able to replace. getting empty content in pdf
public void replaceString()
PDDocument doc = null;
try {     
doc = PDDocument.load("D:/DOCS/Letter.pdf"); //Input PDF File Name
List pages = doc.getDocumentCatalog().getAllPages();
for (int i = 0; i < pages.size(); i++)
PDPage page = (PDPage) pages.get(i);
PDStream contents = page.getContents();
PDFStreamParser parser = new PDFStreamParser(contents.getStream());
parser.parse();
List tokens = parser.getTokens();
for (int j = 0; j < tokens.size(); j++)
Object next = tokens.get(j);
if (next instanceof PDFOperator)
PDFOperator op = (PDFOperator) next;
// Tj and TJ are the two operators that display strings in a PDF
if (op.getOperation().equals("Tj"))
// Tj takes one operator and that is the string
// to display so lets update that operator
COSString previous = (COSString) tokens.get(j - 1);
System.out.println("COSString::"+previous);
String string = previous.getString();
string = string.replaceFirst("@loanamount", "5,00,000");
//Word you want to change. Currently this code changes word "Solr" to "Solr123"
previous.reset();
previous.append(string.getBytes());
PDStream updatedStream = new PDStream(doc);
OutputStream out = updatedStream.createOutputStream();
ContentStreamWriter tokenWriter = new ContentStreamWriter(out);
tokenWriter.writeTokens(tokens);
System.out.println("updatedStream::"+updatedStream.getInputStreamAsString());
page.setContents(updatedStream);
//setItem(COSName.CONTENTS,updatedStream);
doc.save("D:/DOCS/loanamt_filled.pdf"); //Output file name
sample content in pdf:
Dear ABC,
Your loan amount @loanamount is approved.
Regards,
DEF
Output:Your loan amount is approved.
I m getting empty spaces instead of @loanamount
Could anyone help me out ?
Please suggest me java open source api to replace caption or content in existing pdf.
Thanks in advance...

Tom
To answer your original question, I know of now easy way of processing your clips and replacing the existing ones already edited.
If I have this right you have your sequence fully edited?
There is a workaround, messy and time consuming but it will not spoil the video element of the sequence.
Process: -
Drag the audio for each clip so that it is on a track with space at either end of it.
Unlink each clip.
For every audio clip extend each audio's head and tail
Then use the edit in Audition link
The clips are individually processed
Then you can go back adjust the head and tail to what you want and fade out and in as you wish.
I'd manually fade each clip rather than add an audio transition
Take care not to alter the video clips at any time or you will go out of sync
Hope this helps
Col

Similar Messages

  • How do you setup to print PDFs using adobe?

    How do you setup to print PDFs using adobe?

    You install Adobe Acrobat, and 'Print to PDF' will be automatically set up.

  • How do I Edit an Existing PDF Form Without Losing Form Functionality

    I'm brand new to Acrobat but familiar and proficient with Flash, PhotoShop Premiere Pro, After Effects, Dreamweaver, Fireworks etc.
    The company I work for sells office supplies. We sell 57 distinct items.  We have Acrobat 9.  I am designing a PDF order form with fields that can be emailed to our clients as an attachment.  They fill out the form, it calculates the total, they send it back to us, we fill and ship the order.  Basic and straightforward.
    I can add form fields to my order/pricelist... not a problem.  The question is:
    Once I have brought a PDF into Acrobat and add 57+ fields and calculations, which is a time consuming process, how do I edit an item price at a later date, if someone in the company decides to make a change to our pricing?
    See..., If I save the original Microsoft Excel document as a PDF, Acrobat can't edit the text for some reason.  Something to do with "Renderable Text".  Now if I open the PDF saved from Microsoft Excel in Adobe Illustrator, I can use the text tool to make changes. That doesn't help me... just saying. Why can't I edit "Renderable Text" with the Acrobat Text Tool?  Someone in a forum stated that Acrobat is NOT a word processing program!  If that is an accurate statement, it would appear that Acrobat can at least work with base PDF documents to make certain types of modifications and add functionality.  Is that correct?
    Here's the problem.  I create a PDF with form functionality.  Everything works great.  The boss says, I want to change the price of the scissors.  I can't change the text in Acrobat because of the "Renderable Text" nonsense.  Does this mean that I have to re-apply all of the form fields and calculations to the new base PDF document every time there is a minor change?  I know there has to be a simple work around.  Should I upgrade to a newer version of Acrobat?
    Is it possible to save the original existing form functionality as a layer or overlay to be applied to the new modified base PDF document?   Kind of like so many other Adobe products do including PhotoShop, Fireworks, Premiere Pro, After Effects, Flash etc., so that all of the form functionality can be applied in one big chunk?  Premiere Pro has the time-saving feature of "Paste Attributes".  It's a real time saver.
    It may be simpler to just direct me to a video that goes through the process of creating a PDF order form with fillable fields that multiplys quantity by unit price and totals one column.
    I already created a prototype of the form in PhotoShop which can be saved as a PDF.  The finished order document appearance has 95 horizontal 3px wide lines and 6 vertical 3px lines, kind of like what one might expect to see in an Excel spread sheet.  The form also contains some graphics and unconventional text areas that acrobat could overlay text fields and everything would be fine.
    With these great number of horizontal dividing lines, It doesn't seem practical or even possible to create the basic layout in Acrobat.  As I originally stated, I'm new to Acrobat and would like suggestions for a workflow that enables easy editing of an existing PDF document with form fields.  I want to avoid the monumental task of re-doing all of the fields and calculations.

    For what you are trying to do that is probably what you want -- Replace Pages. There are a few more issues that you need to be aware of since this is a business form. If customers are using Reader XI, it is not an issue.
    On the renderable text, can you see the text list when you look at the font tab in the document properties (ctrl-D)? If not, they you do not really have fonts to edit. This may be the type of fonts you used in the original or the way in which you did the conversion to PDF. You need to have fonts that are on your system and then be sure to embed them (otherwise others may not be able to read them because of different OS or such).
    As to e-mailing the form, that is fine (though there are sometimes problems with various clients and PDFs -- but usually on the sending end).
    For collecting the data you may want to try a different route. For users of Reader XI, they can save the form with the data. Prior versions could not do that unless you enabled the form for Reader. However, this latter process has a 500 form use limit -- A license issue. If the data is submitted, then it does not make a difference. The folks with Reader XI can still save the form with the data, others will have to print a copy for their records.
    The data can be imported to the form on your end and so you would have the exact same results as what was filled out. However, the submission process should be set up to submit to a web script for your receipt and not use mailto. The latter has problems that you have no control over due to proper operation with the mail client on the user machine. Typically the mail client must be the default and use MAPI. In any case, it is not reliable (not for business use). So submission to a web script is useful. The data in AcroForms would be of the type FDF (or possibly XFDF). If for some reason use created the form with Designer, that limit any editing in Acrobat since it is no longer a real PDF, but an XML container that Acrobat and Reader can display and interact with, but not change. Again, submission to a web script is still preferred.
    For dealing with a web script and some coding for various languages, you can check out the FDF Toolkit. It has been around a while, but should still handle the CGI needs of the submission. In addition, it has tools for adding the data to a database and other typical operations for data collection. You can save the FDF files and import them to the form and deal with the data there also.
    The use of Replace pages would do the job if all your form fields will still need to be in about the same location. Form fields are mark up and the pages are referred to as the document. Thus the replace pages will just original page and leave all the form fields. You will still need to go back and fix the value within the fields themselves, but that is a field edit.

  • How to write special characters in PDF using iText

    How to write special characters encoded with UTF-8 in PDF using iText.
    Regards,
    Pandharinath.

    I don't know what your problem is but that's almost certainly the wrong question to ask about it. Java (including iText) uses only Unicode characters. (You may consider some of them to be "special" if you like but Unicode doesn't.) And when it does that, they aren't encoded in UTF-8 or any other encoding.
    So can you describe your problem? That question doesn't make sense.

  • How to Embed fonts in existing PDF file

    HI,
    I want to know how to embed the fonts in an existing PDF file, i do have Acrobat.
    Thanks

    Post your question in the forum for Acrobat.

  • How to get image properties in PDF using javascript or plug ins

    Hi
    How to get the image(all the images) properties in PDF using javascript or suggest plug ins
    Thanks in Advance

    HI,
    In the PDF Edit API's ( as has already been suggested) there is the PDEImage and using this you should be able to find out everything you need to know about any image in a PDF file.
    I would recommend starting with PDEImageGetAttrs
    Hope this helps
    Malcolm

  • How to get image properties in PDF using javascript

    Hi
    How to get the image(all the images) properties in PDF using javascript?
    Thanks in Advance

    Hi
    Thanks for your quick response. Any recommended plug ins
    Thanks in advance

  • How to extract word coordinates from PDF using vc++6.0

    In sdk,i just know how to get coordinate from pdf using javascript,and it will be completed use vb.but i dont know how to get the coordinate througt vc++6.0.anyone can help me?
    thank you advance!

    PDEWordFinder is the usual method for getting words and co-ordinates.
    PDFEdit is not usually used, it is not suitable for getting text.
    It is very hard work to make the two worlds work together (e.g. to
    edit text you find).
    Aandi Inston

  • How to search a word in PDF using acrobat javascript?

    Hi,
    I need to find a word in acrobat PDF using javascript. I used
    find text("abx");
    select text("abx");
    This doesn't work for me..
    Someone guide me.
    Thanks in advance,
    Poovili V

    I used
    find text("abx");
    select text("abx");
    This doesn't work for me..
    That is not Acrobat Javascript. In the Acrobat Javascript Reference look for the method getPageNthWord.

  • Inserting PDFs into existing PDFs using Preview

    Previous to the 10.6.6 update I was able to insert a PDF document into an existing PDF document by dragging the new PDF into the sidebar within Preview.
    Now when I try this, instead of adding the document, it opens the PDF I have just dragged in, in the same window.
    Is this a setting that I have missed somewhere? Have check document security permissions, preferences etc...
    Thanks
    Message was edited by: griffs

    Preview (in Snow Leopard) can display more than one multi-page PDF in one window. If you drag pages from document 2 into the space at the end of the sidebar of document 1, they will remain as separate documents. Drag them on top of the pages of document 1 in the sidebar. Document 1 will highlight and you can position the pages as desired. It is easier to do it than to explain it.

  • How can I edit an existing pdf file? I just need to replace some text

    my boss wants me to amend a pdf document and I've been doing it wrong. The programs I have are illustrator, in design and photoshop hope you can help.
    thank you in advance.

    I have amended a pdf before sometime ago but totally forgotten what I did.
    But I do know it can be done
    The fact that you edited one PDF doesn't mean you can edit another. There are many possible PDF "recipes" which may or may not result in direct edit-ability.
    In your original post, you state you've "been doing it wrong."
    In post #2, you state "it didn't work."
    In post #4 you state "it doesn't allow me..."
    It would be a lot easier to advise you if we had more detail in terms of how you're going about your attempts to edit, and what actually happens when you try. For example:
         "I use the Type Tool and click/drag to select text, but it makes a new text box instead."
         "I can't select individual objects. It looks like everything is grouped in one big frame"
         "When I click on text, it gets elected like objects, with anchor points all around."

  • How to insert a specific picture to an existing pdf using Insert Pages

    I have created a plugin button which I want to call the "Insert page from another file" behaviour method when pressed. Passing in a specific image file which is stored on my local machine.
    So the user pressed this button and they are immediately confronted with the following dialog.
    My problem is trying to get this file from c:\Sunset.jpg and pass it into the Insert Pages Dialog.
    Could anybody explain how I would go about doing this.
    Thanks

    Thanks @Ironsenth At least I know not to go down this route.
    I am not wanting to add a Watermark, but was confused as to exactly what I have to send to this method as arguments. I asked very similar questions on other discussions but kept getting given solutions which were too broad when all I wanted was to know a few tiny details.

  • How to replace string

    Hi Experts,
    This is not jdeveloper question, but still i am asking, becoz i dont know other blogs......:(
    I want to replace one string, i am using StringUtils.replace(originalString,searchString,replacedString) everthing is working fine but if my
    originalString:"1,65.0000,65.0000,1,MMMF,Current,SHTC,"
    searchString:originalString[3]-- 1
    replacedString: testing
    so finally string is : :"testing,65.0000,65.0000,testing,MMMF,Current,SHTC," -- its wrong because i thought to change only 3rd element from the array, but the same 1 is there in both positions i tried with
    StringUtils.replace(originalString,searchString,replacedString,occurences) when i put occurences as 1 then its changing 0th element.
    can any one suggest me how to resolve this issue.
    sorry if this question causes inconvinence to any one.
    Any inputs could be highly appreciate.
    Edited by: user642703 on Feb 29, 2012 9:52 PM

    http://commons.apache.org/ is probably the best place for you to look around (they have a mailing list) - I assume you are using their StringUtils

  • How to replace a function/procedure/trigger using datapump

    Hi All and thanks for any help you can provide!
    My goal is to export our production schema -- table data, function and procedure definitions, triggers and sequences -- and import all of that into the QA schema.
    Here is the expdp command from production
    expdp / as sysdba
    DIRECTORY=EXPORT_DATA
    SCHEMAS=CP_APP
    DUMPFILE=cp_app_01.dmp
    LOGFILE=cp_app_01.log
    I then move the file from the production server to the qa server and use this command to import it.
    impdp / as sysdba
    DIRECTORY=IMPORT_DATA
    CONTENT=ALL
    TRANSFORM=OID:N
    DUMPFILE=cp_app_01.dmp
    TABLE_EXISTS_ACTION=REPLACE
    REMAP_SCHEMA=CP_APP:CP_QA
    The problem is that triggers don't get built properly. Here's one error
    ORA-39083: Object type TRIGGER failed to create with error:
    ORA-00942: table or view does not exist
    Failing sql is:
    CREATE TRIGGER "CP_QA"."PLAYER_LOG_EMAIL_INS_TRIGGER"
    before insert on cp_app.player_log_email
    for each row
    begin
    -- auto-increment --
    select seq_player_log_email.nextval into :new.log_id from dual;
    end;
    The REMAP_SCHEMA option only changes the schema of the trigger itself, but it did not affect the schema of the referenced table.
    Any suggestions on how to get PL/SQL objects rebuilt?
    Thanks for any help.
    -- Chris Curzon

    Hi,
    this is a known issue and is also desribed in the manuals. There is a note on Oracle Support: "IMPDP Reports ORA-942 and ORA-39083 During Importing Schema Objects [ID 750783.1]". It describes a solution, in the simplest way:
    Make an sql dump of the import, add the last parameter:
    impdp / as sysdba
    DIRECTORY=IMPORT_DATA
    CONTENT=ALL
    TRANSFORM=OID:N
    DUMPFILE=cp_app_01.dmp
    TABLE_EXISTS_ACTION=REPLACE
    REMAP_SCHEMA=CP_APP:CP_QA
    sqlfile=script.sqlNow you have the file script.sql in which you find your trigger code. Adjust in this file the schema names and run the code against the database.
    Another option would be to adjust the trigger code in the source database to not reference the schema.
    Herald ten Dam
    http://htendam.wordpress.com

  • How can I make an existing pdf form mobile friendly

    I have a mobile notary business and need to make Invoices for on the go.
    What Ive done:
    Ive created an image in Photoshop with basic text, table structure and company logo and save it as a pdf (saved file is 1.24mb)
    I imported the saved pdf into Acrobat Pro X, added fields, and saved (saved file is 4.29mb)
    The invoice is exactly how I want it, and runs great on the computer, but when I try to view it on my Droid Bionic or Galaxy Tab 10.1 using any pdf reader (including acrobat reader) it can't seem to open completely. It nearly freezes the devices.
    What Id like to do:
    Take the file Ive already made, and make it mobile device friendly so I can create and email invoices on the spot.
    What are my best options to do this?

    Well, I was running into problems saving a filled form on my galaxy tab and droid bionic, so thats why I was asking about the option... But I figured out the reader-enabled function and tested it (I had hoped to edit my post before you read it lol) but, it only gives me the option to "share" not to save. I tested it and sent emailed it to my computer, opened it and it was a filled form. One problem I foreseee though, is that the file (the filled invoice sent from my tab) is still editable. In other word, I could fill a form, email it to someone, and they could refill it to whatever they want. I need to be able to fill out a form on my tab/phone, save and email it to someone, and make it so they can't change anything... any suggestions?
    Apparently "reader" for the droid system doesn't have a "Save/Save As/export" option at all...
    But apparently if I open the Invoice PDF in Reader, fill it, then open the file in an office type app (I use quick office pro) Itll open the pdf WITH the fields fille, and then I can save as a *.docx file. But, it won't let me just opne/edit field in quick office. I've getting frustrated.
    Found a solution XD an app that allows one to open a pdf, fill the fields, "flatten" (so its no longer editible), and save. qPDF Problem solved
    It looks bad in InDesign, before exporting to PDF

Maybe you are looking for