A new release of Aspose.PDF for Java 17.6 has been published offering a new feature to Get height of table in existing PDF file. Apart from this new feature, we have also introduced many fixes related to bus reported in earlier release versions. In fact, the conversion of PDF files to PDF/A format has been specifically improved to cater wide variety of PDF files.

Get Height of Table in Existing PDF File

Aspose.PDF for Java offers the feature to Add table in existing PDF file, as well as Manipulate tables in existing PDF file. Starting this new release, we also have introduced the feature to Get height of table in existing PDF document. In order to get the height information, we need to create an instance of TableAbsorber instance, iterate through page of PDF file, get rectangular instance for table object and then print the Height and Width information of extracted table instance.

// load an existing PDF document
Document doc = new Document("testtable2.pdf");
// get reference of first page of PDF document
Page page = doc.getPages().get_Item(1);
// instantiate TableAbsorber instance
TableAbsorber absorber = new TableAbsorber();
// iterate through first page of PDF file
absorber.visit(page);
// get rectangular region of first table instance
Rectangle table1_rect = absorber.getTableList().get_Item(0).getRectangle();
// print height and width of table instance
System.out.println("height: " + table1_rect.getHeight() + "; width: " + table1_rect.getWidth());

The following code snippets shows the steps to determine the rectangular region of two tables already present inside PDF file and then draw a LineAnnotation between the gap of both tables.

// load an existing PDF document
Document doc = new Document("testtable2.pdf");
// get reference of first page of PDF document
Page page = doc.getPages().get_Item(1);
// instantiate TableAbsorber instance
TableAbsorber absorber = new TableAbsorber();
// iterate through first page of PDF file
absorber.visit(page);
// get rectangular region of first table instance
Rectangle table1_rect = absorber.getTableList().get_Item(0).getRectangle();
//get rectangular region of second table instance
Rectangle table2_rect = absorber.getTableList().get_Item(1).getRectangle();
// get lowerLeftX and LowerLeftY for first table instance
Point point1 = new Point(table1_rect.getLLX(), table1_rect.getLLY());
Point point2 = new Point(table2_rect.getURX() - table2_rect.getWidth(), table2_rect.getURY());
// get rectangular region around first table
Rectangle rect = new Rectangle(table1_rect.getLLX(), table1_rect.getLLY(), table2_rect.getURX() - table2_rect.getWidth(), table2_rect.getURY());
// create Lineannotation instance
LineAnnotation lineBetweenTables = new LineAnnotation(page, rect, point1, point2);
// set LineEnding style as OpenArrow
lineBetweenTables.setEndingStyle(LineEnding.OpenArrow);
//set LineStarting style as OpenArrow
lineBetweenTables.setStartingStyle(LineEnding.OpenArrow);
// create border instance    
com.aspose.pdf.Border border = new com.aspose.pdf.Border(lineBetweenTables);
// set border width
border.setWidth(1);
// set line foreground color as blue        
lineBetweenTables.setColor(Color.getBlue());
// set border for LineAnnotation
lineBetweenTables.setBorder(border);                
// add Annotation to Annotations collection of first page of PDF file         
page.getAnnotations().add(lineBetweenTables);
// save PDF document
doc.save("c:/pdftest/testtableOut.pdf");

Please notice the blue line in above image.

Miscellaneous fixes

As mentioned above, the significant improvements have been made in PDF to PDF/A conversion. Furthermore, the HTML to PDF conversion, PDF to DOCX and PCL file to PDF conversion are also among the improvement features which help to create output files with great fidelity. As it is always recommended to use latest release of our API’s, so we suggest you to please download the latest release of Aspose.PDF for Java 17.6 and check Release Notes section regarding list of issues fixed in Aspose.PDF for Java 17.6