Carbon Copy birt with Frameset Report with Carbon copy
#1
Posted 31 January 2013 - 01:36 AM
I have a certain report (INVOICING) and I get this int var value the number of copies that i'm suppose to do in one print at the time.
I would like to do carbon copies in just ONE print labeling them as "Original" , "Fist copy", and so on. the Original might get more that one page off course !!
Can any of you give me any sort on inspiration to do the job...please.
I would like to avoid java approach, instead java script on the report itself, because all i'm using is the frameset servlet all the time.
Thanks ins advence
#2
Posted 31 January 2013 - 01:37 PM
What I'm doing is using parameters to store which copy it is, change the "Copy n of m" label to match, generate the PDF with some JS in a temp location and then redirect the report back to itself to create the next n of m until the parameter equals the number of copies that has been provided in an HTML form.
#3
Posted 01 February 2013 - 06:04 AM
kclark, on 31 January 2013 - 01:37 PM, said:
What I'm doing is using parameters to store which copy it is, change the "Copy n of m" label to match, generate the PDF with some JS in a temp location and then redirect the report back to itself to create the next n of m until the parameter equals the number of copies that has been provided in an HTML form.
Thanks a lot i will wait
Paulo
#4
Posted 04 February 2013 - 10:10 AM
Here's the script I wrote to generate the copies
importPackage(Packages.com.itextpdf.awt);
importPackage(Packages.com.itextpdf.text.pdf);
importPackage(Packages.com.itextpdf.text);
importPackage(Packages.com.itextpdf.text.pdf.ocg);
importPackage(Packages.java.io);
if(params["dropForm"].value > 0) {
importPackage(Packages.org.eclipse.birt.report.engine.api);
var re = reportContext.getReportRunnable().getReportEngine();
var mydoc = reportContext.getHttpServletRequest().getAttribute("attributeBean").getReportDocumentName();
var mydocument = re.openReportDocument(mydoc);
var options = new PDFRenderOption();
var outputfile = "c:/test/original.pdf";
options.setOutputFileName(outputfile);
options.setOutputFormat("pdf");
ntask = re.createRenderTask(mydocument);
ntask.setRenderOption(options);
ntask.render();
mydocument.close();
ntask.close();
for(i=0;i<=params["carbonNum"].value;i++) {
if(i!=0) {
var result = "c:\\test\\appended.pdf";
reader = new PdfReader("c:\\test\\original.pdf");
stamper = new PdfStamper(reader, new FileOutputStream("c:\\test\\carboncopy" + i + ".pdf"), '\0', true);
cb = stamper.getUnderContent(1);
cb.beginText();
cb.setFontAndSize(BaseFont.createFont(), 12);
cb.showTextAligned(Element.ALIGN_LEFT, "***CARBON COPY #" + i + "***", 36, 770, 0);
cb.endText();
stamper.close();
reader.close();
}
}
}
Let me know if the works for you
Attached File(s)
-
carboncopy.rptdesign (35.56K)
Number of downloads: 5
#5
Posted 05 February 2013 - 07:21 AM
kclark, on 04 February 2013 - 10:10 AM, said:
Here's the script I wrote to generate the copies
importPackage(Packages.com.itextpdf.awt);
importPackage(Packages.com.itextpdf.text.pdf);
importPackage(Packages.com.itextpdf.text);
importPackage(Packages.com.itextpdf.text.pdf.ocg);
importPackage(Packages.java.io);
if(params["dropForm"].value > 0) {
importPackage(Packages.org.eclipse.birt.report.engine.api);
var re = reportContext.getReportRunnable().getReportEngine();
var mydoc = reportContext.getHttpServletRequest().getAttribute("attributeBean").getReportDocumentName();
var mydocument = re.openReportDocument(mydoc);
var options = new PDFRenderOption();
var outputfile = "c:/test/original.pdf";
options.setOutputFileName(outputfile);
options.setOutputFormat("pdf");
ntask = re.createRenderTask(mydocument);
ntask.setRenderOption(options);
ntask.render();
mydocument.close();
ntask.close();
for(i=0;i<=params["carbonNum"].value;i++) {
if(i!=0) {
var result = "c:\\test\\appended.pdf";
reader = new PdfReader("c:\\test\\original.pdf");
stamper = new PdfStamper(reader, new FileOutputStream("c:\\test\\carboncopy" + i + ".pdf"), '\0', true);
cb = stamper.getUnderContent(1);
cb.beginText();
cb.setFontAndSize(BaseFont.createFont(), 12);
cb.showTextAligned(Element.ALIGN_LEFT, "***CARBON COPY #" + i + "***", 36, 770, 0);
cb.endText();
stamper.close();
reader.close();
}
}
}
Let me know if the works for you
Hello kclark, I'km goin to test it.
Thank you very much





MultiQuote




