Expand my Community achievements bar.

Print Option in PDF

Avatar

Former Community Member

Hi All,

I have a requirement where in i need to take a print of only few of the fields present in pdf. Can we create a customized print option other than default [Ctrl+p].

Regards,

Ali

7 Replies

Avatar

Level 10

Hi Ali,

I think you need to look at having some code in the prePrint event to hide the parts of the form that you don't want to print.

Bruce

Avatar

Former Community Member

Hi Bruce,

Thanks for your reply. we can also make any object visible/invisble on print. but my requirement is just to populate the data what the user has entered like for example Assume if there are 2 radio buttons and user has selected only one radio button the other radio button should not appear on print.

In brief i want to take a printout of the simple format summary of data the user has entered excluding headers/footers/images.

Regards,

Ali

Avatar

Level 10

Hi Ali,

There is a Report object that allows you to create a flat pdf file which you could then call the print method on.

var rep = new Report();

if (!RadioButtonList.Yes.isNull)

{

    rep.writeText("RadioButtonList set to Yes");

}

if (!RadioButtonList.No.isNull)

{

    rep.writeText("RadioButtonList set to No");

}

if (RadioButtonList.isNull)

{

    rep.writeText("RadioButtonList not set");

}

var d = rep.open("My Report");

d.print();

But there is not much formatting available, maybe too simple.  There more info in the "JavaScript for Acrobat API Reference".

Bruce

Avatar

Former Community Member

Hi Bruce,

Thanks but i am not able to create a variable of Report Class.

Its a simple line of code "var rep = new Report()" under button event giving below error any inputs

GeneralError: Operation failed.

Root.Report:2:XFA:form1[0]:#subform[0]:Button1[0]:click

Constructor function needs to be called with new

Regards,

Ali

Avatar

Level 10

Hi Ali,

Seems that the Report object is not available in Reader (only Acrobat).

John Brinkman has a post on this sort of print option, basically having two forms defined and flicking from one to the other in the prePrint/postPrint.

http://blogs.adobe.com/formfeed/2011/02/multiple-top-level-subforms.html

Bruce

Avatar

Former Community Member

Hi Bruce,

Thanks for your suggestion the link was helpfull. completed the requirement using one more Approach

My Approach goes like, i created a sub-form(hidden from layout) when user triggers print option following changes i made to occur:

  1. Changed the property of Sub-Form from Hidden to Visible under Pre-Print Event.
  2. Filled all the fileds in sub forms under pre-print Event.
  3. Under Post-print Event change the property back to Hidden.

But my question still is why i was not able to use Report() class ????????

Regards,

Ali

Avatar

Level 10

Hi Ali,

There are a couple of things that are not made available in Adobe Reader even if the form is enabled by Acrobat or LiveCycle and the Report object is one of them.

I didn't realise when I first suggestted it.

Bruce