如何读取Identity-H编码以创建带有替换的第一个pdf文本的新pdf的目的?

我尝试在使用时从具有Identity-H编码的pdf提取文本

String content = PdfTextExtractor.getTextFromPage(reader,1);
System.out.println(content);

内容以文本形式打印,但我需要的是:

byte[] pageContentInput = ContentByteUtils.getcontentBytesForPage(reader,1);
String content2 = new String(pageContentInput);

以这种格式打印

1 0 0 1 48.351 696.9 Tm
/F0 90.0 Tf

<000100020003000400050001000200030004> Tj

ET
BT
0.8666667342185974 0.8666667342185974 0.8666667342185974 rg
1 0 0 1 48.351 606.9 Tm
/F0 90.0 Tf

<000100020003000400050001000200030004> Tj
ET

我的最终目标是翻译<...> Tj中的内容,然后使用

创建一个新的pdf。
stream.setData(content2.getBytes()); 

我能够使用具有ANSI编码的pdf做到这一点,因为<...> Tj中的内容为文本格式。

我检查了toUnicode映射,看起来我的pdf文件具有该功能。

>>10 0 obj
/Type /Font
/Subtype /Type0
/BaseFont /QOXJXM+Times#20New#20Roman
/Encoding /Identity-H
/DescendantFonts [ 11 0 R ]
/ToUnicode 14 0 R



>>16 0 obj
<<
/Type /Font
/Subtype /Type0
/BaseFont /XUKQUF+Times#20New#20Roman#20Bold
/Encoding /Identity-H
/DescendantFonts [ 17 0 R ]
/ToUnicode 20 0 R
>>

>>21 0 obj
<<
/Type /Font
/Subtype /Type0
/BaseFont /YTJNUV+Times#20New#20Roman#20Italic
/Encoding /Identity-H
/DescendantFonts [ 22 0 R ]
/ToUnicode 25 0 R
>>
>>
/Type /Font
/Subtype /Type0
/BaseFont /LLKUND+Times#20New#20Roman#20Bold#20Italic
/Encoding /Identity-H
/DescendantFonts [ 27 0 R ]
/ToUnicode 30 0 R

这里是/ ToUnicode 14 0 R之一

/CIDInit /ProcSet findresource
begin
12 dict
begin
begincmap
/CIDSystemInfo <</Registry (Oracle) /Ordering (ucs) /Supplement 0 >> def
/CMapName /Oracle-Identity-ucs def
1 begincodespacerange
<0000> <ffffffffffffffff> endcodespacerange
72 beginbfchar
<0000> <003f> <0001> <0043> <0002> <004f> <0003> <0050> <0004> <0059> <0005> <0020> <0006> <0034> <0007> <0032> <0008> <0039> <0009> <0033> <000a> <0031> <000b> <0044> <000c> <0065> <000d> <007a> <000e> <0030> <000f> <0038> <0010> <0054> <0011> <0035> <0012> <0037> <0013> <0046> <0014> <0052> <0015> <0036> <0016> <0041> <0017> <0056> <0018> <004e> <0019> <002d> <001a> <0047> <001b> <004c> <001c> <0055> <001d> <0057> <001e> <0069> <001f> <0070> <0020> <0072> <0021> <006f> <0022> <006d> <0023> <0074> <0024> <0064> <0025> <0061> <0026> <0073> <0027> <0053> <0028> <006c> <0029> <0066> <002a> <0063> <002b> <002f> <002c> <0076> <002d> <006e> <002e> <0075> <002f> <0027> <0030> <0062> <0031> <00ffffffe9> <0032> <002c> <0033> <0048> <0034> <0067> <0035> <0068> <0036> <0042> <0037> <0045> <0038> <0051> <0039> <004b> <003a> <003a> <003b> <002b> <003c> <0078> <003d> <004d> <003e> <002e> <003f> <0025> <0040> <0028> <0041> <0029> <0042> <0049> <0043> <0077> <0044> <0026> <0045> <00ffffffea> <0046> <003d> <0047> <0079> endbfchar
endcmap
CMapName
currentdict
/CMap defineresource
pop
end
end

我不知道我应该如何使用此Unicode映射,或者它是否有用。如果/ ToUnicode可用,则<....> Tj部分不应该已经使用Unicode

我是iText的新手。只是想知道我打算用itext做些什么?

sgflh 回答:如何读取Identity-H编码以创建带有替换的第一个pdf文本的新pdf的目的?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3144543.html

大家都在问