5

I need to be able to isolate 2 places in my JSF page to send to the PrimeFaces Printer component. Unfortunately I can not find an example of how to do this anywhere including the PrimeFaces documentation. Surely this command is more flexible than just taking in one target?

Using PrimeFaces 6.2

I tried this:

<p:commandButton value="Print in a PRINTER FREINDLY format">
     <p:printer target="area1" />
     <p:printer target="area2" />
</p:commandButton>
    
<p:outputPanel id="area1">
...
</p:outputPanel>
    
...bunch of code between these two output panels...

<p:outputPanel id="area2">
...
</p:outputPanel>

no error shows up however only the target that is put first shows up in the print page.

Doing this:

<p:printer target="area1 area2" />

results in a error.

Can someone please advise on how I can have multiple targets for the printer command in PrimeFaces?

Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
  • it might just be that you can't. The source IS open and free to use to investigate – Kukeltje Apr 30 '18 at 21:05
  • Yes @Kukeltje perhaps you are right about not currently being able to. If I have some time I will certainly investigate. In the mean while a colleague suggested I use CSS, https://www.w3schools.com/cssref/css3_pr_mediaquery.asp –  Apr 30 '18 at 23:52

2 Answers2

0

add your areas in a form and use:

<p:printer target=":form:printable" />
Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
Ethem
  • 13
  • 5
0

No, you cannot "target" multiple components using the p:printer behavior. You can just use one single component. If there are certain section(s) within the component you don't want to be printable, just hide the sections(s) using CSS media queries.

Something like:

@media print {
    cssSelectorToHide {
        display: none !important;
    }
}

See also:

Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102