|
@@ -34,18 +34,20 @@ public class PDFWrite_nohead_36 {
|
|
|
|
|
|
writer.setPdfVersion(PdfWriter.PDF_VERSION_1_2);//版本(默认1.4)
|
|
|
doc.open();// 打开文档
|
|
|
- doc.setMargins(0,0,0,0);
|
|
|
-
|
|
|
+ doc.setMargins(0,0,-20,0);
|
|
|
+ String dtoBarCode = pdfGoodsDto.getBarCode();
|
|
|
+ byte[] bytes = BarcodeUtil.generateBarCode128(dtoBarCode, 9.0d, 1.28d, false, true);
|
|
|
+ String uploadUrl = FileManager.upload(dtoBarCode + UUID.randomUUID().toString(), bytes, String.valueOf(bytes.length));
|
|
|
// -----------------------标签头----------------------
|
|
|
for (int i = 0; i < 9; i++) {
|
|
|
- getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto);
|
|
|
+ getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,uploadUrl);
|
|
|
}
|
|
|
|
|
|
doc.close(); //记得关闭document
|
|
|
|
|
|
}
|
|
|
|
|
|
- private static void getPdfPTable(Font fontChinese11, BaseFont bfHei, Document doc, PDFGoodsDto pdfGoodsDto) throws IOException, DocumentException {
|
|
|
+ private static void getPdfPTable(Font fontChinese11, BaseFont bfHei, Document doc, PDFGoodsDto pdfGoodsDto,String uploadUrl) throws IOException, DocumentException {
|
|
|
PdfPTable table = new PdfPTable(4);
|
|
|
|
|
|
// --------------产品名称-------------------------------
|
|
@@ -72,12 +74,12 @@ public class PDFWrite_nohead_36 {
|
|
|
table = new PdfPTable(4);
|
|
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
- PdfPTable pdfPTable4 = new PdfPTable(1);
|
|
|
- Font font = new Font(bfHei, 20);
|
|
|
+// PdfPTable pdfPTable4 = new PdfPTable(1);
|
|
|
+ Font font = new Font(bfHei, 18);
|
|
|
Paragraph bigPrice = new Paragraph("¥"+pdfGoodsDto.getPrice().substring(0,pdfGoodsDto.getPrice().indexOf(".")), font);
|
|
|
bigPrice.setAlignment(Element.ALIGN_BOTTOM);
|
|
|
// --------------小价格-------------------------------
|
|
|
- font = new Font(bfHei, 10);
|
|
|
+ font = new Font(bfHei, 9);
|
|
|
Paragraph smallPrice = new Paragraph(pdfGoodsDto.getPrice().substring(pdfGoodsDto.getPrice().indexOf(".")), font);
|
|
|
smallPrice.setAlignment(Element.ALIGN_BOTTOM);
|
|
|
smallPrice.setIndentationLeft(50);
|
|
@@ -87,14 +89,15 @@ public class PDFWrite_nohead_36 {
|
|
|
|
|
|
PdfPCell priceCell = new PdfPCell(bigPrice);
|
|
|
priceCell.setBorder(0);
|
|
|
- priceCell.setHorizontalAlignment(Element.ALIGN_LEFT); // 水平居中
|
|
|
- priceCell.setVerticalAlignment(Element.ALIGN_BOTTOM); // 垂直居中
|
|
|
- pdfPTable4.addCell(priceCell);
|
|
|
+ priceCell.setHorizontalAlignment(Element.ALIGN_RIGHT); // 右边
|
|
|
+ priceCell.setVerticalAlignment(Element.ALIGN_BOTTOM); // 下面
|
|
|
+ priceCell.setPaddingRight(15f);
|
|
|
+// pdfPTable4.addCell(priceCell);
|
|
|
|
|
|
|
|
|
// ----------------test-----------------------
|
|
|
PdfPTable pdfPTable8 = new PdfPTable(2);
|
|
|
- pdfPTable8.setWidths(new int[]{10,8});
|
|
|
+ pdfPTable8.setWidths(new int[]{10,11});
|
|
|
font = new Font(bfHei, 6);
|
|
|
// --------------左上的字-------------------------------
|
|
|
Paragraph leftParagraph1 = new Paragraph("\n建议零售价省¥"+pdfGoodsDto.getSavings()+"\n\n", font);
|
|
@@ -110,7 +113,7 @@ public class PDFWrite_nohead_36 {
|
|
|
|
|
|
PdfPCell p = new PdfPCell(pdfPTable8);
|
|
|
p.setBorder(0);
|
|
|
- table.setWidthPercentage(110f);
|
|
|
+ table.setWidthPercentage(112f);
|
|
|
table.addCell(p);
|
|
|
}
|
|
|
|
|
@@ -118,15 +121,15 @@ public class PDFWrite_nohead_36 {
|
|
|
doc.add(table);
|
|
|
String dtoBarCode = pdfGoodsDto.getBarCode();
|
|
|
table = new PdfPTable(4);
|
|
|
- byte[] bytes = BarcodeUtil.generateBarCode128(dtoBarCode, 9.0d, 1.28d, false, true);
|
|
|
- String uploadUrl = FileManager.upload(dtoBarCode + UUID.randomUUID().toString(), bytes, String.valueOf(bytes.length));
|
|
|
+
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
// --------------底部黑色和条形码区域-------------------------------
|
|
|
PdfPTable pdfPTable7 = new PdfPTable(2);
|
|
|
+ pdfPTable7.setWidths(new int[]{8,10});
|
|
|
Font font = new Font(bfHei, 5.5f);
|
|
|
font.setColor(Color.WHITE);
|
|
|
Paragraph PLU = new Paragraph(pdfGoodsDto.getPlu(), font);
|
|
|
- Paragraph blankParagraph = new Paragraph(" ", font);
|
|
|
+ Paragraph blankParagraph = new Paragraph(" ", font);
|
|
|
Paragraph barCode = new Paragraph(dtoBarCode.substring(dtoBarCode.length()-4), font);
|
|
|
blankParagraph.add(barCode);
|
|
|
PLU.add(blankParagraph);
|
|
@@ -144,14 +147,15 @@ public class PDFWrite_nohead_36 {
|
|
|
img.setAlignment(Image.ALIGN_CENTER); //设置图片居中
|
|
|
img.setBorder(Image.NO_BORDER);
|
|
|
img.setBorderColor(Color.WHITE);
|
|
|
- img.scaleAbsolute(72,10.5f);
|
|
|
+ img.scaleAbsolute(63,10.5f);
|
|
|
PdfPCell imgCell = new PdfPCell(img,false);
|
|
|
imgCell.setBorder(0);
|
|
|
+ imgCell.setPaddingLeft(3f);
|
|
|
pdfPTable7.addCell(pluCell);
|
|
|
pdfPTable7.addCell(imgCell);
|
|
|
PdfPCell p = new PdfPCell(pdfPTable7);
|
|
|
p.setBorder(0);
|
|
|
- table.setWidthPercentage(110f);
|
|
|
+ table.setWidthPercentage(112f);
|
|
|
table.addCell(p);
|
|
|
}
|
|
|
doc.add(table);
|
|
@@ -179,8 +183,9 @@ public class PDFWrite_nohead_36 {
|
|
|
Font font = new Font(bfHei, i2); // 设置字体
|
|
|
Paragraph paragraph = new Paragraph(s, font); // 段落
|
|
|
PdfPCell nameCell = new PdfPCell(paragraph); // 单元Cell
|
|
|
+ nameCell.setPaddingRight(10f);
|
|
|
setBasisStyle(nameCell, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE);
|
|
|
- table.setWidthPercentage(110f);
|
|
|
+ table.setWidthPercentage(112f);
|
|
|
table.addCell(nameCell);
|
|
|
}
|
|
|
|