java 实现导出pdf 里面对各种数据进行处理

package com.smart.trucking.service;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.Collections;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.itextpdf.text.BaseColor;
import com.itextpdf.text.Chunk;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Element;
import com.itextpdf.text.Font;
import com.itextpdf.text.FontFactory;
import com.itextpdf.text.Image;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.Phrase;
import com.itextpdf.text.Rectangle;
import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.text.pdf.PdfContentByte;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
import com.smart.trucking.base.Page;
import com.smart.trucking.constant.FeeDirectionEnum;
import com.smart.trucking.constant.FeeInfoStatusEnum;
import com.smart.trucking.dao.AttachmentMapper;
import com.smart.trucking.entity.Attachment;
import com.smart.trucking.entity.MainOrders;
import com.smart.trucking.entity.vo.FeeInfoMainVo;
import com.smart.trucking.entity.vo.MainOrderDetailVo;
import com.smart.trucking.entity.vo.MainOrderFeeInfoVo;
import com.smart.trucking.entity.vo.PassingPlaceVo;
import com.smart.trucking.entity.vo.SubOrdersDetailVo;
import com.smart.trucking.param.AttachmentQueryParam;
import com.smart.trucking.param.MainOrdersQueryParam;
import com.smart.trucking.util.DateFormatUtil;

@Service
public class MainOrderPdfService {

@Autowired
private MainOrdersService mainOrdersService;
@Autowired
private AttachmentMapper attachmentMapper;

// 导出文件的路径
@Value("${spring.multipart.location}")
private String multipartLocation;

private final static String fileServer = "https://www.hswl.tech/file_server";

private final static String suffix = "?code=admin&key=1589282477226&result=ac756645a1224a0c1a7503e9e9fb350a8480c08c&system=safety_exam";

private final Font titlefont = FontFactory.getFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED, 10f,
		Font.BOLD, BaseColor.BLACK);
private final Font contentfont = FontFactory.getFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED, 10f,
		Font.NORMAL, BaseColor.BLACK);
private final Font chapterfont = FontFactory.getFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED, 20f,
		Font.BOLD, BaseColor.BLACK);
private final Font sectionfont = FontFactory.getFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED, 15f,
		Font.BOLD, BaseColor.BLACK);
private final Font textfont = FontFactory.getFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED, 13f,
		Font.BOLD, BaseColor.BLACK);
private final Font mobiletextfont = FontFactory.getFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED, 13f,
		Font.BOLD, BaseColor.BLACK);

public void createPdf() throws DocumentException, IOException {
	MainOrdersQueryParam mainOrdersQueryParam = new MainOrdersQueryParam();
	mainOrdersQueryParam.setId(264);
	mainOrdersQueryParam.setOrgType(3);
	MainOrderDetailVo mainOrderDetailVo = mainOrdersService.getById(mainOrdersQueryParam);

	// 必须要设置字体
	// 页面大小,默认A4
	Rectangle pageSize = new Rectangle(PageSize.A4);
	// Step 1—Create a Document.
	Document doc = new Document(pageSize, 30, 30, 50, 50);
	// Step 2—Get a PdfWriter instance.
	PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream(multipartLocation + "createSamplePDF.pdf"));
	// Step 3—Open the Document.
	doc.open();
	createProperties(doc, writer);
	// Step 4—Add content.

	doc.add(getTitle(mainOrderDetailVo));
	doc.add(getSplit());
	doc.add(getChapter("一、运单附件"));

	// PdfContentByte imgC = writer.getDirectContent();
	//
	// AttachmentQueryParam attachmentQueryParam = new AttachmentQueryParam();
	// attachmentQueryParam.setMaterialId(153);
	// attachmentQueryParam.setAlias(MainOrders.class.getSimpleName());
	// attachmentQueryParam.setPs(Integer.MAX_VALUE);
	// List<Attachment> attachmentList =
	// attachmentMapper.listQuery(attachmentQueryParam);
	//
	// float absolute = 0 ;
	// if(attachmentList.size() > 0) {
	// Attachment attachment2 = attachmentList.get(0);
	// Image img = Image.getInstance(fileServer + attachment2.getFilePath()+suffix);
	// img.setAbsolutePosition(absolute+=30f, 600f);
	// img.scaleToFit(100f, 100f);
	// // imgC.addImage(img);
	// attachmentList.remove(attachment2);
	// if(attachmentList.size() > 0) {
	// for(Attachment attachment: attachmentList) {
	// Image img2 = Image.getInstance(fileServer + attachment.getFilePath()+suffix);
	// img2.setAbsolutePosition(absolute+=100f, 600f);
	// img2.scaleToFit(100f, 100f);
	// imgC.addImage(img2);
	// }
	// }
	// }
	// 此处的路径取附件的路径
	Image img = Image.getInstance("D:/pdf/1.jpg");
	img.setAbsolutePosition(30f, 600f);
	img.scaleToFit(100f, 100f);
	PdfContentByte imgC = writer.getDirectContent();
	imgC.addImage(img);

	Image img2 = Image.getInstance("D:/pdf/1.jpg");
	img2.setAbsolutePosition(130f, 600f);
	img2.scaleToFit(100f, 100f);
	imgC.addImage(img2);

	doc.add(getLine());
	doc.add(getLine());
	doc.add(getLine());
	doc.add(getLine());
	doc.add(getLine());
	doc.add(getChapter("二、运单信息"));
	doc.add(getLine());

	// doc.add(getSection("(一)货主信息"));
	// doc.add(getLine());
	//
	// doc.add(getText(" 货主名称:" +
	// this.processingValue(mainOrderDetailVo.getOwnerName())));
	// doc.add(getText(" 货主联系人/联系方式:" +
	// this.processingValue(mainOrderDetailVo.getOwnerContacts()) + "/"
	// + this.processingValue(mainOrderDetailVo.getOwnerContactsTel())));
	// doc.add(getText(" 货主运费:"
	// + this.processingValue(String.valueOf(mainOrderDetailVo.getOwnerFee()))));
	// doc.add(getText(" 货主结算方式:" +
	// this.processingValue(mainOrderDetailVo.getOwnerSettlementMethod())));
	// doc.add(getText(" 承运内容/数量:" +
	// this.processingValue(mainOrderDetailVo.getCargoId().toString()) + "/" +
	// this.processingValue(mainOrderDetailVo.getCargoQuality())));
	// doc.add(getText(" 货主备注:" +
	// this.processingValue(mainOrderDetailVo.getOwnerMemo())));
	// doc.add(getLine());

	doc.add(getSection("(一)航运信息"));
	doc.add(getLine());

	doc.add(getText("    航名/航次:" + this.processingValue(mainOrderDetailVo.getVesselVoyage())));
	doc.add(getText("    截港时间:" + this.isEmptyTime(mainOrderDetailVo.getPortEndTime())));
	doc.add(getText("    开船时间:" + this.isEmptyTime(mainOrderDetailVo.getSailingTime())));
	doc.add(getText("    目的港:" + this.processingValue(mainOrderDetailVo.getDestinationPort())));
	doc.add(getText("    截单时间:" + this.isEmptyTime(mainOrderDetailVo.getOrderEndTime())));
	doc.add(getLine());

	doc.add(getSection("(二)背箱信息"));
	doc.add(getLine());

	doc.add(getText("    提单号:" + this.processingValue(mainOrderDetailVo.getLadingNo())));
	doc.add(getText("    场站:" + this.processingValue(mainOrderDetailVo.getSiteInfoStationSiteName())));
	doc.add(getText("    场站联系人/联系电话:" + this.processingValue(mainOrderDetailVo.getSiteInfoStationContacts()) + "/"
			+ this.processingValue(mainOrderDetailVo.getSiteInfoStationContactsTel())));
	// doc.add(getText(" 场站联系电话:" +
	// this.processingValue(mainOrderDetailVo.getSiteInfoStationContactsTel())));
	doc.add(getText("    可背箱时间:" + this.isEmptyTime(mainOrderDetailVo.getGetContainerTime())));
	doc.add(getText("    出发地:" + this.processingValue(mainOrderDetailVo.getSiteInfoDepartureSiteName())));
	doc.add(getText("    出发地地址:" + this.processingValue(mainOrderDetailVo.getSiteInfoDepartureAddress())));
	doc.add(getLine());

	doc.add(getSection("(三)运单信息-回箱信息"));
	doc.add(getLine());

	doc.add(getText("    回箱地:" + this.processingValue(mainOrderDetailVo.getSiteInfoContainerSiteName())));
	doc.add(getText("    回箱地址:" + this.processingValue(mainOrderDetailVo.getSiteInfoContainerAddress())));
	doc.add(getLine());

	doc.add(getChapter("三、装货地信息"));
	doc.add(getLine());

	doc.add(createPositionTable(mainOrderDetailVo));
	doc.add(getLine());

	doc.add(getChapter("四、承运车队"));
	doc.add(getLine());

	doc.add(getText("    承运车队:" + this.processingValue(mainOrderDetailVo.getCarrierName())));
	doc.add(getText("    车队联系人/联系方式:" + this.processingValue(mainOrderDetailVo.getCarrierContacts()) + "/"
			+ this.processingValue(mainOrderDetailVo.getCarrierContactsTel())));
	// doc.add(getText(" 车队联系方式:" +
	// this.processingValue(mainOrderDetailVo.getCarrierContactsTel())));
	// doc.add(getText(" 车队结算方式:" +
	// this.processingValue(mainOrderDetailVo.getCarrierSettlementMethod())));
	doc.add(getText("    车队运费/结算方式:"
			+ String.valueOf(mainOrderDetailVo.getCarrierFee() != null ? mainOrderDetailVo.getCarrierFee() : 0.0)
			+ "/" + this.processingValue(mainOrderDetailVo.getCarrierSettlementMethod())));
	doc.add(getText("    车队备注:" + this.processingValue(mainOrderDetailVo.getCarrierMemo())));
	doc.add(getText("    车队传真附件:"));
	doc.add(getLine());
	doc.add(getLine());
	doc.add(getLine());
	doc.add(getLine());

	Image img3 = Image.getInstance("D:/pdf/1.jpg");
	img3.setAbsolutePosition(30f, 600f);
	img3.scaleToFit(100f, 100f);
	imgC.addImage(img3);

	Image img4 = Image.getInstance("D:/pdf/1.jpg");
	img4.setAbsolutePosition(130f, 600f);
	img4.scaleToFit(100f, 100f);
	imgC.addImage(img4);

	doc.add(getLine());
	doc.add(getLine());
	doc.add(getLine());
	doc.add(getLine());
	doc.add(getLine());
	doc.add(getLine());
	doc.add(getChapter("五、派车信息"));
	doc.add(getLine());

	doc.add(createDispatchTable(mainOrderDetailVo));
	doc.add(getLine());

	doc.add(getChapter("六、费用信息"));
	doc.add(getLine());

	doc.add(createFeeTable(mainOrderDetailVo));
	doc.add(getLine());
	// doc.add(new Paragraph("你好 World", font));
	// Step 5—Close the Document.
	doc.close();
}

public void createPdfOwner() throws DocumentException, MalformedURLException, IOException {
	MainOrdersQueryParam mainOrdersQueryParam = new MainOrdersQueryParam();
	mainOrdersQueryParam.setId(264);
	mainOrdersQueryParam.setOrgType(3);
	MainOrderDetailVo mainOrderDetailVo = mainOrdersService.getById(mainOrdersQueryParam);

	// 必须要设置字体
	// 页面大小,默认A4
	Rectangle pageSize = new Rectangle(PageSize.A4);
	// Step 1—Create a Document.
	Document doc = new Document(pageSize, 30, 30, 50, 50);
	// Step 2—Get a PdfWriter instance.
	PdfWriter writer = PdfWriter.getInstance(doc,
			new FileOutputStream(multipartLocation + "createPdfOwnerPDF.pdf"));
	// Step 3—Open the Document.
	doc.open();
	createProperties(doc, writer);
	// Step 4—Add content.

	doc.add(getTitle(mainOrderDetailVo));
	doc.add(getSplit());
	doc.add(getChapter("一、运单附件"));

	// PdfContentByte imgC = writer.getDirectContent();
	//
	// AttachmentQueryParam attachmentQueryParam = new AttachmentQueryParam();
	// attachmentQueryParam.setMaterialId(153);
	// attachmentQueryParam.setAlias(MainOrders.class.getSimpleName());
	// attachmentQueryParam.setPs(Integer.MAX_VALUE);
	// List<Attachment> attachmentList =
	// attachmentMapper.listQuery(attachmentQueryParam);
	//
	// float absolute = 0 ;
	// if(attachmentList.size() > 0) {
	// Attachment attachment2 = attachmentList.get(0);
	// Image img = Image.getInstance(fileServer + attachment2.getFilePath()+suffix);
	// img.setAbsolutePosition(absolute+=30f, 600f);
	// img.scaleToFit(100f, 100f);
	// // imgC.addImage(img);
	// attachmentList.remove(attachment2);
	// if(attachmentList.size() > 0) {
	// for(Attachment attachment: attachmentList) {
	// Image img2 = Image.getInstance(fileServer + attachment.getFilePath()+suffix);
	// img2.setAbsolutePosition(absolute+=100f, 600f);
	// img2.scaleToFit(100f, 100f);
	// imgC.addImage(img2);
	// }
	// }
	// }
	// 此处的路径取附件的路径
	Image img = Image.getInstance("D:/pdf/1.jpg");
	img.setAbsolutePosition(30f, 600f);
	img.scaleToFit(100f, 100f);
	PdfContentByte imgC = writer.getDirectContent();
	imgC.addImage(img);

	Image img2 = Image.getInstance("D:/pdf/1.jpg");
	img2.setAbsolutePosition(130f, 600f);
	img2.scaleToFit(100f, 100f);
	imgC.addImage(img2);

	doc.add(getLine());
	doc.add(getLine());
	doc.add(getLine());
	doc.add(getLine());
	doc.add(getLine());
	doc.add(getChapter("二、运单信息"));
	doc.add(getLine());

	doc.add(getSection("(一)货主信息"));
	doc.add(getLine());

	doc.add(getText("    货主名称:" + this.processingValue(mainOrderDetailVo.getOwnerName())));
	doc.add(getText("    货主联系人/联系方式:" + this.processingValue(mainOrderDetailVo.getOwnerContacts()) + "/"
			+ this.processingValue(mainOrderDetailVo.getOwnerContactsTel())));
	doc.add(getText("    货主运费/结算方式:" + this.processingValue(String.valueOf(mainOrderDetailVo.getOwnerFee())) + "/"
			+ this.processingValue(mainOrderDetailVo.getOwnerSettlementMethod())));
	// doc.add(getText(" 货主结算方式:" +
	// this.processingValue(mainOrderDetailVo.getOwnerSettlementMethod())));
	doc.add(getText("    承运内容/数量:" + this.processingValue(mainOrderDetailVo.getCargoId().toString()) + "/"
			+ this.processingValue(mainOrderDetailVo.getCargoQuality())));
	doc.add(getText("    货主备注:" + this.processingValue(mainOrderDetailVo.getOwnerMemo())));
	doc.add(getLine());

	doc.add(getSection("(二)航运信息"));
	doc.add(getLine());

	doc.add(getText("    航名/航次:" + this.processingValue(mainOrderDetailVo.getVesselVoyage())));
	doc.add(getText("    截港时间:" + this.isEmptyTime(mainOrderDetailVo.getPortEndTime())));
	doc.add(getText("    开船时间:" + this.isEmptyTime(mainOrderDetailVo.getSailingTime())));
	doc.add(getText("    目的港:" + this.processingValue(mainOrderDetailVo.getDestinationPort())));
	doc.add(getText("    截单时间:" + this.isEmptyTime(mainOrderDetailVo.getOrderEndTime())));
	doc.add(getLine());

	doc.add(getSection("(三)背箱信息"));
	doc.add(getLine());

	doc.add(getText("    提单号:" + this.processingValue(mainOrderDetailVo.getLadingNo())));
	doc.add(getText("    场站:" + this.processingValue(mainOrderDetailVo.getSiteInfoStationSiteName())));
	doc.add(getText("    场站联系人/联系电话:" + this.processingValue(mainOrderDetailVo.getSiteInfoStationContacts()) + "/"
			+ this.processingValue(mainOrderDetailVo.getSiteInfoStationContactsTel())));
	// doc.add(getText(" 场站联系电话:" +
	// this.processingValue(mainOrderDetailVo.getSiteInfoStationContactsTel())));
	doc.add(getText("    可背箱时间:" + this.isEmptyTime(mainOrderDetailVo.getGetContainerTime())));
	doc.add(getText("    出发地:" + this.processingValue(mainOrderDetailVo.getSiteInfoDepartureSiteName())));
	doc.add(getText("    出发地地址:" + this.processingValue(mainOrderDetailVo.getSiteInfoDepartureAddress())));
	doc.add(getLine());

	doc.add(getSection("(四)运单-回箱信息"));
	doc.add(getLine());

	doc.add(getText("    回箱地:" + this.processingValue(mainOrderDetailVo.getSiteInfoContainerSiteName())));
	doc.add(getText("    回箱地址:" + this.processingValue(mainOrderDetailVo.getSiteInfoContainerAddress())));
	doc.add(getLine());

	doc.add(getChapter("三、装货地信息"));
	doc.add(getLine());

	doc.add(createPositionTable(mainOrderDetailVo));
	doc.add(getLine());

	// doc.add(getChapter("四、承运车队"));
	// doc.add(getLine());
	//
	// doc.add(getText(" 承运车队:" +
	// this.processingValue(mainOrderDetailVo.getCarrierName())));
	// doc.add(getText(" 车队联系人:" +
	// this.processingValue(mainOrderDetailVo.getCarrierContacts())));
	// doc.add(getText(" 车队联系方式:" +
	// this.processingValue(mainOrderDetailVo.getCarrierContactsTel())));
	// doc.add(getText(" 车队结算方式:" +
	// this.processingValue(mainOrderDetailVo.getCarrierSettlementMethod())));
	// doc.add(getText(" 车队备注:" +
	// this.processingValue(mainOrderDetailVo.getCarrierMemo())));
	// doc.add(getText(" 车队运费:"
	// + String.valueOf(mainOrderDetailVo.getCarrierFee() != null ?
	// mainOrderDetailVo.getCarrierFee() : 0.0)));
	// doc.add(getText(" 车队传真附件:"));
	// doc.add(getLine());

	doc.add(getChapter("四、派车信息"));
	doc.add(getLine());

	doc.add(createDispatchTable(mainOrderDetailVo));
	doc.add(getLine());

	doc.add(getChapter("五、费用信息"));
	doc.add(getLine());

	doc.add(createFeeTable(mainOrderDetailVo));
	doc.add(getLine());
	// doc.add(new Paragraph("你好 World", font));
	// Step 5—Close the Document.
	doc.close();

}

public void createPdfCustomerOwner() throws MalformedURLException, IOException, DocumentException {
	MainOrdersQueryParam mainOrdersQueryParam = new MainOrdersQueryParam();
	mainOrdersQueryParam.setId(264);
	mainOrdersQueryParam.setOrgType(3);
	MainOrderDetailVo mainOrderDetailVo = mainOrdersService.getById(mainOrdersQueryParam);

	// 必须要设置字体
	// 页面大小,默认A4
	Rectangle pageSize = new Rectangle(PageSize.A4);
	// Step 1—Create a Document.
	Document doc = new Document(pageSize, 30, 30, 50, 50);
	// Step 2—Get a PdfWriter instance.
	PdfWriter writer = PdfWriter.getInstance(doc,
			new FileOutputStream(multipartLocation + "createPdfCustomerOwnerPDF.pdf"));
	// Step 3—Open the Document.
	doc.open();
	createProperties(doc, writer);
	// Step 4—Add content.

	doc.add(getTitle(mainOrderDetailVo));
	doc.add(getSplit());
	doc.add(getChapter("一、运单附件"));

	// PdfContentByte imgC = writer.getDirectContent();
	//
	// AttachmentQueryParam attachmentQueryParam = new AttachmentQueryParam();
	// attachmentQueryParam.setMaterialId(153);
	// attachmentQueryParam.setAlias(MainOrders.class.getSimpleName());
	// attachmentQueryParam.setPs(Integer.MAX_VALUE);
	// List<Attachment> attachmentList =
	// attachmentMapper.listQuery(attachmentQueryParam);
	//
	// float absolute = 0 ;
	// if(attachmentList.size() > 0) {
	// Attachment attachment2 = attachmentList.get(0);
	// Image img = Image.getInstance(fileServer + attachment2.getFilePath()+suffix);
	// img.setAbsolutePosition(absolute+=30f, 600f);
	// img.scaleToFit(100f, 100f);
	// // imgC.addImage(img);
	// attachmentList.remove(attachment2);
	// if(attachmentList.size() > 0) {
	// for(Attachment attachment: attachmentList) {
	// Image img2 = Image.getInstance(fileServer + attachment.getFilePath()+suffix);
	// img2.setAbsolutePosition(absolute+=100f, 600f);
	// img2.scaleToFit(100f, 100f);
	// imgC.addImage(img2);
	// }
	// }
	// }
	// 此处的路径取附件的路径
	Image img = Image.getInstance("D:/pdf/1.jpg");
	img.setAbsolutePosition(30f, 600f);
	img.scaleToFit(100f, 100f);
	PdfContentByte imgC = writer.getDirectContent();
	imgC.addImage(img);

	Image img2 = Image.getInstance("D:/pdf/1.jpg");
	img2.setAbsolutePosition(130f, 600f);
	img2.scaleToFit(100f, 100f);
	imgC.addImage(img2);

	doc.add(getLine());
	doc.add(getLine());
	doc.add(getLine());
	doc.add(getLine());
	doc.add(getLine());
	doc.add(getChapter("二、运单信息"));
	doc.add(getLine());

	doc.add(getSection("(一)货主信息"));
	doc.add(getLine());

	doc.add(getText("    货主名称:" + this.processingValue(mainOrderDetailVo.getOwnerName())));
	doc.add(getText("    货主联系人/联系方式:" + this.processingValue(mainOrderDetailVo.getOwnerContacts()) + "/"
			+ this.processingValue(mainOrderDetailVo.getOwnerContactsTel())));
	doc.add(getText("    货主运费/结算方式:" + this.processingValue(String.valueOf(mainOrderDetailVo.getOwnerFee())) + "/"
			+ this.processingValue(mainOrderDetailVo.getOwnerSettlementMethod())));
	// doc.add(getText(" 货主结算方式:" +
	// this.processingValue(mainOrderDetailVo.getOwnerSettlementMethod())));
	doc.add(getText("    承运内容/数量:" + this.processingValue(mainOrderDetailVo.getCargoId().toString()) + "/"
			+ this.processingValue(mainOrderDetailVo.getCargoQuality())));
	doc.add(getText("    货主备注:" + this.processingValue(mainOrderDetailVo.getOwnerMemo())));
	doc.add(getLine());

	doc.add(getSection("(二)航运信息"));
	doc.add(getLine());

	doc.add(getText("    航名/航次:" + this.processingValue(mainOrderDetailVo.getVesselVoyage())));
	doc.add(getText("    截港时间:" + this.isEmptyTime(mainOrderDetailVo.getPortEndTime())));
	doc.add(getText("    开船时间:" + this.isEmptyTime(mainOrderDetailVo.getSailingTime())));
	doc.add(getText("    目的港:" + this.processingValue(mainOrderDetailVo.getDestinationPort())));
	doc.add(getText("    截单时间:" + this.isEmptyTime(mainOrderDetailVo.getOrderEndTime())));
	doc.add(getLine());

	doc.add(getSection("(三)背箱信息"));
	doc.add(getLine());

	doc.add(getText("    提单号:" + this.processingValue(mainOrderDetailVo.getLadingNo())));
	doc.add(getText("    场站:" + this.processingValue(mainOrderDetailVo.getSiteInfoStationSiteName())));
	doc.add(getText("    场站联系人/联系电话:" + this.processingValue(mainOrderDetailVo.getSiteInfoStationContacts()) + "/"
			+ this.processingValue(mainOrderDetailVo.getSiteInfoStationContactsTel())));
	// doc.add(getText(" 场站联系电话:" +
	// this.processingValue(mainOrderDetailVo.getSiteInfoStationContactsTel())));
	doc.add(getText("    可背箱时间:" + this.isEmptyTime(mainOrderDetailVo.getGetContainerTime())));
	doc.add(getText("    出发地:" + this.processingValue(mainOrderDetailVo.getSiteInfoDepartureSiteName())));
	doc.add(getText("    出发地地址:" + this.processingValue(mainOrderDetailVo.getSiteInfoDepartureAddress())));
	doc.add(getLine());

	doc.add(getSection("(四)运单信息-回箱信息"));
	doc.add(getLine());

	doc.add(getText("    回箱地:" + this.processingValue(mainOrderDetailVo.getSiteInfoContainerSiteName())));
	doc.add(getText("    回箱地址:" + this.processingValue(mainOrderDetailVo.getSiteInfoContainerAddress())));
	doc.add(getLine());

	doc.add(getChapter("三、装货地信息"));
	doc.add(getLine());

	doc.add(createPositionTable(mainOrderDetailVo));
	doc.add(getLine());

	doc.add(getChapter("四、承运车队"));
	doc.add(getLine());

	doc.add(getText("    承运车队:" + this.processingValue(mainOrderDetailVo.getCarrierName())));
	doc.add(getText("    车队联系人/联系方式:" + this.processingValue(mainOrderDetailVo.getCarrierContacts()) + "/"
			+ this.processingValue(mainOrderDetailVo.getCarrierContactsTel())));
	// doc.add(getText(" 车队联系方式:" +
	// this.processingValue(mainOrderDetailVo.getCarrierContactsTel())));
	// doc.add(getText(" 车队结算方式:" +
	// this.processingValue(mainOrderDetailVo.getCarrierSettlementMethod())));
	doc.add(getText("    车队备注:" + this.processingValue(mainOrderDetailVo.getCarrierMemo())));
	doc.add(getText("    车队运费/结算方式:"
			+ String.valueOf(mainOrderDetailVo.getCarrierFee() != null ? mainOrderDetailVo.getCarrierFee() : 0.0)
			+ "/" + this.processingValue(mainOrderDetailVo.getCarrierSettlementMethod())));
	doc.add(getText("    车队传真附件:"));
	doc.add(getLine());

	doc.add(getChapter("五、派车信息"));
	doc.add(getLine());

	doc.add(createDispatchTable(mainOrderDetailVo));
	doc.add(getLine());

	doc.add(getChapter("六、费用信息"));
	doc.add(getLine());

	doc.add(createFeeTable(mainOrderDetailVo));
	doc.add(getLine());
	// doc.add(new Paragraph("你好 World", font));
	// Step 5—Close the Document.
	doc.close();

}

public void pdfMobileOwner() throws DocumentException, MalformedURLException, IOException {
	MainOrdersQueryParam mainOrdersQueryParam = new MainOrdersQueryParam();
	mainOrdersQueryParam.setOwnerId(1);
	mainOrdersQueryParam.setPs(Integer.MAX_VALUE);
	Page<FeeInfoMainVo> pageQueryFeeInfo = mainOrdersService.pageQueryFeeInfo(mainOrdersQueryParam);
	List<FeeInfoMainVo> FeeInfoMainVoList = pageQueryFeeInfo.getContents();
	// 必须要设置字体
	// 页面大小,默认A4
	Rectangle pageSize = new Rectangle(PageSize.A4);
	// Step 1—Create a Document.
	Document doc = new Document(pageSize, 30, 30, 50, 50);
	// Step 2—Get a PdfWriter instance.
	PdfWriter writer = PdfWriter.getInstance(doc,
			new FileOutputStream(multipartLocation + "pdfMobileOwnerPDF.pdf"));
	// Step 3—Open the Document.
	doc.open();
	createProperties(doc, writer);
	// Step 4—Add content.

	// doc.add(getTitle(mainOrderDetailVo));
	// doc.add(getSplit());orderTime
	if (FeeInfoMainVoList.size() > 0) {
		for (FeeInfoMainVo feeInfoMainVo : FeeInfoMainVoList) {
			doc.add(getChapter("运单单号:" + this.processingValue(feeInfoMainVo.getOrderNo()) + this.notSmallWrap()
					+ "应付/未付总费用: " + "¥"
					+ String.valueOf(
							feeInfoMainVo.getMainFeeNumber() != null ? feeInfoMainVo.getMainFeeNumber() : 0.0)
					+ "/" + String.valueOf(
							feeInfoMainVo.getMainoffNumber() != null ? feeInfoMainVo.getMainoffNumber() : 0.0)));
			doc.add(getLine());
			doc.add(getMobileText("    下单时间:" + this.isEmptyTime(feeInfoMainVo.getOrderTime()) + this.notWrap()
					+ "负责人:" + this.processingValue(feeInfoMainVo.getAgentcontacts())));
			doc.add(getMobileText("    完成时间:" + this.isEmptyTime(feeInfoMainVo.getServiceFinishTime())
					+ this.notWrap() + " 箱型/箱量:" + this.processingValue(feeInfoMainVo.getBox())));
			doc.add(getMobileText("    账期:" + this.processingValue(feeInfoMainVo.getOwnerSettlementMethod())));

			doc.add(getLine());

			doc.add(getMobileText("    费用调整 "));
			doc.add(getLine());

			doc.add(createCostAdjustmentTable(feeInfoMainVo));

			doc.add(getLine());
		}
	}
	doc.close();

}

public void pdfMobileCarrier() throws DocumentException, MalformedURLException, IOException {
	MainOrdersQueryParam mainOrdersQueryParam = new MainOrdersQueryParam();
	mainOrdersQueryParam.setOwnerId(1);
	mainOrdersQueryParam.setPs(Integer.MAX_VALUE);
	Page<FeeInfoMainVo> pageQueryFeeInfo = mainOrdersService.pageQueryFeeInfo(mainOrdersQueryParam);
	List<FeeInfoMainVo> FeeInfoMainVoList = pageQueryFeeInfo.getContents();

	// 必须要设置字体
	// 页面大小,默认A4
	Rectangle pageSize = new Rectangle(PageSize.A4);
	// Step 1—Create a Document.
	Document doc = new Document(pageSize, 30, 30, 50, 50);
	// Step 2—Get a PdfWriter instance.
	PdfWriter writer = PdfWriter.getInstance(doc,
			new FileOutputStream(multipartLocation + "pdfMobileCarrierPDF.pdf"));
	// Step 3—Open the Document.
	doc.open();
	createProperties(doc, writer);
	// Step 4—Add content.

	if (FeeInfoMainVoList.size() > 0) {
		for (FeeInfoMainVo feeInfoMainVo : FeeInfoMainVoList) {
			doc.add(getChapter("运单单号:" + this.processingValue(feeInfoMainVo.getOrderNo()) + this.notSmallWrap()
					+ "应付/未付总费用:" + "¥"
					+ String.valueOf(
							feeInfoMainVo.getMainFeeNumber() != null ? feeInfoMainVo.getMainFeeNumber() : 0.0)
					+ "/" + String.valueOf(
							feeInfoMainVo.getMainoffNumber() != null ? feeInfoMainVo.getMainoffNumber() : 0.0)));
			doc.add(getLine());
			doc.add(getMobileText("    派单时间:" + this.isEmptyTime(feeInfoMainVo.getOrderTime()) + this.notWrap()
					+ "负责人:" + this.processingValue(feeInfoMainVo.getAgentcontacts())));
			doc.add(getMobileText("    完成时间:" + this.isEmptyTime(feeInfoMainVo.getServiceFinishTime())
					+ this.notWrap() + " 箱型/箱量:" + this.processingValue(feeInfoMainVo.getBox())));
			doc.add(getMobileText("    账期:" + this.processingValue(feeInfoMainVo.getOwnerSettlementMethod())));

			doc.add(getLine());

			doc.add(getMobileText("    费用调整 "));
			doc.add(getLine());

			doc.add(createCostAdjustmentCarrierTable(feeInfoMainVo));

			doc.add(getLine());
		}
	}

	// doc.add(new Paragraph("你好 World", font));
	// Step 5—Close the Document.
	doc.close();

}

/**
 * 顶部的title
 */
private Paragraph getTitle(MainOrderDetailVo mainOrderDetailVo) {
	Chunk chunkSpace = new Chunk(String.join("", Collections.nCopies(40, " ")));
	Paragraph paragraph = new Paragraph();
	Chunk chunkTitle = new Chunk("订单号:", titlefont);
	Chunk chunkContent = new Chunk(this.processingValue(mainOrderDetailVo.getOrderNo()), contentfont);
	paragraph.add(chunkTitle);
	paragraph.add(chunkContent);
	paragraph.add(chunkSpace);
	// chunkTitle = new Chunk("派单人:", titlefont);
	// chunkContent = new
	// Chunk(this.processingValue(mainOrderDetailVo.getAgentContacts())
	// , contentfont);
	// paragraph.add(chunkTitle);
	// paragraph.add(chunkContent);
	// paragraph.add(chunkSpace);
	chunkTitle = new Chunk("派单人/联系方式:", titlefont);
	chunkContent = new Chunk(this.processingValue(mainOrderDetailVo.getAgentContacts()) + "/"
			+ this.processingValue(mainOrderDetailVo.getAgentContactsTel()), contentfont);
	paragraph.add(chunkTitle);
	paragraph.add(chunkContent);
	paragraph.setAlignment(Element.ALIGN_CENTER);
	return paragraph;
}

/**
 * 横线
 */
private Paragraph getSplit() {
	Paragraph paragraph = new Paragraph();
	Chunk chunkSplit = new Chunk(String.join("", Collections.nCopies(120, "-")));
	paragraph.add(chunkSplit);
	paragraph.setAlignment(Element.ALIGN_CENTER);
	return paragraph;
}

/**
 * 大章节
 */
private Paragraph getChapter(String value) {
	return new Paragraph(value, chapterfont);
}

/**
 * 换行
 */
private Paragraph getLine() {
	return new Paragraph(" ", chapterfont);
}

/**
 * 小章节
 */
private Paragraph getSection(String value) {
	return new Paragraph(value, sectionfont);
}

/**
 * 正文
 */
private Paragraph getText(String value) {
	return new Paragraph(value, textfont);
}

/**
 * 小程序正文
 */
private Paragraph getMobileText(String value) {
	return new Paragraph(value, mobiletextfont);
}

private void createProperties(Document doc, PdfWriter writer) throws DocumentException, FileNotFoundException {

	// PDF版本(默认1.4)
	writer.setPdfVersion(PdfWriter.PDF_VERSION_1_2);

	// 文档属性
	doc.addTitle("Title@sample");
	doc.addAuthor("Author@rensanning");
	doc.addSubject("Subject@iText sample");
	doc.addKeywords("Keywords@iText");
	doc.addCreator("Creator@iText");
}

/**
 * 创建表 加入的字段必须都是对齐的,定义了每行cell的数量就必须对应填充够,会自动填充到下一行中
 */
private PdfPTable createPositionTable(MainOrderDetailVo mainOrderDetailVo) {
	PdfPTable table = new PdfPTable(4);
	table.addCell(new PdfPCell(new Phrase("地点名称", titlefont)));
	table.addCell(new PdfPCell(new Phrase("地址", titlefont)));
	table.addCell(new PdfPCell(new Phrase("联系电话", titlefont)));
	table.addCell(new PdfPCell(new Phrase("要求到达时间", titlefont)));

	if (mainOrderDetailVo.getPassingPlaceList().size() > 0) {
		for (PassingPlaceVo passingPlaceVo : mainOrderDetailVo.getPassingPlaceList()) {
			if (passingPlaceVo.getSiteInfoSiteName() != null) {
				table.addCell(new PdfPCell(new Phrase(passingPlaceVo.getSiteInfoSiteName(), titlefont)));
			} else {
				table.addCell(" ");
			}
			if (passingPlaceVo.getSiteInfoAddress() != null) {
				table.addCell(new PdfPCell(new Phrase(passingPlaceVo.getSiteInfoAddress(), titlefont)));
			} else {
				table.addCell(" ");
			}
			if (passingPlaceVo.getSiteInfoContactsTel() != null) {
				table.addCell(new PdfPCell(new Phrase(passingPlaceVo.getSiteInfoContactsTel(), titlefont)));
			} else {
				table.addCell(" ");
			}
			String emptyTime4 = this.isEmptyTime(passingPlaceVo.getAskTime());
			if (passingPlaceVo.getAskTime() == null) {
				table.addCell(" ");
			} else {
				table.addCell(new PdfPCell(new Phrase(emptyTime4, titlefont)));
			}

		}
	} else {
		// 第一行填充完毕,开始第二行
		table.addCell(" ");
		table.addCell(" ");
		table.addCell(" ");
		table.addCell(" ");
	}
	// 第一行填充完毕,开始第二行
	// table.addCell(" ");
	// table.addCell(" ");
	// table.addCell(" ");
	// table.addCell(" ");

	return table;
}

private PdfPTable createDispatchTable(MainOrderDetailVo mainOrderDetailVo) {
	PdfPTable table = new PdfPTable(6);
	table.addCell(new PdfPCell(new Phrase("海关监管", titlefont)));
	table.addCell(new PdfPCell(new Phrase("箱型", titlefont)));
	table.addCell(new PdfPCell(new Phrase("箱号", titlefont)));
	table.addCell(new PdfPCell(new Phrase("铅封号", titlefont)));
	table.addCell(new PdfPCell(new Phrase("车牌号", titlefont)));
	table.addCell(new PdfPCell(new Phrase("驾驶员", titlefont)));

	if (mainOrderDetailVo.getListSubOrdersDetailVo().size() > 0) {
		for (SubOrdersDetailVo subOrdersDetailVo : mainOrderDetailVo.getListSubOrdersDetailVo()) {
			if (subOrdersDetailVo.getSubOrdersState() != null) {
				table.addCell(new PdfPCell(new Phrase(
						subOrdersDetailVo.getSubOrdersState().toString().equals("0") ? "不监管" : "监管", titlefont)));
			} else {
				table.addCell(" ");
			}
			if (subOrdersDetailVo.getContainerName() != null) {
				table.addCell(new PdfPCell(new Phrase(subOrdersDetailVo.getContainerName(), titlefont)));
			} else {
				table.addCell(" ");
			}
			if (subOrdersDetailVo.getContainerType() != null) {
				table.addCell(new PdfPCell(new Phrase(subOrdersDetailVo.getContainerType(), titlefont)));
			} else {
				table.addCell(" ");
			}
			if (subOrdersDetailVo.getSealNo() != null) {
				table.addCell(new PdfPCell(new Phrase(subOrdersDetailVo.getSealNo(), titlefont)));
			} else {
				table.addCell(" ");
			}
			if (subOrdersDetailVo.getPlateNo() != null) {
				table.addCell(new PdfPCell(new Phrase(subOrdersDetailVo.getPlateNo(), titlefont)));
			} else {
				table.addCell(" ");
			}
			if (subOrdersDetailVo.getDriverName() != null) {
				table.addCell(new PdfPCell(new Phrase(subOrdersDetailVo.getDriverName(), titlefont)));
			} else {
				table.addCell(" ");
			}
		}
	} else {
		// 第一行填充完毕,开始第二行
		table.addCell(" ");
		table.addCell(" ");
		table.addCell(" ");
		table.addCell(" ");
		table.addCell(" ");
		table.addCell(" ");
	}
	return table;
}

private PdfPTable createFeeTable(MainOrderDetailVo mainOrderDetailVo) {
	PdfPTable table = new PdfPTable(9);
	table.addCell(new PdfPCell(new Phrase("状态", titlefont)));
	table.addCell(new PdfPCell(new Phrase("费用对象", titlefont)));
	table.addCell(new PdfPCell(new Phrase("费用名称", titlefont)));
	table.addCell(new PdfPCell(new Phrase("费用方向", titlefont)));
	table.addCell(new PdfPCell(new Phrase("金额", titlefont)));
	table.addCell(new PdfPCell(new Phrase("审核人/时间", titlefont)));
	table.addCell(new PdfPCell(new Phrase("提报人/时间", titlefont)));
	table.addCell(new PdfPCell(new Phrase("销账人/时间", titlefont)));
	table.addCell(new PdfPCell(new Phrase("销账金额", titlefont)));

	if (mainOrderDetailVo.getListMainFee().size() > 0) {
		for (MainOrderFeeInfoVo mainOrderFeeInfoVo : mainOrderDetailVo.getListMainFee()) {
			if (mainOrderFeeInfoVo.getServiceState() != null) {
				table.addCell(new PdfPCell(
						new Phrase(this.serviceState(mainOrderFeeInfoVo.getServiceState()), titlefont)));
			} else {
				table.addCell(" ");
			}
			if (mainOrderFeeInfoVo.getAccountName() != null) {
				table.addCell(new PdfPCell(new Phrase(mainOrderFeeInfoVo.getAccountName(), titlefont)));
			} else {
				table.addCell(" ");
			}

			if (mainOrderFeeInfoVo.getFeeName() != null) {
				table.addCell(new PdfPCell(new Phrase(mainOrderFeeInfoVo.getFeeName(), titlefont)));
			} else {
				table.addCell(" ");
			}

			if (mainOrderFeeInfoVo.getFeeDirection() != null) {
				table.addCell(new PdfPCell(new Phrase(mainOrderFeeInfoVo.getFeeDirection().toString(), titlefont)));
			} else {
				table.addCell(" ");
			}

			if (mainOrderFeeInfoVo.getFeeNumber() != null) {
				table.addCell(new PdfPCell(new Phrase(mainOrderFeeInfoVo.getFeeNumber().toString(), titlefont)));
			} else {
				table.addCell(" ");
			}
			System.err.println(mainOrderFeeInfoVo.getApprovalTime() == null);

			// DateFormatUtil.dataFormat(mainOrderFeeInfoVo.getApprovalTime(),DateFormatUtil.DATA_FORMAT_ONE);

			String emptyTime = this.isEmptyTime(mainOrderFeeInfoVo.getApprovalTime());
			table.addCell(new PdfPCell(new Phrase(
					mainOrderFeeInfoVo.getApprovalUserName() != null ? mainOrderFeeInfoVo.getApprovalUserName()
							: " " + "/" + emptyTime,
					titlefont)));

			String emptyTime2 = this.isEmptyTime(mainOrderFeeInfoVo.getCreateTime());
			table.addCell(new PdfPCell(new Phrase(
					mainOrderFeeInfoVo.getCreateUserId() != null ? mainOrderFeeInfoVo.getCreateUserId().toString()
							: " " + "/" + emptyTime2,
					titlefont)));

			String emptyTime3 = this.isEmptyTime(mainOrderFeeInfoVo.getCreateTime());

			table.addCell(new PdfPCell(
					new Phrase(mainOrderFeeInfoVo.getOffsetName() != null ? mainOrderFeeInfoVo.getOffsetName()
							: " " + "/" + emptyTime3, titlefont)));
			if (mainOrderFeeInfoVo.getOffsetFeeNumber() != null) {
				table.addCell(
						new PdfPCell(new Phrase(mainOrderFeeInfoVo.getOffsetFeeNumber().toString(), titlefont)));
			} else {
				table.addCell(" ");
			}

		}

	} else {
		// 第一行填充完毕,开始第二行
		table.addCell(" ");
		table.addCell(" ");
		table.addCell(" ");
		table.addCell(" ");
		table.addCell(" ");
		table.addCell(" ");
		table.addCell(" ");
		table.addCell(" ");
		table.addCell(" ");
	}
	return table;
}

/**
 * 创建表 加入的字段必须都是对齐的,定义了每行cell的数量就必须对应填充够,会自动填充到下一行中
 */
private PdfPTable createCostAdjustmentTable(FeeInfoMainVo feeInfoMainVo) {
	PdfPTable table = new PdfPTable(3);
	table.addCell(new PdfPCell(new Phrase("费用名称", titlefont)));
	table.addCell(new PdfPCell(new Phrase("费用金额", titlefont)));
	table.addCell(new PdfPCell(new Phrase("费用方向", titlefont)));

	// 判断 费用对象是否为空 不为空让它走下边的列表循环
	if (feeInfoMainVo.getListMainFee().size() > 0) {
		for (MainOrderFeeInfoVo mainOrderFeeInfoVo : feeInfoMainVo.getListMainFee()) {
			if (mainOrderFeeInfoVo.getFeeName() != null) {
				table.addCell(new PdfPCell(new Phrase(mainOrderFeeInfoVo.getFeeName(), titlefont)));
			} else {
				table.addCell(" ");
			}
			if (mainOrderFeeInfoVo.getFeeNumber() != null) {
				table.addCell(new PdfPCell(new Phrase(mainOrderFeeInfoVo.getFeeNumber().toString(), titlefont)));
			} else {
				table.addCell(" ");
			}
			if (mainOrderFeeInfoVo.getFeeDirection() != null) {
				table.addCell(new PdfPCell(
						new Phrase(this.feeDirection(mainOrderFeeInfoVo.getFeeDirection()), titlefont)));
			} else {
				table.addCell(" ");
			}

		}
	} else {
		// 第一行填充完毕,开始第二行
		table.addCell(" ");
		table.addCell(" ");
		table.addCell(" ");
	}
	// 第一行填充完毕,开始第二行
	// table.addCell(" ");
	// table.addCell(" ");
	// table.addCell(" ");
	// table.addCell(" ");

	return table;
}

/**
 * 创建表 加入的字段必须都是对齐的,定义了每行cell的数量就必须对应填充够,会自动填充到下一行中
 */
private PdfPTable createCostAdjustmentCarrierTable(FeeInfoMainVo feeInfoMainVo) {
	PdfPTable table = new PdfPTable(3);
	table.addCell(new PdfPCell(new Phrase("费用名称", titlefont)));
	table.addCell(new PdfPCell(new Phrase("费用金额", titlefont)));
	table.addCell(new PdfPCell(new Phrase("费用方向", titlefont)));

	// 判断 费用对象是否为空 不为空让它走下边的列表循环
	if (feeInfoMainVo.getListMainFee().size() > 0) {
		for (MainOrderFeeInfoVo mainOrderFeeInfoVo : feeInfoMainVo.getListMainFee()) {
			if (mainOrderFeeInfoVo.getFeeName() != null) {
				table.addCell(new PdfPCell(new Phrase(mainOrderFeeInfoVo.getFeeName(), titlefont)));
			} else {
				table.addCell(" ");
			}
			if (mainOrderFeeInfoVo.getFeeNumber() != null) {
				table.addCell(new PdfPCell(new Phrase(mainOrderFeeInfoVo.getFeeNumber().toString(), titlefont)));
			} else {
				table.addCell(" ");
			}
			if (mainOrderFeeInfoVo.getFeeDirection() != null) {
				table.addCell(new PdfPCell(
						new Phrase(this.feeDirection(mainOrderFeeInfoVo.getFeeDirection()), titlefont)));
			} else {
				table.addCell(" ");
			}
		}
	} else {
		// 第一行填充完毕,开始第二行
		table.addCell(" ");
		table.addCell(" ");
		table.addCell(" ");
	}
	// 第一行填充完毕,开始第二行
	// table.addCell(" ");·
	// table.addCell(" ");
	// table.addCell(" ");
	// table.addCell(" ");

	return table;
}

/**
 * 对费用方向状态的处理
 */
private String feeDirection(Integer feeDirection) {

	switch (feeDirection) {
	case 1:

		return FeeDirectionEnum.RECEIVALBLE.getDesc();
	case 2:

		return FeeDirectionEnum.COPEWITH.getDesc();

	case 3:

		return FeeDirectionEnum.BOOKKEEPING.getDesc();

	default:
		break;
	}
	return null;
}

/**
 * 对时间的处理
 * 
 * @param Time
 * @return
 */
private String isEmptyTime(Date Time) {
	if (Time == null) {
		return " ";
	} else {
		String dataFormat = DateFormatUtil.dataFormat(Time, DateFormatUtil.DATA_FORMAT_ONE);

		return dataFormat;
	}

}

/**
 * 对费用信息状态的处理
 */
private String serviceState(Integer serviceState) {

	switch (serviceState) {
	case 0:

		return FeeInfoStatusEnum.UNAPPROVAL.getContent();
	case 1:

		return FeeInfoStatusEnum.ONGOING.getContent();

	case 2:

		return FeeInfoStatusEnum.ADOPT.getContent();
	case 3:

		return FeeInfoStatusEnum.NON_THROUGHT.getContent();

	case 4:

		return FeeInfoStatusEnum.PART.getContent();
	case 5:

		return FeeInfoStatusEnum.ALL.getContent();
	default:
		break;
	}
	return null;
}

/**
 * 对值为null 的处理
 */
private String processingValue(String value) {

	if (value == null) {
		return " ";
	} else {
		return value;
	}
}

/**
 * 对小程序空格 不换行处理
 */
private String notWrap() {

	return "                                          ";
}

/**
 * 对小程序大标题空格 不换行处理
 */
private String notSmallWrap() {

	return "           ";
}
/**
 * double对值为null 的处理
 */
private String processingValue(Double value) {

	if (value == null) {
		return " ";
	} else {
		return String.valueOf(value);
	}
}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 非常感谢您的提问。关于使用Java实现数据PDF文件导出的问题,可以使用Java PDF库来实现。常用的Java PDF库有iText和PDFBox等。这些库可以让您使用Java代码来创建、修改和导出PDF文件。您可以使用这些库来创建包含表格、图形和文本等元素的PDF文件,然后导出PDF格式。使用这些库需要一定的Java编程知识,但是它们都提供了丰富的文档和示例代码,方便开发者使用。 ### 回答2: 使用Java实现数据PDF文件导出可以通过使用第三方库来实现。其中最常用且功能强大的库是iText库。以下是使用iText库来实现数据PDF文件导出的步骤: 1. 首先,需要在项目中导入iText库的相关jar包。 2. 创建一个PDF文档对象,可以通过`Document`类来实现,例如:`Document document = new Document();` 3. 使用`PdfWriter`类来指定输出的文件路径和文件名,例如:`PdfWriter.getInstance(document, new FileOutputStream("output.pdf"));` 4. 打开文档对象:`document.open();` 5. 根据需求,可以添加标题、表格、图像等内容来填充PDF文件。例如,可以使用`Paragraph`类来添加标题:`document.add(new Paragraph("标题"));` 6. 在PDF文件中添加数据表格,可以使用`PdfPTable`类来创建表格,然后使用`PdfPCell`类来添加表格内容。 7. 可以通过循环遍历数据来将数据填充到表格中。 8. 设置样式,可以使用`Font`类来设置字体、颜色等样式。 9. 关闭文档:`document.close();` 10. 最后,导出PDF文件会保存在指定路径中。 除了iText库,还有其他一些可供选择的库,例如Apache PDFBox等,都可以用来实现数据PDF文件导出。但是无论使用哪个库,基本的步骤和原理是相似的。 总之,使用Java实现数据PDF文件导出可以通过使用第三方库来简化开发过程,并且可以实现丰富的样式和内容。 ### 回答3: PDF是一种常用的文件格式,用于显示和打印文档,并且可以保持文档的格式不变。Java是一种常用的编程语言,具有强大的文档处理能力和丰富的库和工具。 要使用Java实现PDF文件导出,可以使用第三方库或工具,如iText、Apache PDFBox等。这些库提供了丰富的API,可以让开发人员创建、操作和导出PDF文件。 首先,我们需要使用Java代码创建一个PDF文档对象。可以设置文档的属性,如页面大小、边距等,然后可以添加文本、图像、表格等内容到文档中。 对于添加文本,可以使用库提供的API来设置字体、大小、颜色等,然后将文本添加到页面中的指定位置。 对于添加图像,可以使用库提供的API来加载图像文件,然后将图像添加到页面中的指定位置。 对于添加表格,可以使用库提供的API来定义表格结构,设置表格样式和内容,然后将表格添加到页面中的指定位置。 最后,可以使用Java代码将创建的PDF文档保存到本地硬盘或输出流中,以供用户下载或进一步处理使用Java实现PDF文件导出,可以方便地生成和操作PDF文件,满足各种场景下对于文档的需求。无论是自动生成报告、生成电子书籍还是其他需要保留格式的文档,Java都可以提供灵活而强大的解决方案。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值