Expand my Community achievements bar.

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

Printing button in PDF fillable form.

Avatar

Level 2

Dear All,

I have created a PDF fillable form with a button which save & print the pdf.

The code for is as fallow:

Formular1.#pageSet[0].Seite1.Bildfeld1::click - (JavaScript, client)

var Mailto = "info@stell.de";

var Betreff = Textfeld1.rawValue;

var Nachricht = "Dies ist eine Telefonnotiz\r2.Zeile Hier";

var CC = "info@stell.de";

var BCC = "info@stell.de";

var Mail = "mailto:" + Mailto + "?Subject=" + Betreff + "&Body=" + Nachricht + "&cc=" + CC + "&bcc=" + BCC;

  1. event.target.submitForm({

cURL: Mail,

bEmpty: false,

cSubmitAs: "PDF"

});

  1. event.target.closeDoc(true); (FormClac)

Formular1.#pageSet[0].Seite1.DruckenSchaltfläche1::click - (JavaScript, client)

  1. xfa.host.print(1, "0", (xfa.host.numPages -1).toString(), 0, 0, 0, 0, 0);

my problem now is that with this script I can print and save the file even though all required fields are not filled!! I donot anyone to have the possibility to print the file or save it unless he fill all required fileds.

  1. Any Idea, coz Iam new in the Adobe Livecycle world
1 Accepted Solution

Avatar

Correct answer by
Level 10

HI,

you can use the validate element to prevent users from printing a form.

See: http://forms.stefcameron.com/2008/04/13/prevent-printing-pdf-forms-in-acrobat-8/

But you never can prevent users from saving a form.

View solution in original post

17 Replies

Avatar

Correct answer by
Level 10

HI,

you can use the validate element to prevent users from printing a form.

See: http://forms.stefcameron.com/2008/04/13/prevent-printing-pdf-forms-in-acrobat-8/

But you never can prevent users from saving a form.

Avatar

Level 2

I just wanted to allow the users to print the PDF or save it ONLY when they have filled the entir document. this is not possible at all?

Avatar

Level 2

can I send you the document to know what I mean?

I canot upload it over here?

Avatar

Level 10

Please read the article under the link I posted before.

There you'll get all details of how to prevent the printing and a sample form you can work with.

Keep in mind that it isn't possible to prevent the saving, this only works for printing, submitting and data connections.

Avatar

Level 2

Thanks a lot for your reply

I sow the article, but the only problem is that the source code for the print button is exactly what I write and I cannot integrate the element code in it. Since in the article is says change the source code and look for

XML Source in Designer and find the following mark-up about 2/3 way down:

<config xmlns="http://www.xfa.org/schema/xci/1.0/">

<agent name="designer">

      ...

   </agent>

   <present>

      <!--  [0..n] -->

      ...

I don’t have this part in my script!

Avatar

Level 10

What version of Designer do you use?

Avatar

Level 10

Ok,

than you need to add the validate element under the <config> tag as it doesn't exist by default.

Before:

<config xmlns="http://www.xfa.org/schema/xci/3.0/">

   <agent name="designer">

      <!--  [0..n]  -->

      <destination>pdf</destination>

      <pdf>

         <!--  [0..n]  -->

         <fontInfo/>

      </pdf>

   </agent>

   <present>

      <!--  [0..n]  -->

      <pdf>

         <!--  [0..n]  -->

         <fontInfo/>

         <version>1.7</version>

         <adobeExtensionLevel>5</adobeExtensionLevel>

      </pdf>

      <xdp>

         <packets>*</packets>

      </xdp>

   </present>

</config>

After:

<config xmlns="http://www.xfa.org/schema/xci/3.0/">

   <agent name="designer">

      <!--  [0..n]  -->

      <destination>pdf</destination>

      <pdf>

         <!--  [0..n]  -->

         <fontInfo/>

      </pdf>

   </agent>

   <present>

      <!--  [0..n]  -->

      <pdf>

         <!--  [0..n]  -->

         <fontInfo/>

         <version>1.7</version>

         <adobeExtensionLevel>5</adobeExtensionLevel>

      </pdf>

      <xdp>

         <packets>*</packets>

      </xdp>

   </present>

   <!-- This is the validate element to prevent printing, when mandatory fields are empty -->

   <acrobat>

      <validate>prePrint</validate>

   </acrobat>

</config>

Avatar

Level 2

and where should I insert this code?

Avatar

Level 10

Go to the XML-Source and look for the <config> tag and add this snippet.

<acrobat>
      <validate>prePrint</validate>
</acrobat>

Avatar

Level 2

I donot want to ask silly questions , but really I canot find the XML source code. all what I can find is this:

Formular1.#pageSet[0].Seite1.Bildfeld1::click - (JavaScript, client)

var Mailto = "info@stell.de";

var Betreff = Textfeld1.rawValue;

var Nachricht = "Dies ist eine Telefonnotiz\r2.Zeile Hier";

var CC = "info@stell.de";

var BCC = "info@stell.de";

var Mail = "mailto:" + Mailto + "?Subject=" + Betreff + "&Body=" + Nachricht + "&cc=" + CC + "&bcc=" + BCC;

event.target.submitForm({

cURL: Mail,

bEmpty: true,

cSubmitAs: "PDF"

});

Formular1.#pageSet[0].Seite1.DruckenSchaltfläche1::click - (JavaScript, client)

xfa.host.print(1, "0", (xfa.host.numPages -1).toString(), 0, 0, 0, 0, 0);

Formular1.#subform[1].#subform[2].Tabelle3.Zeile1.#subform[1].#subform[2].Teilformularschaltfläche1entfernen::click - (JavaScript, client)

/*

   This button will Remove the current instance of the repeating subform or table row.

   bCalc: Flag - true if the removed instance might be referenced by other calculations, otherwise false.

   message: The error message displayed.

*/

var bCalc = true;

var message = "Sie haben die Mindestanzahl zulässiger Objekte erreicht.";

// DO NOT MODIFY THE CODE BEYOND THIS POINT - 9.0.0.2.20101008.1.725030.725025 - Subform_Instance_Controls_IRM.xfo.p4

var oWrapper = this.parent.parent;          // The outer subform built in to the object, enclosing the button group.

var oTargetSubform = oWrapper.parent;          // The subform or table row the controls are intended to manipulate.

var oManager = oTargetSubform.instanceManager;          // Get the instance manager.

var nMinCount = oManager.occur.min;                              // Get the minimum number of subform occurrences allowed.

var nSubCount = oManager.count;                                        // Get the current number of instances.

// Proceed if the minimum number of subform occurrences has not been reached.

if (nSubCount > nMinCount) {

 

          // Invoke the Instance Manager.

          oManager.removeInstance(oTargetSubform.index);

          // Fire the form calculations.

          if (bCalc == true) {

 

          // Execute all the form calculations.

          xfa.form.recalculate(1);

          }

} else {

          xfa.host.messageBox(message,"Remove Item", 3);

}

// END OF DO NOT MODIFY

Formular1.#subform[1].#subform[2].Tabelle3.Zeile1.#subform[1].#subform[2].Teilformularschaltfläche1hinzufügen::click - (JavaScript, client)

/*

   This button will insert one instance of the repeating subform or table row.

   bCalc: Flag - true if the new instance might be referenced by other calculations, otherwise false.

   message: The error message displayed.

*/

var bCalc = true;

var message = "Sie haben die maximale Anzahl zulässiger Objekte erreicht.";

// DO NOT MODIFY THE CODE BEYOND THIS POINT - 9.0.0.2.20101008.1.725030.725025 - Subform_Instance_Controls_IRM.xfo.p2

var oWrapper = this.parent.parent;          // The outer subform built in to the object, enclosing the button group.

var oTargetSubform = oWrapper.parent;          // The subform or table row the controls are intended to manipulate.

var oManager = oTargetSubform.instanceManager; // Get the instance manager.

var nMaxCount = oManager.occur.max;                     // Get the maximum number of subform occurrences allowed.

var nSubCount = oManager.count;                              // Get the current number of instances.

// Proceed if the maximum number of subform occurrences has not been reached.

if ((nMaxCount == "-1") || (nSubCount < nMaxCount)) {

 

          // Invoke the Instance Manager.

          var oNewInstance = oManager.addInstance(1);

          // Fire the form calculations.

          if (bCalc == true) {

          // Execute all the form calculations.

          xfa.form.recalculate(1);

          }

          // Move the new subform below the current one.

          var nIndexFrom = oNewInstance.index;

          var nIndexTo = oTargetSubform.index + 1;

          oManager.moveInstance(nIndexFrom, nIndexTo);

} else {

          xfa.host.messageBox(message,"Insert Item", 3);

}

// END OF DO NOT MODIFY

Formular1.#subform[1].#subform[2].Tabelle3.Zeile1.#subform[1].#subform[2].TeilformularschaltflächeNachOben1::click - (JavaScript, client)

/*

   This button will move the current instance of the repeating subform or table row up one position.

   bCalc: Flag - true if the moved instance might be referenced by other calculations, otherwise false.

   message: The error message displayed.

*/

var bCalc = true;

var message = "Das aktuelle Objekt kann nicht nach oben verschoben werden, da es sich bereits an erster Stelle befindet.";

// DO NOT MODIFY THE CODE BEYOND THIS POINT - 9.0.0.2.20101008.1.725030.725025 - Subform_Instance_Controls_IRM.xfo.p1

var oWrapper = this.parent.parent;          // The outer subform built in to the object, enclosing the button group.

var oTargetSubform = oWrapper.parent;          // The subform or table row the controls are intended to manipulate.

var nIndex = oTargetSubform.index                    // Get the index number of the current subform or table row.

var oManager = oTargetSubform.instanceManager;          // Get the instance manager.

// Proceed if the current subform is not the first instance.

if (nIndex != 0) {

 

          // Move the current subform.

          var nIndexFrom = nIndex;

          var nIndexTo = nIndex - 1;

          oManager.moveInstance(nIndexFrom, nIndexTo);

          // Fire the form calculations.

          if (bCalc == true) {

 

          // Execute all the form calculations.

          xfa.form.recalculate(1);

          }

} else {

          xfa.host.messageBox(message,"Move Item", 3);

}

// END OF DO NOT MODIFY

Formular1.#subform[1].#subform[2].Tabelle3.Zeile1.#subform[1].#subform[2].TeilformularschaltflächeNachUnten1::click - (JavaScript, client)

/*

   This button will move the current instance of the repeating subform or table row down one position.

   bCalc: Flag - true if the moved instance might be referenced by other calculations, otherwise false.

   message: The error message displayed.

*/

var bCalc = true;

var message = "Das aktuelle Objekt kann nicht nach unten verschoben werden, da es sich bereits an letzter Stelle befindet.";

// DO NOT MODIFY THE CODE BEYOND THIS POINT - 9.0.0.2.20101008.1.725030.725025 - Subform_Instance_Controls_IRM.xfo.p3

var oWrapper = this.parent.parent;          // The outer subform built in to the object, enclosing the button group.

var oTargetSubform = oWrapper.parent;          // The subform or table row the controls are intended to manipulate.

var oManager = oTargetSubform.instanceManager;          // Get the instance manager.

var nSubCount = oManager.count;                              // Get the current number of instances.

var nIndex = oTargetSubform.index                    // Get the index number of the current subform or table row.

// Proceed if the current subform is not the last instance.

if ((nIndex + 1) < nSubCount)  {

 

          // Move the current subform.

          var nIndexFrom = nIndex;

          var nIndexTo = nIndex + 1;

          oManager.moveInstance(nIndexFrom, nIndexTo);

          // Fire the form calculations.

          if (bCalc == true) {

 

          // Execute all the form calculations.

          xfa.form.recalculate(1);

          }

} else {

          xfa.host.messageBox(message,"Move Item", 3);

}

// END OF DO NOT MODIFY

Formular1.#subform[1].#subform[2].Tabelle3.Zeile1::indexChange - (JavaScript, both)

//{{Adobe LiveCycle Designer Generated Code Begin}} - row shading script. Don't modify it!

var Freqs=[1,1];

var Colors=["255,255,255","255,255,255"];

var nFreqSize = 0;

for (var i=0; i<Freqs.length; i++)

  nFreqSize += Freqs[i];

var nRelIndex = this.index % nFreqSize + 1;

for (var nRun=0; nRun<Freqs.length; nRun++)

{

   if (nRelIndex>Freqs[nRun])

   {

        nRelIndex -= Freqs[nRun];

   }

   else

   {

      this.border.fill.color.value = Colors[nRun];

      break;

   }

}

//{{Adobe LiveCycle Designer Generated Code End}} - row shading script.

Formular1.TABELLEN1.#subform[2].Tabelle4.Zeile1::indexChange - (JavaScript, both)

//{{Adobe LiveCycle Designer Generated Code Begin}} - row shading script. Don't modify it!

var Freqs=[1,1];

var Colors=["255,255,255","255,255,255"];

var nFreqSize = 0;

for (var i=0; i<Freqs.length; i++)

  nFreqSize += Freqs[i];

var nRelIndex = this.index % nFreqSize + 1;

for (var nRun=0; nRun<Freqs.length; nRun++)

{

   if (nRelIndex>Freqs[nRun])

   {

        nRelIndex -= Freqs[nRun];

   }

   else

   {

      this.border.fill.color.value = Colors[nRun];

      break;

   }

}

//{{Adobe LiveCycle Designer Generated Code End}} - row shading script.

Avatar

Level 2

would you like to take alook with team viewer ... only If you have time?

Avatar

Level 2

<config xmlns="http://www.xfa.org/schema/xci/2.8/">

   <agent name="designer">

      <!--  [0..n]  -->

      <destination>pdf</destination>

      <pdf>

         <!--  [0..n]  -->

         <fontInfo/>

      </pdf>

   </agent>

   <present>

      <!--  [0..n]  -->

      <pdf>

         <!--  [0..n]  -->

         <version>1.7</version>

         <adobeExtensionLevel>3</adobeExtensionLevel>

      </pdf>

      <common/>

      <script>

         <runScripts>server</runScripts>

      </script>

      <cache>

         <macroCache/>

      </cache>

      <xdp>

         <packets>*</packets>

      </xdp>

  

   <psMap>

      <font typeface="NewsGoth BT" psName="NewsGothicBT-Roman" weight="normal" posture="normal"/>

      <font typeface="NewsGothic LT" psName="NewsGothicLT" weight="normal" posture="normal"/>

      <font typeface="NewsGothic LT" psName="NewsGothicLT-Bold" weight="bold" posture="normal"/>

      <font typeface="NewsGothic LT" psName="NewsGothicLT-BoldOblique" weight="bold" posture="italic"/>

      <font typeface="NewsGothic LT" psName="NewsGothicLT-Oblique" weight="normal" posture="italic"/>

   </psMap>

<acrobat>
      <validate>prePrint</validate>
</acrobat>

</config>

** I found it & i have inserted the code! but its not working?

Avatar

Level 10

Hi,

TeamViewer is ok, but not at the moment.

Do you have time this evening at around 19:00?

Or can you share your form somewhere and post a link here?

Avatar

Level 2

the problem is iam working in a company from 7:00 till 17:00 (Germany time)

and all the programes & the sheets at my desktop computer , but if you have time tomorrow it will be perfect. sorry for all this mess, I have been trying to solve this issues but iam new in the field of java scrptiing

Avatar

Level 10

Keine Ursache.

Bis morgen dann!