Expand my Community achievements bar.

SOLVED

solution needed: how to put certain Text content on given position of last page in form?

Avatar

Former Community Member

Hi Buddies,
I need your suggestions urgently on issue described below. Somehow long story. Appreciate your interest& suggestions.
==============Clip==============
I have a form design requirement that certain text content should only appear on a fixed position of the last page.
The form will be multi-pages.

Following is the way how I tried

1) On master page:
Add Text object lblEnding( w =176mm, h =45mm)
Wrap lblEnding into subform ( frmEnding)
Make frmEnding on position as required ( x=20mm, y =200mm, w=176mm);


2) On bodypage:
Add Text object lblBlank; ( no border& transparent). It's used for occuping the page area to flow the bodypage
Wrap lblBlank into subform frmBlank, flowed, top to bottom.

3) Note: The last required content of form template is a subform, called frmInfoBlock.

OK, then here comes to my scripting part.
---------------------------------------------------
1) On Master page:

// To configue frmEnding only appear on last page
// To control the presence of frmEnding based on pageCount()
// scripting on frmEnding
//
FormDeliveryNoteNotification.#pageSet[0].mstMasterPg1.frmEnding::ready:layout - (JavaScript, client)
if (xfa.layout.page(this)!= xfa.layout.pageCount()) this.presence = "hidden";

2) On Bodypage:
// To control the presence of frmBlank based on its position ( property "y")
// scripting on frmBlank
//
FormDeliveryNoteNotification.bdyPage1.frmBlank::ready:form - (JavaScript, client)
var y1 = this.y;
var y2 = frmInfoBlock.y;
var h2 = frmInfoBlock.h;

var yNum1 = parseInt(y1);
var hNum2 = parseInt(h2);
var yNum2 = parseInt(y2);

this.presence = "visible";
if (yNum1 <= "200")
{
if(yNum2 + hNum2 <"200" )
  this.presence ="hidden";
}

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

Later I found it not worked as expected.
As for property "y"
>>>>
Specifies the y coordinate of a container’s anchor point relative to the top-left corner of the parent
container when placed with positioned layout.
Containers with flowed content do not use y coordinates.
>>>>

As subforms inc. frmBlank & frmInfoBlock all are flowed, variables in above scripts, always have value as below( based on my debugging result)
y1=0 in
y2=0 in
h2=0 in

Accordingly, inc. yNum1, yNum2, hNum2 are always 0.

Result is:

frmBlank will always be hidden

If only 1 page, the bodypage count can be overlapped with master page frmEnding.

==============Clap==============
Hope I've described things clear. :-P

Can you provide your suggestions as alternative suggestion.

-VickyX

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi Vicky,

See if this helps you: https://acrobat.com/#d=Qjw-*VtT-gNdWjP*rlx2HA

Check out the line which acts as a marker for the y coordinates. The script is in the subform spacer.

Good luck,

Niall

View solution in original post

9 Replies

Avatar

Level 10

Hi,

I think you can achieve this without script.

Set up a second Master Page and set its Min count and Max count to "1". Place this as the second Master Page in the hierarchy and put the standard text in the position you want it. Reduce the content area so that the standard text is outside of the content area.

This should always be the last page at runtime.

Hope that helps,

Niall

Avatar

Former Community Member

Hi Niall,

Thanks for reply.

Firstly, something I missed in my previous posting:

>>>>

There're already 2 master pages in my form design.

mstMasterPg1: Used as front-cover page. Occurrece: Min 1, Max 1;

mstMasterPg2: Used for extended form content, from page 2~n. Occurrence: None.

>>>>

So, if I add mstMasterPg3 as the back-cover, per your suggested:

mstMasterPg3: Occurrence; Min 1, Max 1.

Result is:

There will always be at least 2 pages in print-out.

There can be cases that,

1) content is finished within page1~n,

2) stardard text will not be overlapped with content on pagen

3) but as mstMasterPg3 added, there will be additionally 1 more page only with the stardard text ( nothing in content area).

==>The last page is somehow "wasted" .

That's why I tried with script.

-VickyX

Avatar

Level 10

Hi,

I might have a solution where the standard text is on the design pages. There is a subform in-between this and the flowed content above. Script in the layoutReady event changes the height of this spacer subform depending on the amount of space taken up by the flowed content. EG: small amount of data means spacer height is large to keep standard text at y=200. If there is a lot of data, then spacer height is reduced.

There is a form here when I use the h values and then script appropriate actions. Re: Repeating Sections

I wont get back to this again until tonight.

Niall

Avatar

Former Community Member

Hi,

I played around with property h, still can not find a way out.

Root cause is that I failed to fetch the height of flowed-content above the fixed-text.


Is it ok I send the xdp to you? ( I don't know how to upload it here in this forum ).

Many thanks.

-Vicky

Avatar

Level 10

Hi, I am out of office for the day. You can upload to http://www.acrobat.com, publish the file and then share the published link here. Niall

Avatar

Correct answer by
Level 10

Hi Vicky,

See if this helps you: https://acrobat.com/#d=Qjw-*VtT-gNdWjP*rlx2HA

Check out the line which acts as a marker for the y coordinates. The script is in the subform spacer.

Good luck,

Niall

Avatar

Former Community Member

Hi Niall,

Many thanks for the help! I figured out the way to solve this problem.

====================CLIP========================================

Way1 ( as you suggested)

1) Form hierarchy:

(Master Pages)

--| mstMasterPg1 ( Occurrence: Max=1, Min=1)

----| ...

----| subform frmEndingInfo ( positioned, started from y=200mm, with stard text h =45mm)

--| mstMasterPg2

----| ...

----| subform frmEndingInfo ( positioned, started from y=200mm, with stard text h =45mm)

Bodypage

--| subform frmMain ( flowed)

--| Line InMarker

--| subform frmHold ( flowed, wraping blank text filed h=45mm; default invisible)

2)

>>>>Scripting on masterpages

/*

     If not the last page, the stard content frmEndingInfo will not be present

*/

FormDeliveryNoteNotification.#pageSet[0].mstMasterPg1.frmEndingInfo::ready:layout - (JavaScript, client)
if (xfa.layout.page(this)!= xfa.layout.pageCount()) this.presence = "hidden";

FormDeliveryNoteNotification.#pageSet[0].mstMasterPg2.frmEndingInfo::ready:layout - (JavaScript, client)
if (xfa.layout.page(this)!= xfa.layout.pageCount()) this.presence = "hidden";

>>>>Scripting on bodypage

/*

     If the line InMarker's y is less than 200mm, then frmMain won't be overlapped with frmEndingInfo => make the spacer frmHold "hidden"

     If the line InMarker's y is more than 200mm, overlap will be occur => make the spacer frmHold "invisible" as default ( occuping the space)

*/

FormDeliveryNoteNotification.bdyPage1.frmHold::ready:layout - (JavaScript, client)
var yMarker = xfa.layout.y(InMarker);
if(yMarker <200)
{
this.presence= "hidden";
}
xfa.layout.relayout();

====================CLAP========================================

I think most tricky tip here is to put a fixed-content-object between 2 flowed subforms, eg: Line  InMarker.

Only its property 'y" could accurately reflect the exact starting position of content below it.

Use this "y" to judge if frmMain is overlapped with frmEndingInfo.

If I use:

var yMarker = xfa.layout.y(frmHold)

Then this "yMarker" won't have the accurate value as threshold. ( sometime it does ( as 1.xml given below), sometime not ( as 2.xml and 3.xml given below)).

For me it's remaining a question mark for current "solved" question here.

====================CLIP========================================

Here is the form design file: https://acrobat.com/#d=ReRCCAr2XyKNgh6JM6AQTg

Note:

I make the frmHold visible as default, just in order to show the difference between  xfa.layout.y(frmHold) and  xfa.layout.y(InMarker).

In practice it should be "invisible".

Sample data

1.xml: https://acrobat.com/#d=4GoCw-wDbkerGdgdW86nNg

2.xml: https://acrobat.com/#d=oRmZHH8SO*vtvJPqBTtvbQ


3.xml:  https://acrobat.com/#d=Yi1EKDA*zBnNpZAmESQ6tw

====================CLAP========================================

Avatar

Former Community Member

Hi Niall,

This is the 2nd way I found to solve the problem. Just paste it here for correction & improving suggestions, if needed.

====================CLIP ==============================

Way2 ( without InMarker, but played around with “h”)

1) Form hierarchy:

(Master Pages)

--| mstMasterPg1 ( Occurrence: Max=1, Min=1)

----| ...

----| subform frmEndingInfo ( positioned, started from y=200mm, with stardard text h =45mm)

--| mstMasterPg2

----| ...

----| subform frmEndingInfo ( positioned, started from y=200mm, with stardard text h =45mm)

Bodypage

--| subform frmMain ( flowed)

--| subform frmHold ( flowed, wraping blank text filed h=45mm; default invisible)

2)

>>>>Scripting on masterpages ( same as way1)

if (xfa.layout.page(this)!= xfa.layout.pageCount()) this.presence = "hidden";

>>>>Scripting on bodypage

FormDeliveryNoteNotification.bdyPage1.frmMain::ready:layout - (JavaScript, client)

var vPage = xfa.layout.page(this);

var strHeight=xfa.layout.h(this);

if( vPage==1) // if only one page in total

{      

        //115  is the height of ctaPg1Cta1

        strHeight = strHeight%115;

       

        // 200-133=67, which is the largest value of frmMain.h on page-1

        /*

                if frmMain.h is more than 67mm, it will be overlapped with frmEndingInfo on Master page1

                ==> frmHold should be "invisible" as default(occupying the space)

               

                if frmMain.h is less than 67mm, it will be upper than frmEndingInfo on Master page1

                ==> frmHold should be "hidden"

                */

        if (strHeight <= "67")

        {

                frmHold.presence="hidden";

        }

}

else if (vPage>1)// if more than 1 pages in total

{

        //115 is the height of ctaPg1Cta1 ( for page 1)

        strHeight = strHeight-115;

        //177 is the height of ctaPg2Cta1 ( for page 2~n-1)

        strHeight = strHeight%177;

       

        // frmMain height on page-n

        if (strHeight <= "128")

        {

                // 200-72 =128, which is the largest value of frmMain.h on page-n( n>=2)

                /*

                if frmMain.h is more than 128mm, it will be overlapped with frmEndingInfo on Master page2

                ==> frmHold should be "invisible" as default(occupying the space)

               

                if frmMain.h is less than 128mm, it will be upper than frmEndingInfo on Master page2

                ==> frmHold should be "hidden"

                */

                frmHold.presence="hidden";

        }

}

xfa.layout.relayout();

====================CLAP ==============================

Avatar

Level 10

Glad you have it working Vicky

Niall