第一个文件“PnL_500010_0314.pdf”
实际上,整行“截至 2014 年 3 月 31 日止年度的损益表”以及更多内容无法提取;检查内容,原因很明显:此文本是使用复合字体编写的,该字体既没有 Encoding 也没有 ToUnicode 条目以允许识别有问题的字符。
在调用processTextPosition(PDFTextStripper 实现并从中检索其文本信息)之前不久,org.apache.pdfbox.text.PDFTextStreamEngine(从中派生出PDFTextStripper)方法showGlyph 包含以下代码:
// use our additional glyph list for Unicode mapping
unicode = font.toUnicode(code, glyphList);
// when there is no Unicode mapping available, Acrobat simply coerces the character code
// into Unicode, so we do the same. Subclasses of PDFStreamEngine don't necessarily want
// this, which is why we leave it until this point in PDFTextStreamEngine.
if (unicode == null)
{
if (font instanceof PDSimpleFont)
{
char c = (char) code;
unicode = new String(new char[] { c });
}
else
{
// Acrobat doesn't seem to coerce composite font's character codes, instead it
// skips them. See the "allah2.pdf" TestTextStripper file.
return;
}
}
有问题的字体没有为文本提取提供任何线索。因此,unicode 这里是null。
此外,字体是复合的,而不是简单的。因此,else 子句被执行,processTextPosition 甚至没有被调用。
因此,PDFTextStripper 根本不知道“截至 2014 年 3 月 31 日止年度的损益表”这一行甚至存在!
如果你替换它
else
{
// Acrobat doesn't seem to coerce composite font's character codes, instead it
// skips them. See the "allah2.pdf" TestTextStripper file.
return;
}
在PDFTextStreamEngine.showGlyph 中通过一些代码设置unicode,例如使用 Unicode 替换字符
else
{
// Use the Unicode replacement character to indicate an unknown character
unicode = "\uFFFD";
}
你会得到
57
THIRTY SEVENTH ANNUAL REPORT 2013-14
STANDALONE FINANCIAL STATEMENTS
�������������������������������������������������������������
As per our report attached. Directors
For Deloitte Haskins & Sells LLP Deepak S. Parekh Nasser Munjee R. S. Tarneja
Chartered Accountants �������� B. S. Mehta J. J. Irani
D. N. Ghosh Bimal Jalan
Keki M. Mistry S. A. Dave D. M. Sukthankar
Sanjiv V. Pilgaonkar ���������������
Partner �����������������������
Renu Sud Karnad V. Srinivasa Rangan Girish V. Koliyote
������, May 6, 2014 Managing Director ������������������ �����������������
Notes Previous Year
� in Crore � in Crore
INCOME
����������������������� 23 23,894.03 20,796.95
���������������������������� 24 248.98 315.55
������������ 25 54.66 35.12
Total Revenue 24,197.67 21,147.62
EXPENSES
Finance Cost 26 16,029.37 13,890.89
�������������� 27 279.18 246.19
���������������������� 28 86.98 75.68
�������������� 29 230.03 193.43
������������������������������ 11 & 12 31.87 23.59
Provision for Contingencies 100.00 145.00
Total Expenses 16,757.43 14,574.78
PROFIT BEFORE TAX 7,440.24 6,572.84
�����������
������������� 1,973.00 1,727.68
�������������� 14 27.00 (3.18)
PROFIT FOR THE YEAR 3 5,440.24 4,848.34
EARNINGS PER SHARE��������������� 2) 31
- Basic 34.89 31.84
- Diluted 34.62 31.45
�������������������������������������������������������������
不幸的是,PDFTextStreamEngine.showGlyph 方法使用了一些私有类成员。因此,不能简单地在自己的PDFTextStripper 类中使用带有上述更改的原始方法代码覆盖它。要么必须在自己的类中复制 PDFTextStreamEngine 的几乎所有功能,要么必须求助于 Java 反射,或者必须自己修补 PDFBox 类。
这种架构并不完美。
第二个文件“Bal_532935_0314.pdf”
第二个文件的情况是由上面引用的同一段 PDFBox 代码引起的。不过这一次,字体很简单,执行的是另一个代码块:
if (font instanceof PDSimpleFont)
{
char c = (char) code;
unicode = new String(new char[] { c });
}
这里发生的事情纯属猜测:如果没有将字形代码映射到 Unicode 的信息,我们假设映射是 Latin-1,它可以简单地嵌入到 char 中。正如在 OP 的第二个文件中可见的那样,这个假设并不总是成立。
如果您不希望 PDFBox 在此处做出此类假设,请将上面的 if 块替换为
if (font instanceof PDSimpleFont)
{
// Use the Unicode replacement character to indicate an unknown character
unicode = "\uFFFD";
}
这会导致
Aries Agro Care Private Limited
1118th Annual Report 2013-14
Balance Sheet as at 31st March, 2014
Particulars Note
No.
As at
31 March, 2014
Rupees
As at
31 March, 2013
Rupees
I. EQUITY AND LIABILITIES
(1) Shareholder's Funds
(a) ������������� 3 100,000 100,000
(b) Reserves and Surplus 4 (2,673,971) ������������
(2,573,971) ������������
(2) Current Liabilities
(a) Short Term Borrowings 5 5,805,535 �����������
(b) Trade Payables 6 159,400 ���������
(c) ������������������������� 7 2,500 22,743
5,967,435 5,934,756
TOTAL 3,393,464 �����������
II. ASSETS
(1) Non-Current Assets
(a) �������������������� � - -
- -
(2) Current Assets
(a) ����������������������� 9 39,605 �������
(b) ����������������������������� 10 3,353,859 ����������
3,393,464 ����������
TOTAL 3,393,464 ����������
��������������������������������
The Notes to Accounts 1 to 23 form part of these Financial Statements
As per our report of even date For and on behalf of the Board
For Kirti D. Shah & Associates
���������������������
�����������������������������
Dr. Jimmy Mirchandani
Director
Kirti D. Shah
Proprietor
Membership No 32371
Dr. Rahul Mirchandani
Director
Place : Mumbai.
Date :- 26th May, 2014.