Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Javascript in PDF form

Avatar

Level 2

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

1 Accepted Solution

Avatar

Correct answer by
Level 3

Dear,

please note that if you import forms ready into LCD then you need to choose interactive layout not fixed layout. otherwise some of the characteristics of LCD will not work properly. and you need to recreate your fields to get the fully functions of LCD. I will see if there is way around this what you want to do for the limit length to visible area. but I am not sure if I understand your third point. can you explain more.

if my answer gives help please mark as correct Answer

@#Karwan!

@Kurdistan

View solution in original post

8 Replies

Avatar

Level 3

Hello,

here is the answers:

1- You can set the field to auto fit in height or width or both in the layout Tab on the right or left side of you live cycle program as per your organization

Capture.JPG

2- for this you can get help from this thread (create an irregular form field )

3 - for this one you can put attach file field in the form.

if my answer gives help please mark as correct Answer

@#Karwan!

@Kurdistan

Avatar

Level 2

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

Avatar

Level 3

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?

for above, please follow below screen shots.

Step1

step 1.jpg

Step 2

step 2.jpg

----------------------------------------------------------------------------------------------------------------------------------

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)

For this one Please follow below screen shot

Select the 3rd text field and do as below. (Limit length to visible area)

Capture.JPG

-------------------------------------------------------------------------------------------------------------------------------------------------

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

for above, your main issue is scaling, you can insert image field or Image and make the size same size of the thing you are inserting it.

if my answer gives help please mark as correct Answer

@#Karwan!

@Kurdistan

Avatar

Level 2

Hi Karwan,

1st: that way I tried before - but without success :-( could the problem be, that I cannot switch the "edit value" mode like you showed in step 2? I have no access to that option. Maybe because of the import structre? The textfield is created in InDesign and imported as fixed layout to LCD.

Screen Shot 2016-06-30 at 10.45.37.png

2nd: this point I activated. But the "visible area" seems to be overwritten by the JavaScript - with or without that option the same problem appears. Maybe this is according to the same problem like in 1) ? That the imported PDF from InDesign let these problems appear?

3rd: Maybe we misunderstood - the mail problems isn't to scale the calender image (it has the same size like the field). But the problem is that afterwards the file should be scaled from e.g. DIN A3 to DIN A5 (quarter of size). This makes using JPG or PNG quite hard. But if there isn't any way to insert (and SHOW) the pdf (not as "attached file" proper), I will get this working with an highres image.

Most important it seems to get 1st and 2nd to work - but I don't know wether these problems are because of the fixed import instead of creating a clean form?

Thank you very much.

Regards,

Florian

Avatar

Correct answer by
Level 3

Dear,

please note that if you import forms ready into LCD then you need to choose interactive layout not fixed layout. otherwise some of the characteristics of LCD will not work properly. and you need to recreate your fields to get the fully functions of LCD. I will see if there is way around this what you want to do for the limit length to visible area. but I am not sure if I understand your third point. can you explain more.

if my answer gives help please mark as correct Answer

@#Karwan!

@Kurdistan

Avatar

Level 2

Hi Karwan,

I imported every time as fixed layout because otherwise all fields were moved around. But you are right, I think, that I need to use interactive layout and/or recreate some fields to get all functionality from LCD I need. Thank you very much for your support. I really appreciate that!

I try to figure out the gist of point 3. As non-native speaker I'm not so versatile with English.

What I need an image field where an image is displayed to the reader. But this field has to be imported by the user. As far as this a "normal" image field. But the file, that has to be imported / displayed has to be in PDF format.

You know the Acrobat Pro workaround for an image field? https://forums.adobe.com/thread/994408

That is a discussion about that. The JavaScript for that in Acrobat Pro is event.target.buttonImportIcon();

It creates a virtual image field which can be filled with only PDF "images" which are displayed like pictures.

Thanks a lot.

Redards,

Florian

Avatar

Level 10

@2nd question: Here's a solution you should try — Field Tab on Full

@3rd question: Forget about it. You can't import PDF's in a LiveCycle form — only 8 bit RGB images.

Avatar

Level 2

Hi Karwan, hi radzmar,

thank you both for explaining and helping in this case.

Beaucse I cannot mark 2 correct answers, I hope you (radzmar) won't be upset that I marked Karwan as first "explainer". Hope I can count on you both with my future questions :-)

Thank you very much! I got a lot further in my work!

Kindly regards,

Florian