Ok...
this is my code...
This method create the final PDF file...
public String createOrder(String orderN,String env){
try{
System.gc();
System.out.println("Sto processando l'ordine : " + orderN) ;
java.util.Date date = new Date();
long time = date.getTime();
to = new TestataOrdine(orderN,env);
pdfD = new PdfBuilderD(this,time); //build the detail
pdfD.buildPdf();
pdfH = new PdfBuilderH(this,time); //build the header
pdfH.buildPdf();
pdfm = new PdfMerger(this,time); //and merge detail +
header
pdfm.buildPdf();
f = new File(pdfm.pdfnameH);
f.delete();
f = new File(pdfm.pdfnameD);
f.delete();
return pdfm.pdfname;
}catch(Exception e){
return e.getMessage();
}
}
This class is the header...
public class PdfBuilderH extends PdfPageEventHelper{
....
/** Creates a new instance of PdfBuilder */
public PdfBuilderH() {
}
public PdfBuilderH(OrdineAcquisto a,long t){
bf = new Font(Font.TIMES_ROMAN, 10, Font.NORMAL);
this.oa = a;
this.ndoc = Integer.parseInt(oa.to.ordineInput);
// recuperare l'ora per rendere univoco il pdf
this.pdfname = oa.to.ut.pdfoutpath + "\\" + oa.to.ordineInput +
"H" + t + ".pdf";
this.pdfnameD = oa.to.ut.pdfoutpath + "\\" + oa.to.ordineInput +
"D" + t +".pdf";
}
public String buildPdf(){
document = new Document(PageSize.A4, 10, 10, 90, 70);
left = document.left();
rigth = document.right();
top = document.top();
bottom = document.bottom();
try{
writer = PdfWriter.getInstance(document, new
FileOutputStream(this.pdfname));
pageEvent = new PdfBuilderH();
writer.setPageEvent(pageEvent);
document.open();
cb = writer.getDirectContent();
this.buildTestata();
// Importo le pagine dei dettagli
PdfReader reader = new PdfReader(pdfnameD);
int length = reader.getNumberOfPages();
for(int i = 0; i < length; i++){
PdfImportedPage page1 = writer.getImportedPage(reader, i
+1);
document.newPage();
cb.addTemplate(page1, 1f, 0, 0, 1f, 0, 0 );
}
document.close();
}catch(Exception e){
System.out.println(e.getMessage());
}
return pdfname;
}
...
}
ant this is the class that merge the two file...
public class PdfMerger extends PdfPageEventHelper{
public OrdineAcquisto oa;
public PdfTemplate tpl;
public BaseFont helv;
public Font bf;
public int currentpage = 0;
public String pdfname = null;
public String pdfnamelink = null;
public String pdfnameH = null;
public String pdfnameD = null;
public Document document = null;
public PdfWriter writer = null;
public PdfPageEvent pageEvent = null;
public PdfContentByte cb = null;
public Paragraph p1 = null;
public Chunk c1 = null;
public float left = 0;
public float rigth = 0;
public float top = 0;
public float bottom = 0;
public int ndoc = 0;
/** Creates a new instance of PdfBuilder */
public PdfMerger() {
}
public PdfMerger(OrdineAcquisto a,long t){
bf = new Font(Font.TIMES_ROMAN, 10, Font.NORMAL);
this.oa = a;
this.ndoc = Integer.parseInt(oa.to.ordineInput);
// recuperare l'ora per rendere univoco il pdf
java.util.Date date = new Date();
long time = date.getTime();
this.pdfnamelink = oa.to.ordineInput + "-" + time + ".pdf";
this.pdfnameH = oa.to.ut.pdfoutpath + "\\" + oa.to.ordineInput +
"H" + t + ".pdf";
this.pdfnameD = oa.to.ut.pdfoutpath + "\\" + oa.to.ordineInput +
"D" + t + ".pdf";
this.pdfname = oa.to.ut.pdfoutpath + "\\" + oa.to.ordineInput +
"-" + time + ".pdf";
}
public String buildPdf(){
document = new Document(PageSize.A4, 10, 10, 70, 70);
left = document.left();
rigth = document.right();
top = document.top();
bottom = document.bottom();
try{
writer = PdfWriter.getInstance(document, new
FileOutputStream(this.pdfname));
document.open();
cb = writer.getDirectContent();
PdfReader reader = new PdfReader(pdfnameH);
int length = reader.getNumberOfPages();
....
I not write this application....there was already... and I must resolt
this problem....
Bye Bye
Post by Bruno LowagiePost by Mauro PelucchiEhm...
I read information from Oracle DATABASE
This information isn't PDF?
Post by Mauro Pelucchiand after create the PDF -->
the error come from the PDFBuilder class.
What is the PDFBuilder class?
Post by Mauro Pelucchi--> BUILD the header
--> BUILD the detail (the PDF is a print of a sales order)
--> MERGE the two pdf created...
Are you sure you are using iText?
And how exactly are you merging the two pdf files?
You aren't just concatenating the two files, are you?
Post by Mauro PelucchiI can open the PDF generater with ACROBAT but it is blank
So in other words: you can't open it.
Post by Mauro Pelucchiand in the log
of the web application I read this error...
Rebuild trailer not found. Original Error: PDF startxref not found
I'm sorry, I don't understand what you are doing and
nothing in your description makes me believe you are
using iText, so I can't help you.
br,
Bruno
--
Mauro Pelucchi <***@gmail.com>