Wrong page number with dynamic text field (Separate run/render task) [message #1000747] |
Tue, 15 January 2013 06:25  |
Eclipse User |
|
|
|
Hello BIRT friends,
I have a very simple BIRT report with one dynamic text field and a long constant text. It forces a page break, when I create a PDF file.
There is no problem, if I use a RunAndRenderTask to create this report as PDF. The page numbers are: 1/2, 2/2. (as expected)
But if I use a separate run and render task, the text is included twice, and the page numbers are: 1/2, 1/2, 2/2, 2/2. (The PDF file has 4 pages)
I use following code for rendering. (I know that RunAndRenderTask works, but I need it in that way for further manipulations)
final IRunTask runTask = this.engine.createRunTask(this.design);
runTask.run(temporaryBirtDocument.getCanonicalPath());
final IReportDocument reportDocument = this.engine.openReportDocument(temporaryBirtDocument.getCanonicalPath());
final IRenderTask renderTask = this.engine.createRenderTask(reportDocument);
renderTask.setRenderOption(this.renderOptions);
renderTask.render();
runTask.close();
If I change the Layout of the BIRT report from "Fixed Layout" to "Auto Layout" everything works fine. But this is not a solution for me.
Do you know this problem? Do you have a solution for me?
I am using BIRT 3.7.2. The sample report is attached.
|
|
|
|
|
|
Re: Wrong page number with dynamic text field (Separate run/render task) [message #1006034 is a reply to message #1000991] |
Tue, 29 January 2013 10:39  |
Eclipse User |
|
|
|
Ok, I've created a very simple renderer that shows the problem. (also see attachment) I've also attached the created output file, so you can see, what the problem is.
package de.drehpunkt.rotorsoft.report.launcher.test;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.logging.Level;
import org.eclipse.birt.core.exception.BirtException;
import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.engine.api.EngineConfig;
import org.eclipse.birt.report.engine.api.IRenderOption;
import org.eclipse.birt.report.engine.api.IRenderTask;
import org.eclipse.birt.report.engine.api.IReportDocument;
import org.eclipse.birt.report.engine.api.IReportEngine;
import org.eclipse.birt.report.engine.api.IReportEngineFactory;
import org.eclipse.birt.report.engine.api.IReportRunnable;
import org.eclipse.birt.report.engine.api.IRunTask;
import org.eclipse.birt.report.engine.api.PDFRenderOption;
public class SimpleTestRenderer {
public static void main(final String[] args) throws BirtException, IOException {
IRunTask runTask = null;
try {
// Start birt platform
final EngineConfig engineConfig = new EngineConfig();
engineConfig.setLogConfig("log", Level.ALL);
engineConfig.setLogMaxBackupIndex(50);
Platform.startup(engineConfig);
final IReportEngineFactory factory = (IReportEngineFactory) Platform
.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
final IReportEngine engine = factory.createReportEngine(engineConfig);
// Open design file
final IReportRunnable design = engine.openReportDesign(new FileInputStream("foundation/reports/test/toc_test.rptdesign"));
// Create and run "run task"
final File temporaryBirtDocument = File.createTempFile("birt", "report");
runTask = engine.createRunTask(design);
runTask.run(temporaryBirtDocument.getCanonicalPath());
// Define PDF render options
final IRenderOption renderOptions = new PDFRenderOption();
renderOptions.setOutputFileName("foundation/reports/test/output.pdf");
renderOptions.setOutputFormat(PDFRenderOption.OUTPUT_FORMAT_PDF);
((PDFRenderOption) renderOptions).setEmbededFont(true);
// Start render task
final IReportDocument reportDocument = engine.openReportDocument(temporaryBirtDocument.getCanonicalPath());
final IRenderTask renderTask = engine.createRenderTask(reportDocument);
renderTask.setRenderOption(renderOptions);
renderTask.render();
} finally {
if (runTask != null) {
runTask.close();
}
Platform.shutdown();
}
}
}
I have realy no idea, what the problem is. I hope some of you can help me.
Best regards,
André
|
|
|
Powered by
FUDForum. Page generated in 0.03772 seconds