Hi,
I have problem generating the PDF report with large record set.
the code works when the recordset is relatively small. but when I try to pull all of
the data from the database (over 3000record), then I get Error 404--Not Found on the
browser.
the connection is not a problem. sql is not problem. following is the code for pdf
part. can somebody give me a hint?
thanks
alex
// step 1: creation of a document-object
Document document = new Document(PageSize.A4.rotate(), 15, 15, 30, 30);
// step 2:
// we create a writer that listens to the document
// and directs a PDF-stream to a temporary buffer
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
try{
// creation of the different writers
PdfWriter.getInstance( document, buffer );
HeaderFooter footer = new HeaderFooter(new Phrase("page: "), true);
footer.setBorder(Rectangle.NO_BORDER);
document.setFooter(footer);
document.open();
Table datatable = new Table(18);
datatable.setPadding(2);
datatable.setSpacing(0);
//datatable.setBorder(Rectangle.NO_BORDER);
int headerwidths[] = {5, 5, 7, 6, 7, 6, 7, 5, 5, 5, 5, 5, 5, 7, 5, 5, 5,
5};
datatable.setWidths(headerwidths);
datatable.setWidth(100);
Cell cell2 = new Cell(new Phrase("Printed: " + currentDate("EEEEEEEEE,
MMMMMMMMMMMM dd, yyyy hh:mm aaa"), FontFactory.getFont(FontFactory.HELVETICA, 8,
Font.BOLD)));
cell2.setHorizontalAlignment(Element.ALIGN_LEFT);
cell2.setColspan(18);
cell2.setBorder(Rectangle.NO_BORDER);
cell2.setBorderWidth(0);
datatable.addCell(cell2);
// the first cell spans 18 columns
Cell cell = new Cell(new Phrase("Department of Human Resources\nEDP
Tracking Report\n"+ vThru , FontFactory.getFont(FontFactory.HELVETICA, 16,
Font.BOLD)));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setLeading(30);
cell.setColspan(18);
cell.setBorder(Rectangle.NO_BORDER);
cell.setBackgroundColor(new Color(0xC0, 0xC0, 0xC0));
datatable.addCell(cell);
// These cells span 2 rows
datatable.setDefaultCellBorderWidth(2);
datatable.setDefaultHorizontalAlignment(1);
datatable.setDefaultRowspan(1);
cell = new Cell(new Phrase("EDP #",
FontFactory.getFont(FontFactory.HELVETICA, 8, Font.BOLD)));
cell.setBorderWidth(1);
cell.setColspan(1);
datatable.addCell(cell);
cell = new Cell(new Phrase("Request Received",
FontFactory.getFont(FontFactory.HELVETICA, 8, Font.BOLD)));
cell.setBorderWidth(1);
cell.setColspan(1);
datatable.addCell(cell);
cell = new Cell(new Phrase("Division/ Office",
FontFactory.getFont(FontFactory.HELVETICA, 8, Font.BOLD)));
cell.setBorderWidth(1);
cell.setColspan(1);
datatable.addCell(cell);
cell = new Cell(new Phrase("Section",
FontFactory.getFont(FontFactory.HELVETICA, 8, Font.BOLD)));
cell.setBorderWidth(1);
cell.setColspan(1);
datatable.addCell(cell);
cell = new Cell(new Phrase("Tech EDP Assigned to",
FontFactory.getFont(FontFactory.HELVETICA, 8, Font.BOLD)));
cell.setBorderWidth(1);
cell.setColspan(1);
datatable.addCell(cell);
cell = new Cell(new Phrase("Ship to Address",
FontFactory.getFont(FontFactory.HELVETICA, 8, Font.BOLD)));
cell.setBorderWidth(1);
cell.setColspan(1);
datatable.addCell(cell);
cell = new Cell(new Phrase("Org #",
FontFactory.getFont(FontFactory.HELVETICA, 8, Font.BOLD)));
cell.setBorderWidth(1);
cell.setColspan(1);
datatable.addCell(cell);
cell = new Cell(new Phrase("To Tech",
FontFactory.getFont(FontFactory.HELVETICA, 8, Font.BOLD)));
cell.setBorderWidth(1);
cell.setColspan(1);
datatable.addCell(cell);
cell = new Cell(new Phrase("To Project Tacking",
FontFactory.getFont(FontFactory.HELVETICA, 8, Font.BOLD)));
cell.setBorderWidth(1);
cell.setColspan(1);
datatable.addCell(cell);
cell = new Cell(new Phrase("From Project Tracking",
FontFactory.getFont(FontFactory.HELVETICA, 8, Font.BOLD)));
cell.setBorderWidth(1);
cell.setColspan(1);
datatable.addCell(cell);
cell = new Cell(new Phrase("Approved by Project Tracking",
FontFactory.getFont(FontFactory.HELVETICA, 8, Font.BOLD)));
cell.setBorderWidth(1);
cell.setColspan(1);
datatable.addCell(cell);
cell = new Cell(new Phrase("Entered into People Soft",
FontFactory.getFont(FontFactory.HELVETICA, 8, Font.BOLD)));
cell.setBorderWidth(1);
cell.setColspan(1);
datatable.addCell(cell);
cell = new Cell(new Phrase("Cleared People Soft",
FontFactory.getFont(FontFactory.HELVETICA, 8, Font.BOLD)));
cell.setBorderWidth(1);
cell.setColspan(1);
datatable.addCell(cell);
cell = new Cell(new Phrase("To Procurement",
FontFactory.getFont(FontFactory.HELVETICA, 8, Font.BOLD)));
cell.setBorderWidth(1);
cell.setColspan(1);
datatable.addCell(cell);
cell = new Cell(new Phrase("To Vendor",
FontFactory.getFont(FontFactory.HELVETICA, 8, Font.BOLD)));
cell.setBorderWidth(1);
cell.setColspan(1);
datatable.addCell(cell);
cell = new Cell(new Phrase("Actual Delivery",
FontFactory.getFont(FontFactory.HELVETICA, 8, Font.BOLD)));
cell.setBorderWidth(1);
cell.setColspan(1);
datatable.addCell(cell);
cell = new Cell(new Phrase("Closed by OIT",
FontFactory.getFont(FontFactory.HELVETICA, 8, Font.BOLD)));
cell.setBorderWidth(1);
cell.setColspan(1);
datatable.addCell(cell);
cell = new Cell(new Phrase("Customer Receives Order",
FontFactory.getFont(FontFactory.HELVETICA, 8, Font.BOLD)));
cell.setBorderWidth(1);
cell.setColspan(1);
datatable.addCell(cell);
// this is the end of the table header
datatable.endHeaders();
datatable.setDefaultCellBorderWidth(0);
tory.HELVETICA, 8, Font.BOLD))); datatable.setDefaultRowspan(1);
datatable.setDefaultHorizontalAlignment(Element.ALIGN_CENTER);
TrackingRecordset = StatementTrackingRecordset.executeQuery();
// rs_aContractRpt = Statementrs_aContractRpt.executeQuery();
while (TrackingRecordset.next()){
String EDPNum = TrackingRecordset.getString("TICKET_NO");
if(EDPNum ==null){
EDPNum ="";
}
String reqReceived =
convertForDisplay(TrackingRecordset.getString("RECD_GW"));
if (reqReceived==null) {
reqReceived="";
}
String division = TrackingRecordset.getString("DIVISION");
if (division==null) {
division="";
}
String section = TrackingRecordset.getString("SECTION");
if (section==null) {
section="";
}
String techAssigned = TrackingRecordset.getString("TECH_ASSIGNED");
if (techAssigned==null) {
techAssigned="";
}
String shipAddress= TrackingRecordset.getString("LOCATION");
if (shipAddress==null) {
shipAddress="";
}
String orgNum= TrackingRecordset.getString("ORG_CODE");
if (orgNum==null) {
orgNum="";
}
String toTech = convertForDisplay(TrackingRecordset.getString("TO_TECHN"));
if (toTech==null) {
toTech="";
}
String toProTracking =
convertForDisplay(TrackingRecordset.getString("TOTRACKING"));
if (toProTracking==null) {
toProTracking="";
}
String fromProTracking =
convertForDisplay(TrackingRecordset.getString("FROMTRACKING"));
if (fromProTracking==null) {
fromProTracking="";
}
String appProTracking =
convertForDisplay(TrackingRecordset.getString("APPROVED"));
if (appProTracking==null) {
appProTracking="";
}
String enterPeopleSoft =
convertForDisplay(TrackingRecordset.getString("ENTERED_GIFS"));
if (enterPeopleSoft==null) {
enterPeopleSoft="";
}
String clearPeopleSoft=
convertForDisplay(TrackingRecordset.getString("CLEARED_GIFS"));
if (clearPeopleSoft==null) {
clearPeopleSoft="";
}
String toProcure=
convertForDisplay(TrackingRecordset.getString("TO_PROCUREMENT"));
if (toProcure==null) {
toProcure="";
}
String toVendor =
convertForDisplay(TrackingRecordset.getString("TO_VENDOR"));
if (toVendor==null) {
toVendor="";
}
String actualDeli =
convertForDisplay(TrackingRecordset.getString("ACT_DELIV_DATE"));
if (actualDeli==null) {
actualDeli="";
}
String closedOIT = convertForDisplay(Tracki tory.HELVETICA, 8,
Font.BOLD)));ngRecordset.getString("CLOSED"));
if (closedOIT==null) {
closedOIT="";
}
String cusomerReceive =
convertForDisplay(TrackingRecordset.getString("CLOSED_BY_CUSTOMER"));
if (cusomerReceive==null) {
cusomerReceive="";
}
cell = new Cell(new Phrase(EDPNum,
FontFactory.getFont(FontFactory.HELVETICA, 7, Font.BOLD)));
cell.setBorderWidth(0);
cell.setColspan(1);
datatable.addCell(cell);
datatable.setDefaultHorizontalAlignment(Element.ALIGN_CENTER);
cell = new Cell(new Phrase(reqReceived,
FontFactory.getFont(FontFactory.HELVETICA, 7, Font.BOLD)));
cell.setBorderWidth(0);
cell.setColspan(1);
datatable.addCell(cell);
cell = new Cell(new Phrase(division,
FontFactory.getFont(FontFactory.HELVETICA, 7, Font.BOLD)));
cell.setBorderWidth(0);
cell.setColspan(1);
datatable.addCell(cell);
cell = new Cell(new Phrase(section,
FontFactory.getFont(FontFactory.HELVETICA, 7, Font.BOLD)));
cell.setBorderWidth(0);
cell.setColspan(1);
datatable.addCell(cell);
cell = new Cell(new Phrase(techAssigned,
FontFactory.getFont(FontFactory.HELVETICA, 7, Font.BOLD)));
cell.setBorderWidth(0);
cell.setColspan(1);
datatable.addCell(cell);
cell = new Cell(new Phrase(shipAddress,
FontFactory.getFont(FontFactory.HELVETICA, 7, Font.BOLD)));
cell.setBorderWidth(0);
cell.setColspan(1);
datatable.addCell(cell);
cell = new Cell(new Phrase(orgNum,
FontFactory.getFont(FontFactory.HELVETICA, 7, Font.BOLD)));
cell.setBorderWidth(0);
cell.setColspan(1);
datatable.addCell(cell);
cell = new Cell(new Phrase(toTech,
FontFactory.getFont(FontFactory.HELVETICA, 7, Font.BOLD)));
cell.setBorderWidth(0);
cell.setColspan(1);
datatable.addCell(cell);
cell = new Cell(new Phrase(toProTracking,
FontFactory.getFont(FontFactory.HELVETICA, 7, Font.BOLD)));
cell.setBorderWidth(0);
cell.setColspan(1);
datatable.addCell(cell);
cell = new Cell(new Phrase(fromProTracking,
FontFactory.getFont(FontFactory.HELVETICA, 7, Font.BOLD)));
cell.setBorderWidth(0);
cell.setColspan(1);
datatable.addCell(cell);
cell = new Cell(new Phrase(appProTracking,
FontFactory.getFont(FontFactory.HELVETICA, 7, Font.BOLD)));
cell.setBorderWidth(0);
cell.setColspan(1);
datatable.addCell(cell);
cell = new Cell(new Phrase(enterPeopleSoft,
FontFactory.getFont(FontFactory.HELVETICA, 7, Font.BOLD)));
cell.setBorderWidth(0);
cell.setColspan(1);
datatable.addCell(cell);
cell = new Cell(new Phrase(clearPeopleSoft,
FontFactory.getFont(FontFactory.HELVETICA, 7, Font.BOLD)));
cell.setBorderWidth(0);
cell.setColspan(1);
datatable.addCell(cell);
cell = new Cell(new Phrase(toProcure,
FontFactory.getFont(FontFactory.HELVETICA, 7, Font.BOLD)));
cell.setBorderWidth(0);
cell.setColspan(1);
datatable tory.HELVETICA, 8, Font.BOLD)));.addCell(cell);
cell = new Cell(new Phrase(toVendor,
FontFactory.getFont(FontFactory.HELVETICA, 7, Font.BOLD)));
cell.setBorderWidth(0);
cell.setColspan(1);
datatable.addCell(cell);
cell = new Cell(new Phrase(actualDeli,
FontFactory.getFont(FontFactory.HELVETICA, 7, Font.BOLD)));
cell.setBorderWidth(0);
cell.setColspan(1);
datatable.addCell(cell);
cell = new Cell(new Phrase(closedOIT,
FontFactory.getFont(FontFactory.HELVETICA, 7, Font.BOLD)));
cell.setBorderWidth(0);
cell.setColspan(1);
datatable.addCell(cell);
cell = new Cell(new Phrase(cusomerReceive,
FontFactory.getFont(FontFactory.HELVETICA, 7, Font.BOLD)));
cell.setBorderWidth(0);
cell.setColspan(1);
datatable.addCell(cell);
// TrackingRecordset.next();
}
document.add(datatable);
document.close();
response.reset();
response.setContentType( "application/pdf" );
response.setContentLength(buffer.size());
ServletOutputStream out1 = response.getOutputStream();
buffer.writeTo(out1);
out1.flush();
}
catch(DocumentException de) {
de.printStackTrace();
}
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions