Multi-table custom exporter problem

Community Driven Extensions Project
Post Reply
marabacioglu
Posts: 67
Joined: 09 Dec 2012, 00:06

26 Dec 2013, 08:46

If we add peport headers in preProcessor only the last table is printed and it is printed over the report headers.
Related part of xhtml:

Code: Select all

<h:panelGrid>
            <p:panel header="#{messages.exportAllData}">

               <h:commandLink>
                  <p:graphicImage value="/img/excel.png" />
                  <pe:exporter target="memberList, memberList3, memberList2" type="xlsx" encoding="cp1254"
                     fileName="#{messages.retirementOperationsReport}" datasetPadding="4" />
               </h:commandLink>

               <h:commandLink>
                  <p:graphicImage value="/img/pdf.png" />
                  <pe:exporter type="pdf" target="memberList, memberList3, memberList2"
                     fileName="#{messages.retirementOperationsReport}"
                     preProcessor="#{retirementOperationsService.preProcessPDF}" datasetPadding="4" />
               </h:commandLink>

            </p:panel>
         </h:panelGrid>
Related part of preprocessor:

Code: Select all

public void preProcessPDF(Object document) throws IOException,
         BadElementException, DocumentException {
      Calendar c = Calendar.getInstance();
      c.setTime(date);
      byte month = (byte) (c.get(Calendar.MONTH) + 1);
      short year = (short) c.get(Calendar.YEAR);
      String title = "memberList";
      String headerText = month + "/" + year + " "
            + messages.get("memberAndRetirementMovements");
      TrustUtility.prepareHeader(document, title, headerText, date);
   }

Code: Select all

public static void prepareHeader(Object document, String title,
         String headerText, Date startDate) throws DocumentException,
         IOException {
      BaseFont times = BaseFont.createFont("Times-Bold", "cp1254",
            BaseFont.NOT_EMBEDDED);
      Font font = new Font(times, 15);
      Document pdf = TrustUtility.preparePdfMetaData(document, Messages
            .instance().get(title));
      pdf.open();
      Paragraph paragraphHeader1 = prepareHeader1(pdf.getPageSize()
            .getRotation() == 0);
      Paragraph paragraphHeader2 = prepareHeader2(pdf.getPageSize()
            .getRotation() == 0);
      Paragraph paragraphEmptyLine = prepareEmptyLine();
      Paragraph paragraph3 = prepareHeaderdateRangeVerTwo(startDate);
      Paragraph paragraph4 = prepareHeader(Messages.instance()
            .get(headerText), font);
      pdf.add(paragraphHeader1);
      pdf.add(paragraphHeader2);
      pdf.add(paragraphEmptyLine);
      pdf.add(paragraph3);
      pdf.add(paragraph4);
      pdf.add(paragraphEmptyLine);
   }
Primefaces 6.0 JSF 2.1 Wildfly 8

User avatar
sudheer
PrimeFaces Core Developer
Posts: 4345
Joined: 16 Oct 2011, 19:19
Location: Singapore

29 Dec 2013, 18:46

As I said earlier please provide the snapshot of your issue.Could you please elaborate about issue.

Thanks!!!
Author,Speaker
https://twitter.com/sudheerjonna
Github: https://github.com/sudheerj
Website http://sudheerjonna.com/

___________________
Sudheer Jonna

marabacioglu
Posts: 67
Joined: 09 Dec 2012, 00:06

30 Dec 2013, 16:36

sudheer wrote:As I said earlier please provide the snapshot of your issue.Could you please elaborate about issue.

Thanks!!!
I tried to explain the issue very clearly in my post. In short; yes multi-table export works very well if we don't need a report header but just the table headers for each table.

We add those header paragraphs in the preprocessor method. You can follow this in the quoted code pieces. But if we run this, we get only the last table and it is printed over the report headers. You can test this easily by adding a few paragraphs to document after opening it in the preprocess method.

I hope this is sufficient.
Primefaces 6.0 JSF 2.1 Wildfly 8

User avatar
sudheer
PrimeFaces Core Developer
Posts: 4345
Joined: 16 Oct 2011, 19:19
Location: Singapore

31 Dec 2013, 09:37

Hi marabacioglu,

If you are using a custom exporter feature,please comment the blank empty lines code of PDFExporter export method and then try to reproduce it.If i get time i will make a test on showcase application.
Author,Speaker
https://twitter.com/sudheerjonna
Github: https://github.com/sudheerj
Website http://sudheerjonna.com/

___________________
Sudheer Jonna

marabacioglu
Posts: 67
Joined: 09 Dec 2012, 00:06

02 Jan 2014, 17:46

I don't use any custom exporter feature. The following code would be sufficient for testing:

Code: Select all

<p:commandLink id="pdf" ajax="false">  
	<p:graphicImage value="/resources/images/pdf.png"/>    
	<pe:exporter type="pdf" target="messageTable,messageDetailsTable" fileName="MessagesAndDetails"  
		preProcessor="#{messageTableController.preProcessPDF}"
		datasetPadding="4"/>  
</p:commandLink> 
And in the controller:

Code: Select all

public void preProcessPDF(Object document) throws IOException,
			BadElementException, DocumentException {
	pdf.open();
	Paragraph paragraphHeader1 = "Test Header 1";
	Paragraph paragraphHeader2 = "Test Header 2";
	pdf.add(paragraphHeader1);
	pdf.add(paragraphHeader2);
}
Primefaces 6.0 JSF 2.1 Wildfly 8

marabacioglu
Posts: 67
Joined: 09 Dec 2012, 00:06

06 Jan 2014, 17:42

Problem is resolved.
The root cause of the problem was that preProcessor method is executed before every report in the target list and this was not what I expected. which caused open method and metadata preparation multiple times.
Controlling this in preprocessor method solved the problem.
Primefaces 6.0 JSF 2.1 Wildfly 8

rajb
Posts: 4
Joined: 23 Jun 2015, 20:41

23 Jun 2015, 20:47

marabacioglu wrote:Problem is resolved.
The root cause of the problem was that preProcessor method is executed before every report in the target list and this was not what I expected. which caused open method and metadata preparation multiple times.
Controlling this in preprocessor method solved the problem.
I have the same issue.
could you please explain more how you resolved the issue?

rajb
Posts: 4
Joined: 23 Jun 2015, 20:41

23 Jun 2015, 20:48

I have the same issue.

Could you please explain more how you resolved the issue?

Post Reply

Return to “Extensions”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 3 guests