Page 1 of 1

Multi-table custom exporter problem

Posted: 26 Dec 2013, 08:46
by marabacioglu
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);
   }

Re: Multi-table custom exporter problem

Posted: 29 Dec 2013, 18:46
by sudheer
As I said earlier please provide the snapshot of your issue.Could you please elaborate about issue.

Thanks!!!

Re: Multi-table custom exporter problem

Posted: 30 Dec 2013, 16:36
by marabacioglu
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.

Re: Multi-table custom exporter problem

Posted: 31 Dec 2013, 09:37
by sudheer
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.

Re: Multi-table custom exporter problem

Posted: 02 Jan 2014, 17:46
by marabacioglu
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);
}

Re: Multi-table custom exporter problem

Posted: 06 Jan 2014, 17:42
by marabacioglu
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.

Re: Multi-table custom exporter problem

Posted: 23 Jun 2015, 20:47
by rajb
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?

Re: Multi-table custom exporter problem

Posted: 23 Jun 2015, 20:48
by rajb
I have the same issue.

Could you please explain more how you resolved the issue?