12 Replies Latest reply: Apr 18, 2012 3:05 PM by jayshakir RSS

    Add a text/sentence inside a PDF

    jayshakir

      I need to take a big pdf document and goto certain pages and locations and add some comments there for the section number.

       

      I tried to do this by first adding text boxes in those regions and then i dynamically opened it with my program and put the value in them.

       

      However the issue is that each line added can only start from a new line.

       

      But i want to add the text inside a paragraph or at the end or start, it should flow from middle of one line to the middle of another.

      I dont want it looking different, inside a text box, but rather look normal like part of the text.

       

      Please let me know how i can do this, i looked at the samples and examples but could not find an example to help add text inside a paragraph of a pdf.

       

      thanks

        • 1. Re: Add a text/sentence inside a PDF
          lrosenth Adobe Employee

          If you are doing this manually, you should post this to the Acrobat users area, since it's an application question.

           

          If this is a programming/development question, then we would need more info about the environment you are using…

          • 2. Re: Add a text/sentence inside a PDF
            jayshakir Community Member

            this is development question, my environment is my local system with window os and visual studio and c#

            thing is in some cases the text box is inside a paragraph and that is fine, however when the text box is filled with a shorter word there is a gap and if there is a longer word the right bottom of the text box has a +.

             

            let us assume that is not the issue, however when the text box needs to start in the middle of the para in the middle of a line and till the end, we cant start the text box in a zig sa manner to start fromt he middle of a line, but from the start of the next line, in a rectange form.

            • 3. Re: Add a text/sentence inside a PDF
              jayshakir Community Member

              or is there a way to just add to an existing text without adding a text box

               

              like to say goto this page this location and at the end of that text in the sentence, add this sentence and continue from the middle of that line to the next few lines.

               

              or

               

              should i concatenate the string to the constant string and post the whole para at a time. this way gaps are avoided and we can start the varible text from the middle of the para?

              • 4. Re: Add a text/sentence inside a PDF
                lrosenth Adobe Employee

                PDF is not a format designed for editing content in the way that you wish.

                • 5. Re: Add a text/sentence inside a PDF
                  jayshakir Community Member

                  Then how do i accomplish this task, let us say below is the para on the acrobat file

                   

                  Colestrol will accelerate heart disease risk by promoting fatty

                  deposits and inflammation in the arteries of the heart. Reduction

                  of excess body fat slows this process. Your Body Mass Index

                  indicates [<moderate obesity>] and it is a must [<that you lose

                  weight and increase exercise>] to reduce your risk of heart disease.

                   

                  To accomplish this task, we are inserting two variables shown as [<bold>]

                   

                  There are two issues here:-

                  1) [<moderate obesity>] - if this is a short word like "normal", then there will be white space at the end of the line.

                  2) [<that...exercise>] - this starts in the middle of a line and ends in the middle of the next line.

                   

                  My guess is i need to add the variable string to the rest of the para at run time and set the whole para dynamically in one shot.

                  So the whole para would be comming in from the server side code.

                  • 6. Re: Add a text/sentence inside a PDF
                    jayshakir Community Member

                    also can i make part of the input string of a different style or font like this :-

                    Your Body Mass Index indicates moderate obesity and it is ...

                     

                    Means can i have bold, italics, underlined in the middle of the text box, set dynamically?

                    Can it be HTML format maybe?

                    • 7. Re: Add a text/sentence inside a PDF
                      lrosenth Adobe Employee

                      PDF is not designed to be used in this way.   You should modify original material (such as HTML, Word, etc.) and then convert to PDF.

                       

                      If you must do this type of thing, then put the ENTIRE PARAGRAPH in a form field and modify the field data.

                      • 8. Re: Add a text/sentence inside a PDF
                        Bernd Alheit MVP

                        In a form text field you can use rich format.

                        • 9. Re: Add a text/sentence inside a PDF
                          jayshakir Community Member

                          thank you this is what i was assuming, generate the whole para and put into the form text box and set to multiline as true.

                           

                          the only other question is have the combined text in the text box have multiple formats for different words in the same sentence

                          • 10. Re: Add a text/sentence inside a PDF
                            jayshakir Community Member

                            okay tell me about how to set different words have differet style/color/appearances.

                            can we use html tags like <b> and </b> or <i> or <u>

                            • 11. Re: Add a text/sentence inside a PDF
                              lrosenth Adobe Employee

                              No, you can't use HTML tags.  You use the JavaScript APIs for creating rich text spans.

                              • 12. Re: Add a text/sentence inside a PDF
                                jayshakir Community Member

                                thanks let me know if there is any other way for rich text edit,

                                 

                                so for now, i will dynamically form each paragraph on the server side and put it inside the text box at run time, this way there are no gaps.

                                 

                                and to format some words of the paragraph differently, the only way is to use JavaScript APIs. I guess i can find these examples in the sdk kit, if not please provide.

                                 

                                eitherway, i thanks you both for all the help and assistance