|
|
|
@ -1,9 +1,11 @@
|
|
|
|
|
package cn.teammodel.utils;
|
|
|
|
|
|
|
|
|
|
import com.itextpdf.text.DocumentException;
|
|
|
|
|
import com.itextpdf.text.Font;
|
|
|
|
|
import com.itextpdf.text.Image;
|
|
|
|
|
import com.itextpdf.text.Rectangle;
|
|
|
|
|
import com.itextpdf.text.pdf.AcroFields;
|
|
|
|
|
import com.itextpdf.text.pdf.BaseFont;
|
|
|
|
|
import com.itextpdf.text.pdf.PdfContentByte;
|
|
|
|
|
import com.itextpdf.text.pdf.PdfStamper;
|
|
|
|
|
|
|
|
|
@ -16,8 +18,13 @@ import java.util.Map;
|
|
|
|
|
*/
|
|
|
|
|
public class PdfUtil {
|
|
|
|
|
public static void fillPdfForm(PdfStamper stamper, Map<String, String> data) throws IOException, DocumentException {
|
|
|
|
|
BaseFont baseFont = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
|
|
|
|
|
Font boldFont = new Font(baseFont, 16, Font.BOLD);
|
|
|
|
|
AcroFields fields = stamper.getAcroFields();
|
|
|
|
|
for (Map.Entry<String, String> entry : data.entrySet()) {
|
|
|
|
|
|
|
|
|
|
fields.setFieldProperty(entry.getKey(), "textsize", boldFont.getSize(), null);
|
|
|
|
|
fields.setFieldProperty(entry.getKey(), "textfont", baseFont, null); // 设置字体为加粗
|
|
|
|
|
fields.setField(entry.getKey(), entry.getValue());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|