Hello,
Thank you for your patience.
Glad to inform that we just released Spire.Pdf for Java 10.12.10 which fixed the issue of failed extraction of vertical text in the table, welcome to download it from the following link and test it. However, the content shown in the figure below may still be lost because the characters used in this part of the content do not correspond to valid Unicode characters. Therefore, even if Adobe software is used for copying, it will still result in content loss. Our developers will further fix it, and once this issue is resolved, we will notify you immediately. Thank you for your understanding.
link:
https://www.e-iceblue.com/Download/pdf-for-java.htmlTest code:
- Code: Select all
PdfDocument pdf = new PdfDocument();
pdf.loadFromFile("Test Report.pdf");
StringBuilder builder = new StringBuilder();
//Create an object of the PdfTableExtractor class
PdfTableExtractor extractor = new PdfTableExtractor(pdf);
//Traverse every page
for (int page = 0; page < pdf.getPages().getCount(); page++)
{
//Extract tables from the page and store them in the PdfTable[]
PdfTable[] tableLists = extractor.extractTable(page);
if (tableLists != null && tableLists.length > 0)
{
//Traverse the table
for (PdfTable table : tableLists)
{
//Retrieve table rows
int row = table.getRowCount();
//Retrieve table columns
int column = table.getColumnCount();
for (int i = 0; i < row; i++)
{
for (int j = 0; j < column; j++)
{
//Retrieve the text content from the table
String text = table.getText(i, j);
builder.append(text+" ");
}
builder.append("\r\n");
}
}
}
}
//Save as txt
FileWriter fileWriter = new FileWriter("ExtractedTable.txt");
fileWriter.write(builder.toString());
fileWriter.flush();
fileWriter.close();
Login to view the files attached to this post.