11 Replies Latest reply on May 18, 2014 10:22 AM by try67

    Multi-line textbox missing first character after new line

    tuvozinterna

      Hello, I'm making a pdf report that swaps 2 pages back and forth (the content is the same except for one table), basically what happens when clicked on the 'swap page' button is:

       

      1. get all the field values of the page that's going to be deleted into an array 'buffer'
      2. delete the page
      3. insert the other page
      4. fill all the field values with the values in the buffer

       

      So, the thing is that in the multi-line textboxes is missing the first character each new line after that process if I modify the content, if I don't modify the content the time I swap the pages and transfer the field values it renders ok, it doesn't matter which line modify it and how many lines I change, in the whole multi-line textbox each new line I get a character less at the begining of a new line (except for the first character of the first line).

       

      I will try to work it around with text.replace('\n','<br>') or something programmatically though I may be missing some configuration key to this.

       

      I'm using Acrobat Pro 11.0.06 on a Windows 7 Professional guest on a Fedora 20(3.13.10-200.fc20.x86_64) host.

       

      Thanks in advance

        • 2. Re: Re: Multi-line textbox missing first character after new line
          tuvozinterna Level 1

          Sure:

           

          function init3(doc){
              //--------------------------------------------------------------------------------------------------
              // Al cargar el documento
              //-----------------------
              
              // controles adicionales
              global.controlesAdicionales = ['membrete','FUMdesconocida','FPPdesconocida','cambiar_pags_evaluacion_doppler'];
              global.busCampos = [
                  'tbl2-fusionAminosCorion',
                  'tbl2-focoHiperecogenicoCardiaco',
                  'tbl2-quistesPlexosCoroideos',
                  'tbl2-quistesCordonUmbilical',
                  'tbl2-huesoNasal',
                  'tbl2-arteriaUmbilicalUnica',
                  'tbl2-translucenciaNucal',
                  'tbl2-onfalocele',
                  'tbl3-edadGestacionalSemanas',
                  'tbl3-edadGestacionalDias',
                  'tbl3-ondaS',
                  'tbl3-ondaD',
                  'tbl3-ondaA',
                  'tbl3-ondaTamx',
                  'tbl3-resultado',
                  'tbl4-edadGestacionalSemanas',
                  'tbl4-edadGestacionalDias',
                  'tbl4-anios',
                  'tbl4-21',
                  'tbl4-18',
                  'tbl4-13',
                  'tbl4-riesgo',
                  'tbl4-resultados',
                  'tbl4-nota',
                  'observaciones',
                  'patologiaMaternaAsociada',
                  'diagnosticoEcografico'
              ];
          }

           


          /*
          // THIS CODE IS ACTIVATED WITH A BUTTON ON THE DOCUMENT
          */
          cambiarPagsEvaluacionDoppler = app.trustedFunction(function(mostrar){

              guardarInfo(this);

              app.beginPriv();
              
              pagsPath = app.getPath("user","javascript") + "/ReporteMedico3-Pagina2";
              
              if(mostrar){
                  this.deletePages({nStart:1});
                  this.insertPages({nPage:0, cPath:pagsPath+"/conTabla.pdf"});
              }else{
                  this.deletePages({nStart:1});
                  this.insertPages({nPage:0, cPath:pagsPath+"/sinTabla.pdf"});
              }

              app.endPriv();
              
              cargarInfo(this);
          });

           


          /*
          // THIS SAVES IN MEMORY THE VALUES OF THE FIELDS OF THE CURRENT PAGE (THE ONE THAT'S GOING TO BE SWAPPED)
          */
          function guardarInfo(doc){
              global.buffer = new Array;

              for(var i=0;i<global.busCampos.length;i++){
                  //app.alert("campo: "+global.busCampos[i])
                  var campo = doc.getField(global.busCampos[i]);
                  
                  if(campo.name == 'diagnosticoEcografico'){
                      global.buffer.push(campo.value.replace(String.fromCharCode(13),"<br>"));
                      app.alert("valor: "+campo.value);
                  } else{
                      global.buffer.push(campo.value);
                  }
              }

          }

           


          /*
          //  THIS TAKES THE VALUES FROM MEMORY TO THE CORRESPONDING FIELDS OF THE NEW PAGE (SWAPPED PAGE)
          */
          function cargarInfo(doc){
              for(var i=0;i<global.buffer.length;i++){
                  var campo = doc.getField(global.busCampos[i]);
                  
                  if(campo.name=='diagnosticoEcografico'){
                      campo.value = global.buffer[i].replace("<br>",String.fromCharCode(13));
                  } else{
                      campo.value = global.buffer[i];
                  }
              }
          }

           

          Page 1 calls page 2 and vice-versa

          • 3. Re: Multi-line textbox missing first character after new line
            try67 MVP & Adobe Community Professional

            Is this issue you're having happening with the "diagnosticoEcografico"

            field, or with others as well?

            • 4. Re: Re: Multi-line textbox missing first character after new line
              tuvozinterna Level 1

              With others as well.

               

              the operation affect the value of all texboxes that have the 'multiline' property checkbox active.

               

              When I test:

               

              1. Open Acrobat
              2. Open the report pdf (it has 2 pages, only the 2nd change)
              3. I hit the button that fires 'cambiarPagsEvaluacionDoppler'
              4. The alert at 'guardarInfo' shows the content (default text)
              5. The pages are swapped
              6. The alert at 'cargarInfo' (there was...in debugging) that shows global.buffer[i] shows the value ok, but
              7. the textbox renders ok

               

              close and on a second try

              1. Open Acrobat
              2. Open the report pdf
              3. Change the default value on a textbox
              4. I hit the button that fires 'cambiarPagsEvaluacionDoppler'
              5. The alert at 'guardarInfo' shows the content (default text)
              6. The pages are swapped
              7. The alert at 'cargarInfo' (there was...in debugging) that shows global.buffer[i] shows the value ok, but
              8. the changed textbox renders every new line of the value without the first character!

               

              I've done this page swapping back and forth from page a to b with/without restarting Acrobat and loading the document again

              • 5. Re: Multi-line textbox missing first character after new line
                try67 MVP & Adobe Community Professional

                Is it possible for you to share the file? Either via a file-sharing site, or privately (by email)...

                • 6. Re: Multi-line textbox missing first character after new line
                  tuvozinterna Level 1

                  Here's the pdf

                   

                  https://dl.dropboxusercontent.com/u/22863498/ReporteMedico-3.1-POST.pdf

                  +the code I posted before, it goes in a .js inside the user's privileged folder:

                   

                  • Vista and Windows 7:
                    Users\(username)\AppData\Roaming\Adobe\Acrobat\Privileged\10.0\JavaScripts.
                    For example, the new path might be
                    C:\Users\JoeUser\AppData\Roaming\Adobe\Acrobat\Privileged\10.0\JavaScripts
                  • XP:
                    Documents and Settings\(username)\Application Data\Adobe\Acrobat\Privileged\10.0\JavaScripts. For example, the new path might be: C:\Documents and Settings\JoeUser\Application Data\Adobe\Acrobat\Privileged\10.0\JavaScripts
                  • 7. Re: Multi-line textbox missing first character after new line
                    try67 MVP & Adobe Community Professional

                    OK... Now provide a user-case scenario the demonstrates the problem.

                    • 8. Re: Multi-line textbox missing first character after new line
                      tuvozinterna Level 1

                      That is:

                       

                      1. open the pdf report
                      2. scroll down to page 2
                      3. write some lines into the diagnostic field
                      4. hit 'Mostrar/Ocultar Tabla' button
                      5. (the pages* swap)
                      6. check the value <---- here's where it renders new lines without the first character
                      7. without modification, hit the button again
                      8. check the value <---- here the unaltered text should render ok

                       

                      and so, you can test going back and forth from page a to b to check how it works and add alerts or some other debugging code to guardarInfo() and cargarInfo().

                       

                      *by the way, you'll need these too

                      https://dl.dropboxusercontent.com/u/22863498/ReporteMedico3-Pagina2.zip

                      the zip contains the two versions of the 2nd page, with 'ductus venosus' table and without ductus venosus table, unzip the folder with the two pdfs into the privileged user folder (previous post)

                      • 9. Re: Multi-line textbox missing first character after new line
                        try67 MVP & Adobe Community Professional

                        If you remove the Rich Text Formatting option for the field it works fine. Also, I don't understand why you need the entire thing for replacing the line-breaks with "<br>" tags... It's not required at all.

                        • 10. Re: Multi-line textbox missing first character after new line
                          tuvozinterna Level 1

                          Thanks Gilad, that gives a workaround!

                           

                          I don't think that behavior is normal though, should I report it as a bug?

                           

                          The '<br>' thing was for trying to get rid of the newline character when I noticed it affected every new line, actually the whole if that observes the 'diagnosticoEcografico' field shouldn't be.

                          • 11. Re: Multi-line textbox missing first character after new line
                            try67 MVP & Adobe Community Professional

                            Yes, you can report it as a bug, although I'm not sure it's not a problem with your code. I noticed a bug it (although I don't think it's directly related to this issue, necessarily). Your replace command only replaces the first instance of a line-break, because it's not set as a global regular expression. So there could be more bugs that cause this problem...