Discussion:
[iText-questions] Rebuild trailer not found. Original Error: PDF startxref not found
Mauro Pelucchi
2005-12-21 08:24:03 UTC
Permalink
Hi,

in an application that read information from an Oracle database and
create a PDF I get this error:
Rebuild trailer not found. Original Error: PDF startxref not found

Anyone has any idea?

Thanks
--
Mauro Pelucchi <***@gmail.com>
Paulo Soares
2005-12-21 08:29:05 UTC
Permalink
My usual advice: save the pdf directly from the DB to file and see what
you get. Can you open it with Acrobat?
-----Original Message-----
Behalf Of Mauro Pelucchi
Sent: Wednesday, December 21, 2005 10:23 AM
To: itext-questions
Subject: [iText-questions] Rebuild trailer not found.
Original Error: PDF startxref not found
Hi,
in an application that read information from an Oracle database and
Rebuild trailer not found. Original Error: PDF startxref not found
Anyone has any idea?
Thanks
--
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep
through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web.
DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
iText-questions mailing list
https://lists.sourceforge.net/lists/listinfo/itext-questions
Mauro Pelucchi
2005-12-21 08:39:11 UTC
Permalink
The application is in production...
I cannot do this trial...
But the application work fine for 2/3 days and after....CRASH!!!
It is a web application (on WEBSPHERE cluster).
The user insert the order number and my application print the PDF...
...after crash for one user...crash for every user
and I must restart the web application....

Any idea...

Thanks
Post by Paulo Soares
My usual advice: save the pdf directly from the DB to file and see what
you get. Can you open it with Acrobat?
-----Original Message-----
Behalf Of Mauro Pelucchi
Sent: Wednesday, December 21, 2005 10:23 AM
To: itext-questions
Subject: [iText-questions] Rebuild trailer not found.
Original Error: PDF startxref not found
Hi,
in an application that read information from an Oracle database and
Rebuild trailer not found. Original Error: PDF startxref not found
Anyone has any idea?
Thanks
--
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep
through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web.
DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
iText-questions mailing list
https://lists.sourceforge.net/lists/listinfo/itext-questions
--
Mauro Pelucchi <***@gmail.com>
Bruno Lowagie
2005-12-21 08:47:08 UTC
Permalink
Post by Mauro Pelucchi
The application is in production...
I cannot do this trial...
But the application work fine for 2/3 days and after....CRASH!!!
It is a web application (on WEBSPHERE cluster).
The user insert the order number and my application print the PDF...
...after crash for one user...crash for every user
and I must restart the web application....
I'm not clairvoyant, but my first impression is that you
have made a design error and that you have been testing
the application on your own, instead of doing a stress test
with multiple, simultaneous users.
br,
Bruno
Mauro Pelucchi
2005-12-21 09:00:45 UTC
Permalink
Hi,
At the first I think to resolv the problem
by the adding of the System.gc() before call the builder method...
I made 100 test...and all works fine...
but after 2 days....(about 20 file for day...)
crash...
Post by Bruno Lowagie
Post by Mauro Pelucchi
The application is in production...
I cannot do this trial...
But the application work fine for 2/3 days and after....CRASH!!!
It is a web application (on WEBSPHERE cluster).
The user insert the order number and my application print the PDF...
...after crash for one user...crash for every user
and I must restart the web application....
I'm not clairvoyant, but my first impression is that you
have made a design error and that you have been testing
the application on your own, instead of doing a stress test
with multiple, simultaneous users.
br,
Bruno
--
Mauro Pelucchi <***@gmail.com>
Bruno Lowagie
2005-12-21 08:30:11 UTC
Permalink
Post by Mauro Pelucchi
Hi,
in an application that read information from an Oracle database and
Rebuild trailer not found. Original Error: PDF startxref not found
Anyone has any idea?
The PDF is corrupt.
If you read the PDF from Oracle and write the bytes to a file,
Adobe Reader will give you more or less the same error message.
Each PDF document needs 'startxref' somewhere near the end of the file.
br,
Bruno
Mauro Pelucchi
2005-12-21 08:36:11 UTC
Permalink
Ehm...

I read information from Oracle DATABASE and after create the PDF -->
the error come from the PDFBuilder class.
I made the PDF in 3 steps:
--> BUILD the header
--> BUILD the detail (the PDF is a print of a sales order)
--> MERGE the two pdf created...

I can open the PDF generater with ACROBAT but it is blank and in the log
of the web application I read this error...
Rebuild trailer not found. Original Error: PDF startxref not found
Post by Bruno Lowagie
Post by Mauro Pelucchi
Hi,
in an application that read information from an Oracle database and
Rebuild trailer not found. Original Error: PDF startxref not found
Anyone has any idea?
The PDF is corrupt.
If you read the PDF from Oracle and write the bytes to a file,
Adobe Reader will give you more or less the same error message.
Each PDF document needs 'startxref' somewhere near the end of the file.
br,
Bruno
--
Mauro Pelucchi <***@gmail.com>
Bruno Lowagie
2005-12-21 08:44:03 UTC
Permalink
Post by Mauro Pelucchi
Ehm...
I read information from Oracle DATABASE
This information isn't PDF?
Post by Mauro Pelucchi
and 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 Pelucchi
I can open the PDF generater with ACROBAT but it is blank
So in other words: you can't open it.
Post by Mauro Pelucchi
and 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
2005-12-21 08:57:26 UTC
Permalink
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 Lowagie
Post by Mauro Pelucchi
Ehm...
I read information from Oracle DATABASE
This information isn't PDF?
Post by Mauro Pelucchi
and 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 Pelucchi
I can open the PDF generater with ACROBAT but it is blank
So in other words: you can't open it.
Post by Mauro Pelucchi
and 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>
Bruno Lowagie
2005-12-21 10:34:04 UTC
Permalink
Post by Mauro Pelucchi
Ok...
this is my code...
It's somebody else's code...
Post by Mauro Pelucchi
I not write this application....there was already... and I must resolt
this problem....
Reading somebody else's code can be very difficult.
Rewriting the code will probably be easier.
(It's what I would do when given this assignment.)
br,
Bruno
Mauro Pelucchi
2005-12-21 11:05:10 UTC
Permalink
Dear Bruno...
I cannot change the architecture of the application...
and before to write some new code I prefer to find the error....
The application crash in this function...
PdfReader(URL url) --> readPdf() --> readXref()...

Other idea..

Thanks

Mauro
Post by Bruno Lowagie
Post by Mauro Pelucchi
Ok...
this is my code...
It's somebody else's code...
Post by Mauro Pelucchi
I not write this application....there was already... and I must resolt
this problem....
Reading somebody else's code can be very difficult.
Rewriting the code will probably be easier.
(It's what I would do when given this assignment.)
br,
Bruno
--
Mauro Pelucchi <***@gmail.com>
Bruno Lowagie
2005-12-21 11:17:05 UTC
Permalink
Post by Mauro Pelucchi
Dear Bruno...
I cannot change the architecture of the application...
and before to write some new code I prefer to find the error....
The application crash in this function...
PdfReader(URL url) --> readPdf() --> readXref()...
There some kind of timestamp in the name of the PDF file.
Has it ever occurred to you that time flies and that you may
be trying to read a file that isn't there?
It's just an idea,
br,
Bruno

Loading...