答案 0 :(得分:3)
我猜这是故意的; Product2
从Product2
继承了Tuple2
(确实显示在搜索结果中),因此搜索界面的设计人员可能认为搜索输出包含单独的内容会过于冗余每个子类型的结果。
您可以点击com.itextpdf.kernel.PdfException: Document was closed. It is impossible to execute action.
,然后点击“已知子类”,找出1 // UPDATE FROM HERE
2 PdfFont font;
3 {
4 GcsFilename gcsFilename = new GcsFilename("fonts", "msgothic001.ttf");
5 try (GcsInputChannel inputChannel =
6 gcsService.openPrefetchingReadChannel(gcsFilename, 0, BUFFER_SIZE)) {
7 font =
8 PdfFontFactory.createFont(
9 getBytes(Channels.newInputStream(inputChannel)),
10 PdfEncodings.IDENTITY_H,
11 true);
12 }
13 }
14 // UPDATE UNTIL HERE
15
16 WriterProperties wp = new WriterProperties();
17 wp.useSmartMode();
18 try (PdfDocument writeDoc = new PdfDocument(new PdfWriter(outputStream, wp))) {
19
20 List<Integer> keyList = Arrays.asList(Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3));
21 for (Integer keyNumber : keyList) {
22 LOGGER.info(keyNumber); // (1)
23 ByteArrayOutputStream baos = new ByteArrayOutputStream();
24 try (PdfWriter writer = new PdfWriter(baos);
25 PdfDocument readDoc =
26 new PdfDocument(new PdfReader(new ByteArrayInputStream(inputBytes)), writer)) {
27 PdfAcroForm pdfAcroForm = PdfAcroForm.getAcroForm(readDoc, false);
28 Map<String, PdfFormField> fieldMap = pdfAcroForm.getFormFields();
29 if (fieldMap != null && fieldMap.size() > 0) {
30 Set<String> fieldNameSet = new HashSet<>(fieldMap.keySet());
31 for (String fieldName : fieldNameSet) {
32 pdfAcroForm.renameField(fieldName, fieldName + "_" + keyNumber);
33 }
34 fieldMap = pdfAcroForm.getFormFields();
35 }
36
37
38 // UPDATE FROM HERE
39 PdfFormField form = fieldMap.get("Customer_" + keyNumber);
40 form.setFont(font).setValue("Test Test");
41 // UPDATE UNTIL HERE
42
43 } // (2) We got the error on this line
44
45 try (PdfDocument readDoc =
46 new PdfDocument(new PdfReader(new ByteArrayInputStream(baos.toByteArray())))) {
47 readDoc.copyPagesTo(1, readDoc.getNumberOfPages(), writeDoc, new PdfPageFormCopier());
48 }
49 }
50 }
继承此方法。