Java tutorial
/* * Copyright (C) 2010-2012 <349446658@qq.com> * * This file is part of Wabacus * * Wabacus is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.wabacusdemo; import com.itextpdf.text.Image; import com.itextpdf.text.pdf.PdfPCell; import com.wabacus.config.component.application.report.ColBean; import com.wabacus.system.ReportRequest; import com.wabacus.system.component.application.report.abstractreport.AbsReportType; import com.wabacus.system.intercept.AbsPdfInterceptor; public class PdfInterceptor_dataexportpdfpage1_vp6 extends AbsPdfInterceptor { /** * PDF??? */ public void displayPerColDataWithoutTemplate(AbsReportType reportTypeObj, Object configbean, int rowidx, String value, PdfPCell cell) { if (!(configbean instanceof ColBean)) {//??<group/> return; } ReportRequest rrequest = reportTypeObj.getReportRequest(); ColBean cbean = (ColBean) configbean; if ("photo".equals(cbean.getProperty()) && rowidx >= 0) {//???? if (value != null && !value.trim().equals("")) { String serverName = rrequest.getRequest().getServerName(); String serverPort = String.valueOf(rrequest.getRequest().getServerPort()); while (value.startsWith("/")) value = value.substring(1).trim(); value = "http://" + serverName + ":" + serverPort + "/" + value;//URL try { cell.setFixedHeight(50f); Image img = Image.getInstance(value); cell.setImage(img);//?URL? // cell.addElement(new Paragraph(newvalue,font)); } catch (Exception e) { e.printStackTrace(); } } } } }