Javascript in PDF form

Avatar

Avatar

equipment-studi

Avatar

equipment-studi

equipment-studi

27-06-2016

Hi guys,

I really have some problems with LCD and Javascript. I need three functions which I don't know to use without JS. So I tried JS but it didn't work, too

Maybe someone can help me with these (or at least one) of the following problems:

Start paramenters: PDF file exported from InDesign (IDML -> PDF) with basic form features (buttons). Now in LCD I need to make the finish, because of missing functionality in Acrobat Pro (which works quite better together with ID). And yes, I know that this workflow isn't best to choose, but I have to follow this in order to working in a team.

1. text auto-size: I need auto text size for some text fields. The text should have e.g. size 15, but if the field is full it should make auto size (shrink). I tried font size "0" but that did not work either. So I read about JS for auto size, but it does not like to work for me. I tried a "this.xxx" and if/else but without luck.

2. text overflow: I have multiple text fields for structure which should be filled with the same block of text (e.g. we have space for around 500 words per field and the text is 750 words long - so it should jump to textfield 2 (same page) and insert the last 250 words there.

3. PDF import: I have some images fields for inserting picture into the form. But because I want to insert a changing object (calendar with different month) I need a field, where I can insert a PDF (the calendar is made by a ID plugin, my working mate uses). The input should be in Acrobat / Reader after the form is finished so my mate can to that stuff. I tried an image field with a jpg/png which worked good - but because of scaling I would prefer PDF. So I tried JS (event.target.buttonImportIcon();) which I knew from Acrobat Pro. But that did not worked in LCD.

So anyone any ideas? Would be really happy about!!

Regards,

Florian

View Entire Topic

Avatar

Avatar

equipment-studi

Avatar

equipment-studi

equipment-studi

27-06-2016

Hi Karwan,

thank you very much for your quick answer.

According to my 1st problem: I need the text to resize (font size). The textfield cannot be resized because of a necessary fixed layout (background has a picture). Any ideas about character / font resizing?

2nd problem: Great solution! Thank you very much for that! It works (almost) perfectly! Just two minor questions: Is an overflow possible, which do not count characters but the "visual range"? That would make everything perfect 😉 But without it works well too!

Another little question: I have 3 following text fields. If I enter the text into the first field I got the code to field 1 and 2 so the text is overflowed into field 3. That's what I want. But in field 3 (if the text is much to long) it appears the little "+". So field 3 ignore the "visual range" function from LCD. Is there any code to declare to field 3 to stop when full?

Would that maybe work with the following script (extracted from your overflow)

  1. // Get the value of the text 
  2. var numchar = this.rawValue;
  3.  
  4. // Set the value of the first line to the sliced remaining 
  5. this.rawValue = numchar.slice(0,70); 

Could that work? (Without making background / stability problems?

3rd: I cannot find that function in my "object library" or under "insert". Where can I find this? 🙂 I'm not really familiar with LCD yet O.O

Thank you very much!

Regards,

Florian