Spire.Office for Java 3.5.0

Spire.Office for Java 3.5.0 is released

We're pleased to announce the release of Spire.Office for Java 3.5.0. This version includes some fantastic new features, for instance, Spire.PDF supports digitally signing a PDF document with a timestamp server and supports adding various kinds of annotations to PDF, Spire.Presentation supports getting the maximun width of the text area in a shape. Moreover, a large number of bugs have fixed by this update.

Here is a list of changes made in this release

Spire.Doc for Java

Category ID Description
Bug SPIREDOC-4103 Fixes the issue that the application threw an error "Unknown format" when loading file.
Bug SPIREDOC-4266 Fixes the issue that the application threw an error "IndexOutOfBoundsException" when loading file.
Bug SPIREDOC-4294 Fixes the issue that the application threw an error "NullPointerException" when loading file.
Bug SPIREDOC-4355 Fixes the issue that the application threw an error "IllegalStateException" when loading file.
Bug SPIREDOC-4359 Fixes the issue that the application threw an error "ArrayIndexOutOfBoundsException" when loading file.
Bug SPIREDOC-4361 Fixes the issue that the application threw an error "No have this value 5" when loading file.
Bug SPIREDOC-4271
SPIREDOC-4371
Fixes the issue that the application threw an error "Input string was not in the correct format" when updating TOC(table of contents).
Bug SPIREDOC-4362 Fixes the issue that the application threw an error "StackOverflowError"when updating TOC(table of contents).
Bug SPIREDOC-4295 Fixes the issue that the format of content was incorrect when converting HTML to Word.
Bug SPIREDOC-4360
SPIREDOC-4370
Fixes the issue that the application threw an error "NullPointerException" when saving to file after removing section breaks.
Bug SPIREDOC-4385 Fixes the issue that the value of the formula fields was not updated correctly.

Spire.Presentation for Java

Category ID Description
New Feature SPIREPPT-1157 Supports getting the maximum width of the text input area in the shape.
IAutoShape shape = (IAutoShape) ppt.getSlides().get(0).getShapes().get(0);
float maxWidth = shape.getTextFrame().getMaxWidth();
New Feature SPIREPPT-1158 Supports getting the starting coordinates of the text when the width of the text input area is maximum.
IAutoShape shape = (IAutoShape) ppt.getSlides().get(0).getShapes().get(0);
double x = shape.getTextFrame().getStartLocationAtMaxWidth().getX();
double y = shape.getTextFrame().getStartLocationAtMaxWidth().getY();
Bug SPIREPPT-904
SPIREPPT-1164
Fixes the issue that the white text turned black when converting PPTX document to image in CentOS.
Bug SPIREPPT-1154 Fixes the issue that the text color of the table cells obtained by the method "getColor()" was incorrect.
Bug SPIREPPT-1156 Fixes the issue that the method "shape.isTextBox" returned an incorrect value.
Bug SPIREPPT-1165 Fixes the issue that the application threw the exception "Object reference not set to an instance of an object" when loading document.
Bug SPIREPPT-1172 Fixes the issue that the data table border of the chart was not displayed correctly after setting it.

Spire.PDF for Java

Category ID Description
New Feature SPIREPDF-2545 Supports digitally signing a PDF document with a timestamp server.
//Configure a timestamp server
String url = "https://freetsa.org/tsr";
signature.configureTimestamp(url);
New Feature SPIREPDF-3191

Supports showing / not showing signature information on PDF pages.

signature.addShowConfigureText(SignatureConfigureText.Contact_Info);//Show Contact_Info (default show all)
signature.removeShowConfigureText(SignatureConfigureText.Contact_Info);//Do not show Contact_Info
signature.setShowConfigureText(EnumSet.of(SignatureConfigureText.Contact_Info));//Only show Contact_Info
New Feature SPIREPDF-3194

Supports drawing Arrow annotation, Cloud annotation, Circle annotation, Square annotation and Connected lines annotation.

PdfDocument pdf = new PdfDocument();
PdfPageBase page = pdf.getPages().add();

//draw LineArrow
String text1 = "this is Arrow annotation";
PdfFont font = new PdfFont(PdfFontFamily.Helvetica, 20);
PdfSolidBrush brush1 = new PdfSolidBrush(new PdfRGBColor(Color.blue));
PdfStringFormat leftAlignment = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
page.getCanvas().drawString(text1, font, brush1, 50, 50, leftAlignment);
Dimension2D dimension = font.measureString(text1);
Rectangle2D.Float bounds = new Rectangle2D.Float(50, 50, (float) dimension.getWidth(), (float) dimension.getHeight());
int[] linePoints = new int[]{92, (int) (page.getSize().getHeight() - bounds.getY() - 60),
        (int) (92 + bounds.getWidth()), (int) (page.getSize().getHeight() - bounds.getY() - 60)};
PdfLineAnnotation annotation1 = new PdfLineAnnotation(linePoints, "LineArrow annotation test");
annotation1.setBeginLineStyle(PdfLineEndingStyle.OpenArrow);
annotation1.setEndLineStyle(PdfLineEndingStyle.OpenArrow);
annotation1.setBackColor(new PdfRGBColor(Color.red));
annotation1.setCaptionType(PdfLineCaptionType.Inline);
annotation1.setLineCaption(true);
((PdfNewPage) page).getAnnotations().add(annotation1);

//draw PolygonCloud
String text2 = "this is Cloud annotation";
PdfBrush brush2 = PdfBrushes.getBlue();
page.getCanvas().drawString(text2, font, brush2, 50, 200);
Point2D point2D[] = new Point2D[]{
        new Point2D.Float(30, 200),
        new Point2D.Float(300, 180),
        new Point2D.Float(300, 250),
        new Point2D.Float(30, 220),
        new Point2D.Float(30, 200)
};
PdfPolygonAnnotation annotation2 = new PdfPolygonAnnotation(page, point2D);
annotation2.setText("PolygonCloud annotation test");
annotation2.setAuthor("E-iceblue");
annotation2.setSubject("test");
annotation2.setModifiedDate(new Date());
annotation2.setBorderEffect(PdfBorderEffect.Big_Cloud);
annotation2.setLocation(new Point2D.Float(190, 230));
annotation2.setColor(new PdfRGBColor(Color.GRAY));
((PdfNewPage) page).getAnnotations().add(annotation2);

//draw circle
String text3 = "this is Circle annotation";
PdfBrush brush3 = PdfBrushes.getBlue();
Dimension2D dimension2D = font.measureString(text3);
dimension2D.setSize(dimension2D.getWidth() + 35, dimension2D.getHeight() + 20);
page.getCanvas().drawString(text3, font, brush3, 50, 300);
Rectangle2D.Float annotationBounds1 = new Rectangle2D.Float();
annotationBounds1.setFrame(new Point2D.Float(36, (float) 290), dimension2D);
PdfSquareAndCircleAnnotation annotation3 = new PdfSquareAndCircleAnnotation(annotationBounds1);
annotation3.setSubType(PdfSquareAndCircleAnnotationType.Circle);
float[] f1 = {0.5f, 0.5f, 0.5f, 0.5f};
annotation3.setRectangularDifferenceArray(f1);
annotation3.setText("Circle annotation test");
annotation3.setColor(new PdfRGBColor(Color.RED));
annotation3.setModifiedDate(new Date());
annotation3.setName("*****");
LineBorder border1 = new LineBorder();
border1.setBorderWidth(2);
annotation3.setLineBorder(border1);
((PdfNewPage) page).getAnnotations().add(annotation3);

//draw Square
String text4 = "this is Square annotation";
PdfBrush brush4 = PdfBrushes.getBlue();
Dimension2D dimension4 = font.measureString(text4);
dimension2D.setSize(dimension2D.getWidth() + 80, dimension2D.getHeight() + 20);
page.getCanvas().drawString(text4, font, brush4, 50, 400);
Rectangle2D.Float annotationBounds2 = new Rectangle2D.Float();
annotationBounds2.setFrame(new Point2D.Float(30, (float) 400), dimension4);
PdfSquareAndCircleAnnotation annotation4 = new PdfSquareAndCircleAnnotation(annotationBounds2);
annotation4.setSubType(PdfSquareAndCircleAnnotationType.Square);
float[] f2 = {0.5f, 0.5f, 0.5f, 0.5f};
annotation4.setRectangularDifferenceArray(f2);
annotation4.setText("Square annotation test");
annotation4.setColor(new PdfRGBColor(Color.RED));
annotation4.setModifiedDate(new Date());
annotation4.setName("*****");
LineBorder border2 = new LineBorder();
border2.setBorderWidth(2);
annotation4.setLineBorder(border2);
((PdfNewPage) page).getAnnotations().add(annotation4);


//draw connected lines
String text5 = "this is Connected lines annotation";
PdfBrush brush5 = PdfBrushes.getBlue();
page.getCanvas().drawString(text5, font, brush5, 50, 465);
Point2D pointzd[] = new Point2D[]{
        new Point2D.Float(30, 470),
        new Point2D.Float(300, 450),
        new Point2D.Float(300, 520),
        new Point2D.Float(30, 490),
        new Point2D.Float(30, 470)
};
PdfPolygonAnnotation annotation5 = new PdfPolygonAnnotation(page, pointzd);
annotation5.setText("Connected Lines annotation test");
annotation5.setAuthor("E-iceblue");
annotation5.setSubject("test");
annotation5.setModifiedDate(new Date());
annotation5.setBorderEffect(PdfBorderEffect.None);
annotation5.setLocation(new Point2D.Float(190, 230));
annotation5.setColor(new PdfRGBColor(Color.GRAY));
((PdfNewPage) page).getAnnotations().add(annotation5);

pdf.saveToFile("output/annotation.pdf");
New Feature SPIREPDF-3201 Adds the parameters "optimizingTextLine" and "optimizingGridText" to optimize the text format when extracting table text from PDF pages.
for (PdfPageBase page : (Iterable) doc.getPages()) {
    content.append(page.extractText(true,true,true));
}
Bug SPIREPDF-3189 Fixes the issue that the spaces were inconsistent with the source document when extracting text.
Bug SPIREPDF-3195 Fixes the issue that setting "setCertificated(true)" did not take effect.
Bug SPIREPDF-3199 Fixes the issue that there were extra blank lines when extacting table text.
Bug SPIREPDF-3211 Fixes the issue that the "File.delete()" method could not delete files after calling the "dispose()" method.
Bug SPIREPDF-3216 Optimizes the time spent when converting PDF to images.
Click the link to download Spire.Office for Java 3.5.0: