Skip to content

Commit dc3a642

Browse files
committed
avoiding dual hex encoding for TJ command
1 parent 217369c commit dc3a642

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

PDFWriter/AbstractContentContext.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1152,8 +1152,6 @@ EStatusCode AbstractContentContext::WriteTextCommandWithDirectGlyphSelection(con
11521152
stringStream.Write((const Byte*)formattingBuffer, 1);
11531153
formattingBuffer[0] = (*it) & 0x00ff;
11541154
stringStream.Write((const Byte*)formattingBuffer, 1);
1155-
//SAFE_SPRINTF_2(formattingBuffer,5,"%02x%02x",((*it)>>8) & 0x00ff,(*it) & 0x00ff);
1156-
//stringStream.Write((const Byte*)formattingBuffer,4);
11571155
}
11581156
inTextCommand->WriteHexStringCommand(stringStream.ToString());
11591157
}
@@ -1246,8 +1244,10 @@ EStatusCode AbstractContentContext::TJ(const GlyphUnicodeMappingListOrDoubleList
12461244
{
12471245
for(itEncoded = itEncodedList->begin();itEncoded!= itEncodedList->end();++itEncoded)
12481246
{
1249-
SAFE_SPRINTF_2(formattingBuffer,5,"%02x%02x",((*itEncoded)>>8) & 0x00ff,(*itEncoded) & 0x00ff);
1250-
stringStream.Write((const Byte*)formattingBuffer,4);
1247+
formattingBuffer[0] = ((*itEncoded) >> 8) & 0x00ff;
1248+
stringStream.Write((const Byte*)formattingBuffer, 1);
1249+
formattingBuffer[0] = (*itEncoded) & 0x00ff;
1250+
stringStream.Write((const Byte*)formattingBuffer, 1);
12511251
}
12521252
stringOrDoubleList.push_back(StringOrDouble(stringStream.ToString()));
12531253
stringStream.Reset();

PDFWriterTesting/UnicodeTextUsage.cpp

+13-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,19 @@ int UnicodeTextUsage(int argc, char* argv[])
7777

7878
EStatusCode encodingStatus = contentContext->Tj("hello \xD7\x92");
7979
if (encodingStatus != PDFHummus::eSuccess)
80-
cout << "Could not find some of the glyphs for this font";
80+
cout << "Could not find some of the glyphs for this font Tj";
81+
82+
contentContext->Tm(30, 0, 0, 30, 78.4252, 562.8997);
83+
StringOrDoubleList textAndPos;
84+
85+
textAndPos.push_back(StringOrDouble("hell"));
86+
textAndPos.push_back(-50*30);
87+
textAndPos.push_back(StringOrDouble("o \xD7\x92"));
88+
89+
encodingStatus = contentContext->TJ(textAndPos);
90+
if (encodingStatus != PDFHummus::eSuccess)
91+
cout << "Could not find some of the glyphs for this font using TJ";
92+
8193

8294
// continue even if failed...want to see how it looks like
8395
contentContext->ET();

0 commit comments

Comments
 (0)