这是我的代码片段-
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进程并重新启动服务器。
发布于 2015-06-11 10:22:13
问题解决了-
由于现有体系结构的依赖关系,我无法更新jar。
但真正的问题是跨行。活动/非活动部件的行距不同。在改变了这种逻辑之后,问题得到了解决。
https://stackoverflow.com/questions/30753416
复制相似问题