Spire.PDF for Java 10.4.9 supports retrieving Javascript content from PDFs

2024-04-30 06:19:52

We're pleased to announce the release of Spire.PDF for Java 10.4.9. This version supports retrieving Javascript content from PDF documents, and adds a constructor method to address the issue of PdfInkAnnotation not displaying in the browser. Furthermore, it also fixes two issue that occurred when extracting tables from PDFs and flattening form fields. More details are listed below.

Here is a list of changes made in this release

Category ID Description
New feature SPIREPDF-6644 Adds a constructor method "PdfInkAnnotation ink = new PdfInkAnnotation(Rectangle2D rect, List<int[]> inkList)" to address the issue of PdfInkAnnotation not displaying in the browser.
PdfDocument doc = new PdfDocument();
PdfPageBase pdfPage = doc.getPages().add();
ArrayList inkList = new ArrayList();
int[] intPoints = new int[]
     {
         100,800,
         200,800,
         200,700
     };
inkList.add(intPoints);
Rectangle2D rect = new Rectangle2D.Float();
rect.setFrame(new Point2D.Float(0, 0), new Dimension((int)pdfPage.getActualSize().getWidth(), (int)pdfPage.getActualSize().getHeight()));
PdfInkAnnotation ink= new PdfInkAnnotation(rect,inkList);
ink.setColor(new PdfRGBColor(Color.RED));
ink.getBorder().setWidth(12);
ink.setText("e-iceblue");
pdfPage.getAnnotations().add(ink);
doc.saveToFile("inkAnnotation.pdf");
New feature SPIREPDF-6672 Supports retrieving Javascript content from PDF documents.
PdfPageBase page = pdf.getPages().get(0);
StringBuilder stringBuilder = new StringBuilder();
java.util.List<PdfJavaScriptAction> list = pdf.getNames().getJavaScripts();
stringBuilder.append(list.get(2).getScript()+"\r\n");
list.get(0).setScript("new javaScript code");
PdfAnnotationCollection annotationCollection = page.getAnnotations();
for(int i = 0;i < annotationCollection.getCount();i++){
    PdfLinkAnnotationWidget annotation = (PdfLinkAnnotationWidget) annotationCollection.get(i);
    stringBuilder.append("Method name:"+"\r\n");
    String script = ((PdfJavaScriptAction) annotation.getAction()).getScript();
    stringBuilder.append(script+"\r\n");
}
Bug SPIREPDF-6662
SPIREPDF-6667
Fixes the issue that the text in tables was not being extracted completely.
Bug SPIREPDF-6675 Fixes the issue that the application threw a "java.lang.NullPointerException" exception when saving a PDF document after flattening form fields.
Click the link below to download Spire.PDF for Java 10.4.9: