Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
extra spaces in the bottom of the pdf generated through birt
birt scree
Find more posts tagged with
Comments
JasonW
Anand
Are you running it with a runandrender task or a run task followed by a render task?
You may want to first use a run task and create a rptdocument and then a render task. Also try adding the following render option:
PDFRenderOption options = new PDFRenderOption();
options.setOption(IRenderOption.HTML_PAGINATION, Boolean.TRUE );
Jason
birt scree
Hi Jason,
Thanks for your comment.
I am running it with runandrender task.
As you said an alternative way,I have tried that way.I commented the runandrender task and wrote code as you said
1.Create run task
2.Create RPTDocument
3.Render task
But still more extra spaces are present in the bottom of the PDF.
I managed to place the "thin-sea blue" image in the bottom of the PDF by increasing
the grid row to 170(from 25).i.e now the grid will have 170 rows. and placed the line image
in 168 th row and another image in 169 th row.
Please see the below code and please let me know anything can be done to put line in the bottom of the pdf
(commented the runandrender task and wrote code as you said)
import java.util.HashMap;
import org.eclipse.birt.report.engine.api.EngineConfig;
import org.eclipse.birt.report.engine.api.EngineConstants;
import org.eclipse.birt.report.engine.api.EngineException;
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.IReportRunnable;
import org.eclipse.birt.report.engine.api.IRunAndRenderTask;
import org.eclipse.birt.report.engine.api.IRunTask;
import org.eclipse.birt.report.engine.api.PDFRenderContext;
import org.eclipse.birt.report.engine.api.PDFRenderOption;
import org.eclipse.birt.report.engine.api.ReportEngine;
import org.eclipse.birt.report.model.api.DesignEngine;
import org.eclipse.birt.report.model.api.ElementFactory;
import org.eclipse.birt.report.model.api.ReportDesignHandle;
import org.eclipse.birt.report.model.api.SessionHandle;
public class PDFReport1 {
/** *
@param
args */
public static void main(String[] args)
{
String designFileName;
String outputFileName;
// To generate the Player Report
designFileName = "D:\\workspace2\\WPBirt\\Chart Types\\Output\\TableOfContents.rptdesign";
outputFileName = "D:\\workspace2\\WPBirt\\Chart Types\\Output\\TableOfContentsPDF.pdf";
renderReport(designFileName, outputFileName);
}
private static void renderReport(String designFileName,String outputFileName)
{
EngineConfig conf = null;
ReportEngine eng = null;
IReportRunnable design = null;
//IRunAndRenderTask task = null;
IRunTask task = null;
PDFRenderContext renderContext = null;
HashMap contextMap = null;
PDFRenderOption options = null;
conf = new EngineConfig();
conf.setEngineHome("C:/Users/css88608/Downloads/birt-runtime-3_7_2/birt-runtime-3_7_2/ReportEngine");
eng = new ReportEngine(conf);
try
{
design = eng.openReportDesign(designFileName);
ReportDesignHandle designHandle = null;
ElementFactory designFactory = null;
SessionHandle sessionHandle = DesignEngine.newSession(null);
}
catch (Exception e)
{
System.err
.println("An error occured during the opening of the report file!");
e.printStackTrace();
System.exit(-1);
}
//task = eng.createRunAndRenderTask(design);
//Create task to run the report - use the task to execute and run the report,
task = eng.createRunTask(design);
//Create rptdocument
try
{
task.run("D:\\workspace2\\WPBirt\\Chart Types\\Output\\TableOfContents.rptdocument");
}
catch (EngineException e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
IReportDocument rptdoc = null;
//Open rptdocument
try
{
rptdoc = eng.openReportDocument("D:\\workspace2\\WPBirt\\Chart Types\\Output\\TableOfContents.rptdocument");
}
catch (EngineException e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
//Create Render Task
IRenderTask rtask = eng.createRenderTask(rptdoc);
renderContext = new PDFRenderContext();
contextMap = new HashMap();
contextMap.put(EngineConstants.APPCONTEXT_PDF_RENDER_CONTEXT,renderContext);
//task.setAppContext(contextMap);
rtask.setAppContext(contextMap);
options = new PDFRenderOption();
options.setOutputFileName(outputFileName);
options.setOutputFormat("pdf");
options.setOption(IRenderOption.HTML_PAGINATION, Boolean.TRUE );
//task.setRenderOption(options);
rtask.setRenderOption(options);
try
{
//task.run();
rtask.render();
}
catch (Exception e)
{
System.err.println("An error occured while running the report!");
e.printStackTrace();
System.exit(-1);
}
System.out.println("All went well. Closing program!");
eng.destroy();
}
}
Please see the attached PDF for your reference.
Regards,
Anand
JasonW
Anand,
I do not see the attachment. On a side note? Are you using the osgi runtime or the pojo runtime?
I noticed you are setting an engine home:
conf.setEngineHome("C:/Users/css88608/Downloads/birt-runtime-3_7_2/birt-runtime-3_7_2/ReportEngine");
This should only be done if you are using the osgi runtime.
Also in the page break properties for any table you have in the report, set the page break interval to 0.
Jason
birt scree
<blockquote class='ipsBlockquote' data-author="'birt scree'" data-cid="108604" data-time="1345196207" data-date="17 August 2012 - 02:36 AM"><p>
Hi Jason,<br />
<br />
Thanks for your comment.<br />
<br />
I am running it with runandrender task.<br />
<br />
As you said an alternative way,I have tried that way.I commented the runandrender task and wrote code as you said<br />
1.Create run task<br />
2.Create RPTDocument<br />
3.Render task<br />
<br />
But still more extra spaces are present in the bottom of the PDF.<br />
<br />
I managed to place the "thin-sea blue" image in the bottom of the PDF by increasing<br />
the grid row to 170(from 25).i.e now the grid will have 170 rows. and placed the line image<br />
in 168 th row and another image in 169 th row.<br />
<br />
Please see the below code and please let me know anything can be done to put line in the bottom of the pdf<br />
(commented the runandrender task and wrote code as you said)<br />
<br />
import java.util.HashMap;<br />
<br />
import org.eclipse.birt.report.engine.api.EngineConfig;<br />
import org.eclipse.birt.report.engine.api.EngineConstants;<br />
import org.eclipse.birt.report.engine.api.EngineException;<br />
import org.eclipse.birt.report.engine.api.IRenderOption;<br />
import org.eclipse.birt.report.engine.api.IRenderTask;<br />
import org.eclipse.birt.report.engine.api.IReportDocument;<br />
import org.eclipse.birt.report.engine.api.IReportRunnable;<br />
import org.eclipse.birt.report.engine.api.IRunAndRenderTask;<br />
import org.eclipse.birt.report.engine.api.IRunTask;<br />
import org.eclipse.birt.report.engine.api.PDFRenderContext;<br />
import org.eclipse.birt.report.engine.api.PDFRenderOption;<br />
import org.eclipse.birt.report.engine.api.ReportEngine;<br />
import org.eclipse.birt.report.model.api.DesignEngine;<br />
import org.eclipse.birt.report.model.api.ElementFactory;<br />
import org.eclipse.birt.report.model.api.ReportDesignHandle;<br />
import org.eclipse.birt.report.model.api.SessionHandle;<br />
<br />
public class PDFReport1 {<br />
<br />
/** *
@param
args */<br />
public static void main(String[] args) <br />
{<br />
String designFileName;<br />
String outputFileName;<br />
<br />
// To generate the Player Report<br />
designFileName = "D:\\workspace2\\WPBirt\\Chart Types\\Output\\TableOfContents.rptdesign";<br />
outputFileName = "D:\\workspace2\\WPBirt\\Chart Types\\Output\\TableOfContentsPDF.pdf";<br />
renderReport(designFileName, outputFileName);<br />
}<br />
<br />
private static void renderReport(String designFileName,String outputFileName) <br />
{<br />
EngineConfig conf = null;<br />
ReportEngine eng = null;<br />
IReportRunnable design = null;<br />
//IRunAndRenderTask task = null;<br />
IRunTask task = null;<br />
PDFRenderContext renderContext = null;<br />
HashMap contextMap = null;<br />
PDFRenderOption options = null;<br />
<br />
conf = new EngineConfig();<br />
conf.setEngineHome("C:/Users/css88608/Downloads/birt-runtime-3_7_2/birt-runtime-3_7_2/ReportEngine");<br />
<br />
eng = new ReportEngine(conf);<br />
<br />
try <br />
{<br />
design = eng.openReportDesign(designFileName);<br />
ReportDesignHandle designHandle = null;<br />
ElementFactory designFactory = null;<br />
SessionHandle sessionHandle = DesignEngine.newSession(null);<br />
} <br />
catch (Exception e) <br />
{<br />
System.err<br />
.println("An error occured during the opening of the report file!");<br />
e.printStackTrace();<br />
System.exit(-1);<br />
}<br />
<br />
//task = eng.createRunAndRenderTask(design);<br />
<br />
//Create task to run the report - use the task to execute and run the report,<br />
task = eng.createRunTask(design); <br />
<br />
//Create rptdocument<br />
try <br />
{<br />
task.run("D:\\workspace2\\WPBirt\\Chart Types\\Output\\TableOfContents.rptdocument");<br />
} <br />
catch (EngineException e1) <br />
{<br />
// TODO Auto-generated catch block<br />
e1.printStackTrace();<br />
}<br />
<br />
IReportDocument rptdoc = null;<br />
//Open rptdocument<br />
try <br />
{<br />
rptdoc = eng.openReportDocument("D:\\workspace2\\WPBirt\\Chart Types\\Output\\TableOfContents.rptdocument");<br />
} <br />
catch (EngineException e1) <br />
{<br />
// TODO Auto-generated catch block<br />
e1.printStackTrace();<br />
} <br />
<br />
//Create Render Task<br />
IRenderTask rtask = eng.createRenderTask(rptdoc);<br />
<br />
renderContext = new PDFRenderContext();<br />
contextMap = new HashMap();<br />
contextMap.put(EngineConstants.APPCONTEXT_PDF_RENDER_CONTEXT,renderContext);<br />
//task.setAppContext(contextMap);<br />
rtask.setAppContext(contextMap);<br />
<br />
options = new PDFRenderOption();<br />
options.setOutputFileName(outputFileName);<br />
options.setOutputFormat("pdf");<br />
options.setOption(IRenderOption.HTML_PAGINATION, Boolean.TRUE );<br />
//task.setRenderOption(options);<br />
rtask.setRenderOption(options);<br />
<br />
try <br />
{<br />
//task.run();<br />
rtask.render();<br />
} <br />
catch (Exception e) <br />
{<br />
System.err.println("An error occured while running the report!");<br />
e.printStackTrace();<br />
System.exit(-1);<br />
}<br />
<br />
System.out.println("All went well. Closing program!");<br />
eng.destroy();<br />
}<br />
<br />
}<br />
<br />
Please see the attached PDF for your reference.<br />
<br />
Regards,<br />
Anand<br /></p></blockquote>
birt scree
Jason,
Thanks for your comment.Issued got fixed by placing the image on the pager footer(Footer Grid)
Anand