Header and footer on the loose after upgrade

Hi all,

At my company we are working on upgrading from iReport 5.1.0 to JasperSoft Studio 6.20.0, and with this move also upgrade Aspose.Words for JasperReports from 19.12 to 22.12.
Not sure if it matters but we are using generated XML-files as datasources for our reports.

Most seems to go well but we are having an issue with headers and footers on the reports no longer sticking in the header and footer part of the word documents we are creating and I was wondering if anyone have had similar issues or if there is anything I can look at to fix this. This makes it so the footer isn’t always at the end of the document and also gives us one last page with only the header and footer information which can be quite annoying.

It worked previously and haven’t changed anything in the reports, only updated versions so was searching for any help.

Not sure if it is a Jasper issue or Aspose issue but the previous in Jasper doesn’t seem to place the header/footer correct in docx so I assume it is related to Aspose to put them where they should be.

One aspose thing I found was to et AWExporterParameter.RECOGNIZE_FIELDS = true which we have since before.

Have a good day

Write you later / MĂĄrten

@marten.carlzon Could you please attach your sample report and output documents produced by the old and new versions of Aspose.Words for JasperReports? We will check the issue and provide you more information.

Sorry, missed it and went home from work shortly after posting my question.
But here is the entire setup for the report. b_rapport.jrxml is the main report, DataSource.xml is the xml with the data to build the report from. And then two word documents showing the result, one with the old versions, and one with the new versions.
I am finding more differences/errors but I think the header/footer issue is my biggest and if that can be resolved I hope I can fix the rest :slight_smile:

Thanks for any help
Write you later / MĂĄrten

b_rapport.7z (83.5 KB)

@marten.carlzon Thank you for additional information. For a sake of correction the problem has been logged as WORDSJR-335. We will keep you posted and let yo uknow once it is resolved or we have more information for you.

1 Like

I am not sure if it would help, but remembered that maybe the settings we have could be an indication too (although we changed nothing with the update)

And just curious if it is possible for any ETA? As we are about to deliver to a customer and we would like to have some information to them. But as a developer myself I know it is not always easy to find these type of errors so is most if you have any information, otherwise it will take the time it takes :slight_smile:

AWDocxExporter exporter = new AWDocxExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);

// Tvinga section-breaks för att det ska se correct ut vid liggande
final boolean isLandscape = jasperReport.getOrientationValue() == OrientationEnum.LANDSCAPE;
exporter.setParameter(AWExporterParameter.PAGE_BREAKS,
		isLandscape ? AWExporterParameter.PAGE_BREAKS_SECTIONS : AWExporterParameter.PAGE_BREAKS_NORMAL);

exporter.setParameter(AWExporterParameter.LICENSE, args.getLicenceFilePath());
if (args.isUseDefaultMargins()) {
	exporter.setParameter(AWExporterParameter.PAGE_MARGINS, "85pt;70pt;28pt;14pt");
}
exporter.setParameter(AWExporterParameter.RECOGNIZE_FIELDS, true);
exporter.setParameter(AWExporterParameter.EXPORT_LINES, true);
exporter.setParameter(AWExporterParameter.SPACING_FACTOR, 0.5d);
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, args.getGeneratedReportPath());
exporter.setParameter(AWExporterParameter.USE_EXACT_ROW_HEIGHTS, args.isUseExactRowHeights());
exporter.setParameter(AWExporterParameter.POSITIONED_STYLE, "EmptyStyle");
if(args.getDocxCompatibility() != null) {
	exporter.setParameter(AWExporterParameter.DOCX_COMPATIBILITY, args.getDocxCompatibility());
}

exporter.exportReport();

@marten.carlzon Currently, the issue is scheduled to be resolved before the next 23.1 release of Aspose.Words for JasperReports. This version will be released within a month or so. But please note, this is a rough estimate and can be shifted.
We will be sure to inform you once the fix is available.

Okay thanks! Yea, totally understand it can be shifted but always good to have something to have as a potential date even though it can be delayed so thanks again.

1 Like

Hi, I noticed that 23.1 have been released but I couldn’t see that WORDSJR-335 was in the release noticed. Have this issue been solved there? That when I have subreports in header/footer it breaks or will it come later?

@marten.carlzon Unfortunately, we did not manage to fix the issue before the 23.1 release. Please accept our apologies for your inconvenience.

Ahh then I know, thanks for letting me know.

1 Like

The issues you have found earlier (filed as WORDSJR-335) have been fixed in this Aspose.Words for JasperReports 23.2 update.

Thanks for letting us know and thanks for a quick fix!

Try to use

exporter.setParameter(AWExporterParameter.PROCESS_SUBREPORT_HEADER_AS_HEADER, true);
exporter.setParameter(AWExporterParameter.PROCESS_SUBREPORT_FOOTER_AS_FOOTER, true);

In my tests this prarmeters can fix the problem.

1 Like

Sadly didn’t seem to resolve our issue, if I have a subreport in header/footer area I still have the same issue.
I have set the following parameters:

AWDocxExporter exporter = new AWDocxExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);

// Tvinga section-breaks för att det ska se correct ut vid liggande
final boolean isLandscape = jasperReport.getOrientationValue() == OrientationEnum.LANDSCAPE;
exporter.setParameter(AWExporterParameter.PAGE_BREAKS,
        isLandscape ? AWExporterParameter.PAGE_BREAKS_SECTIONS : AWExporterParameter.PAGE_BREAKS_NORMAL);

exporter.setParameter(AWExporterParameter.LICENSE, args.getLicenceFilePath());
if (args.isUseDefaultMargins())
{
    exporter.setParameter(AWExporterParameter.PAGE_MARGINS, "85pt;70pt;28pt;14pt");
}
exporter.setParameter(AWExporterParameter.RECOGNIZE_FIELDS, true);
exporter.setParameter(AWExporterParameter.EXPORT_LINES, true);
exporter.setParameter(AWExporterParameter.SPACING_FACTOR, 0.5d);
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, args.getGeneratedReportPath());
exporter.setParameter(AWExporterParameter.USE_EXACT_ROW_HEIGHTS, args.isUseExactRowHeights());
exporter.setParameter(AWExporterParameter.POSITIONED_STYLE, "EmptyStyle");
if (args.getDocxCompatibility() != null)
{
    exporter.setParameter(AWExporterParameter.DOCX_COMPATIBILITY, args.getDocxCompatibility());
}

exporter.setParameter(AWExporterParameter.PROCESS_SUBREPORT_HEADER_AS_HEADER, true);
exporter.setParameter(AWExporterParameter.PROCESS_SUBREPORT_FOOTER_AS_FOOTER, true);

logInfo("New parameters set");

exporter.exportReport();

I sadly still get the issue that my subreports are dealt with as part of the normal document instead of the header/footer area. I am running with the aspose.words.jasperreports-23.2.0-7.8.0-8.0.0.jar jar from your library.

Could there be conflicting parameters or something that we are using?

@marten.carlzon Could you please attach your .jrprint file?
I can’t reproduce this bug with complex .jrxml structure on my side, and .jrprint easy to use in tests.

I am not sure how to get the.jprint file, I have .jasper and .jrxml file, but I assume the .jprint is while you are actually making the file?

For quick and easy testing I made the following:
Main report:

  • Header through subreport
  • One details band with static text, detail 1
  • Footer through subreport

Header subreport:

  • Static text in detail 1 saying “Header”

Footer subreport:

  • Static text in detail 1 saying “Footer”
    And got the following word file.

asposeExampleSubreportHeaderFooter.docx (13.8 KB)
AsposeHeaderFooter.zip (24.4 KB)

For creating .jrprint you can use JasperFillManager.fillReportToFile method.
I still need .jrprint file and can’t create report with your .jrxml files.

I opened the following new ticket in our internal issue tracking system
WORDSJR-342

Okay, I have found that we make a jasperPrint objekt in our java class:

final JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, args.getReportParams());

We also set it in the exporter with following:

exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);

Now to get the info to a jrprint file as we don’t seem to save it to an actual file anywhere :slight_smile:

Might have succeded, here is a jrprint file and I did as follow:

File debugFile = new File("C:\\installs\\riku\\log\\report\\debugFile" + System.currentTimeMillis() + ".jrprint");
debugFile.createNewFile();

JasperFillManager.fillReportToFile(jasperReport, debugFile.getAbsolutePath(), args.getReportParams());

Hopefully it can give you the help you need. But the exporter parameters, for instance the one you mentioned with PROCESS_SUBREPORT_HEADER_AS_HEADER is set on the exporter, not the JasperFillManager :thinking:debugFile1678111504074.zip (2.7 KB)

Thank you for additional information.
Now I reproduce bug and started analysis the issue.

In first glanse in all other tests with header/footer with subreports:

  • Header and Footer exist in main report
  • Header and Footer exist in subreport

AWExporterParameter.PROCESS_SUBREPORT_HEADER_AS_HEADER recognize header in subreprot and use it. but in your report no header and footer in subreports and solution for WORDSJR-335 didn’t work