News & Releases
|
|

Spire.PDF for Java 2.9.1 supports adding image to grid and filling XfaDateTimeField
We're pleased to announce the release of Spire.PDF for Java 2.9.1. This version supports adding image to grid and filling XfaDateTimeField. Besides, some issues that occurred when converting PDF to Word, extracting Chinese text and filling the TextBoxField are fixed successfully. See the content below for more details.
New Features:
- Supports adding image to Grid.
- Supports filling XfaDateTimeField.
PdfDocument doc = new PdfDocument();
doc.loadFromFile(inputFile);
PdfPageBase page = doc.getPages().get(0);
PdfGrid grid = new PdfGrid();
PdfGridRow row = grid.getRows().add();
grid.getColumns().add(2);
grid.getColumns().get(0).setWidth(120);
grid.getColumns().get(1).setWidth(300);
Dimension2D imageSize = new Dimension();
imageSize.setSize(70,70);
float LR = (grid.getColumns().get(0).getWidth()-(float) imageSize.getWidth())/2;
PdfGridCellContentList list = new PdfGridCellContentList();
PdfGridCellContent textAndStyle = new PdfGridCellContent();
textAndStyle.setImage(PdfImage.fromFile("./Data/ImgFiles/E-iceblue logo.png"));
textAndStyle.setImageSize(imageSize);
list.getList().add(textAndStyle);
row.getCells().get(0).setValue(list);
grid.draw(page, new Point2D.Double(50, 330));
doc.saveToFile(outputFile);
PdfDocument doc = new PdfDocument();
doc.loadFromFile(inputFile);
StringBuilder sb = new StringBuilder();
PdfFormWidget formWidget = (PdfFormWidget) doc.getForm();
List xfafields = formWidget.getXFAForm().getXfaFields();
for (int i = 0; i < xfafields.size(); i++) {
if (xfafields.get(i) instanceof XfaDateTimeField) {
XfaDateTimeField xf = (XfaDateTimeField) xfafields.get(i);
sb.append( "xfafields"+i + xf.getValue() + "\r\n");
xf.setValue("gray1");
sb.append("xfafields"+i + xf.getValue() + "\r\n");
sb.append( "\r\n");
}
}
FileWriter fileWriter = new FileWriter(outputFile_T);
fileWriter.write(sb.toString());
fileWriter.flush();
fileWriter.close();
doc.saveToFile(outputFile);
Bug Fixes:
- Fixes the issue that the positions of stamp and textbox field were different when using the same coordinates to draw.
- Fixes the issue that the content was covered after converting PDF to Word.
- Fixes the issue that the extracted Chinese text was incorrect.
- Fixes the issue that the content overlapped after converting PDF to Word.
- Fixes the issue that filling the TextBoxField was failed.
Click the link to download Spire.PDF for Java 2.9.1: