image - How to show pictures held by a p:dataTable in PDF, when the p:dataTable is exported as a PDF by a p:dataExporter? -


i want show picture in top of <p:datatable> in primefaces. works in xhtml not working, when export pdf format. there anyway show pictures , css styles in pdf export?

this xhtml page.

<h:form>     <p:datatable id="mydata" value="#{userdata.employees}" var="employee"  >         <f:facet name="header">             <p:graphicimage value="/images/icon/mellatlogo.png" style="height: 100px"/>         </f:facet>         <p:column>             <f:facet name="header">name</f:facet>             <h:outputtext value="#{employee.name}" />         </p:column>         <p:column>             <f:facet name="header">city</f:facet>             <h:outputtext value="#{employee.city}" />         </p:column>         <p:column>             <f:facet name="header">date</f:facet>             <h:outputtext value="#{employee.date}" />         </p:column>     </p:datatable>     <p:panel header="export data">          <h:commandlink>             <p:graphicimage value="/images/icon/pdf.jpg" />             <p:dataexporter type="pdf" target="mydata" filename="mypdf" />         </h:commandlink>     </p:panel> </h:form> 

add logo pdf have use preprocessor attr in commandebutton

<h:commandlink>             <p:graphicimage value="/images/icon/pdf.jpg" />             <p:dataexporter type="pdf" target="mydata" filename="mypdf" preprocessor="#{yourbean.yourpreprocfunction}" />         </h:commandlink> 

your preprocess function sould like,

        public void yourpreprocfunction(object document) throws ioexception, badelementexception, documentexception{     document pdf = (document) document; servletcontext servletcontext = (serveletcontext) facescontext.getcurrentinstance().getexternalcontext().getcontext(); string logo = serveletcontext.getrealpath("")+file.separator+"images"+file.separator+"mellatlogo.png"; pdf.add(image.getinstance(logo));      } 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -