0
這裏是我的代碼snippet-錯誤在PDF導出
getResponse().setContentType(NAPSConstants.PDF_CONTENT_TYPE);
getResponse().setHeader(NAPSConstants.PDF_CONTENT_DISP, NAPSConstants.PDF_ATTACHMENT_FILE+getText("rcmid.details")+NAPSConstants.PDF_EXTN);
//Set the Page Size
Document document = new Document(PageSize.A3, 40, 40, 40, 40);
PdfPTable table = new PdfPTable(rcmDetailsCols.length);
for(RCMIDPartsDetailsDTO part : rcmidDTO.getPartsDetailsDTO()){
table.addCell(part.getPartStatus().equals(NAPSConstants.Active) ?
PDFHelper.dataCell(part.getPlantName(), PDFHelper.FONT_DATA) :
PDFHelper.coloredDataCell(part.getPlantName(), PDFHelper.FONT_DATA));
table.addCell(part.getPartStatus().equals(NAPSConstants.Active) ?
PDFHelper.dataCell(part.getOemSupplierId(), PDFHelper.FONT_DATA):PDFHelper.coloredDataCell(part.getOemSupplierId(), PDFHelper.FONT_DATA));
table.addCell(PDFHelper.dataCellWithRowSpan(rcmidDTO.getPackSupplierId(), PDFHelper.FONT_DATA, rcmidDTO.getActiveRowSpan()+rcmidDTO.getPartsList.size()));
}
document.add(table);
document.close();
//輔助方法,
public static PdfPCell dataCell(String cellText, Integer fontSize)
{
PdfPCell cell = new PdfPCell();
if(cellText==null || cellText.compareTo("null")==0 || NAPSConstants.EMPTY_STRING.equals(cellText) ||
cellText.equals(NAPSConstants.MINUS_ONE)){
//cellText = NAPSConstants.TEXT_NA;
cellText = NAPSConstants.EMPTY_STRING;
}
cell.setPhrase(new Phrase(cellText, new Font(Font.NORMAL, fontSize)));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
return cell;
}
public static PdfPCell coloredDataCell(String cellText, Integer fontSize)
{
PdfPCell cell = new PdfPCell();
if(cellText==null || cellText.compareTo("null")==0 || NAPSConstants.EMPTY_STRING.equals(cellText) ||
cellText.equals(NAPSConstants.MINUS_ONE)){
//cellText = NAPSConstants.TEXT_NA;
cellText = NAPSConstants.EMPTY_STRING;
}
cell.setPhrase(new Phrase(cellText, new Font(Font.NORMAL, fontSize,0, new Color(255,0,0))));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setBackgroundColor(new Color(200, 200, 200));
return cell;
}
public static PdfPCell dataCellWithRowSpan(String cellText, Integer fontSize, int rowspan)
{
PdfPCell cell = new PdfPCell();
cell.setRowspan(rowspan);
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
if(cellText==null || cellText.compareTo("null")==0){
//cellText = NAPSConstants.TEXT_NA;
cellText = NAPSConstants.EMPTY_STRING;
}
cell.setPhrase(new Phrase(cellText, new Font(Font.NORMAL, fontSize)));
return cell;
}
我無法瞭解實際的問題是什麼。 我有兩種數據'有效'/'無效',因此我添加了三元運算符來更改非活動數據的背景顏色。 PDF導出對於活動數據非常適用。但對於非活動數據,以下情況是例外。
ThreadMonitor W WSVR0605W: Thread "WebContainer : 3" (0000001c) has been active for 754832 milliseconds and may be hung. There is/are 1 thread(s) in total in the server that may be hung.
at com.lowagie.text.pdf.BidiLine.createArrayOfPdfChunks(Unknown Source)
at com.lowagie.text.pdf.BidiLine.createArrayOfPdfChunks(Unknown Source)
at com.lowagie.text.pdf.BidiLine.processLine(Unknown Source)
at com.lowagie.text.pdf.ColumnText.go(Unknown Source)
at com.lowagie.text.pdf.PdfPCell.getMaxHeight(Unknown Source)
at com.lowagie.text.pdf.PdfPTable.getRowHeight(Unknown Source)
at com.lowagie.text.pdf.PdfPTable.getRowHeight(Unknown Source)
at com.lowagie.text.pdf.PdfPTable.getRowHeight(Unknown Source)
at com.lowagie.text.pdf.PdfPTable.getRowHeight(Unknown Source)
at com.lowagie.text.pdf.PdfPTable.getRowHeight(Unknown Source)
at com.lowagie.text.pdf.PdfPTable.getRowHeight(Unknown Source)
at com.lowagie.text.pdf.PdfPTable.getRowHeight(Unknown Source)
at com.lowagie.text.pdf.PdfPTable.getRowHeight(Unknown Source)
at com.lowagie.text.pdf.PdfPTable.getRowHeight(Unknown Source)
at com.lowagie.text.pdf.PdfPTable.getRowHeight(Unknown Source)
at com.lowagie.text.pdf.PdfPTable.getRowHeight(Unknown Source)
at com.lowagie.text.pdf.PdfPTable.getRowHeight(Unknown Source)
at com.lowagie.text.pdf.PdfPTable.getRowHeight(Unknown Source)
at com.lowagie.text.pdf.PdfPTable.getRowHeight(Unknown Source)
at com.lowagie.text.pdf.PdfPTable.getRowHeight(Unknown Source)
at com.lowagie.text.pdf.PdfPTable.getRowHeight(Unknown Source)
at com.lowagie.text.pdf.PdfPTable.getRowHeight(Unknown Source)
at com.lowagie.text.pdf.PdfPTable.getRowHeight(Unknown Source)
at com.lowagie.text.pdf.PdfPTable.getRowHeight(Unknown Source)
at com.lowagie.text.pdf.PdfPTable.getRowHeight(Unknown Source)
at com.lowagie.text.pdf.PdfPTable.getRowHeight(Unknown Source)
at com.lowagie.text.pdf.PdfPTable.calculateHeights(Unknown Source)
at com.lowagie.text.pdf.PdfPTable.setTotalWidth(Unknown Source)
at com.lowagie.text.pdf.ColumnText.goComposite(Unknown Source)
at com.lowagie.text.pdf.ColumnText.go(Unknown Source)
at com.lowagie.text.pdf.ColumnText.go(Unknown Source)
at com.lowagie.text.pdf.PdfDocument.addPTable(Unknown Source)
at com.lowagie.text.pdf.PdfDocument.add(Unknown Source)
at com.lowagie.text.Document.add(Unknown Source)
at com.honda.naps.action.rcmid.RCMIDDetailsAction.rcmDetailsExportTOPDF(RCMIDDetailsAction.java:490)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:600)
此外,java進程佔用CPU使用率高達95%。服務器變得非常慢。我必須手動停止java進程並重新啓動服務器。
我在你的錯誤信息中看到我的名字。這意味着您使用的是6年前的iText版本。該版本不再受支持。當前版本是5.5.6。請升級。 –
是的應用程序已超過6年。通過更新到最新版本將解決這個問題? – Waqar
你是說你有一個6年的應用程序,並且你一直在等待報告問題?表功能已被完全重寫,所以問題很可能會消失。 –