LibPDF: Add (automated!) test for info dict encoding

Manually added an info dict with the three text string encoding
methods to encoding.pdf.

(Preview.app apparently can't handle UTF-8 in info dicts!)
This commit is contained in:
Nico Weber 2023-11-21 20:09:51 -05:00 committed by Andrew Kaster
parent 65b895595a
commit d345c5b793
2 changed files with 24 additions and 4 deletions

View file

@ -44,6 +44,21 @@ TEST_CASE(empty_file_issue_10702)
EXPECT(document.is_error());
}
TEST_CASE(encodig)
{
auto file = MUST(Core::MappedFile::map("encoding.pdf"sv));
auto document = MUST(PDF::Document::create(file->bytes()));
MUST(document->initialize());
EXPECT_EQ(document->get_page_count(), 1U);
auto info_dict = MUST(document->info_dict()).value();
EXPECT_EQ(MUST(info_dict.author()).value(), "Nico Weber");
EXPECT_EQ(MUST(info_dict.producer()).value(), (char const*)u8"Manüally Created");
// FIXME: Make this pass.
// EXPECT_EQ(MUST(info_dict.title()).value(), (char const*)u8"Êñ©•ding test");
}
TEST_CASE(truncated_pdf_header_issue_10717)
{
AK::DeprecatedString string { "%PDF-2.11%" };

View file

@ -32,17 +32,22 @@ endobj
<</Type/Font/Subtype/Type1/Name/F1/BaseFont/Helvetica/Encoding/MacRomanEncoding>>
endobj
6 0 obj
<</Author<FEFF004E00690063006F002000570065006200650072>/Producer(\357\273\277Man\303\274ally Created)/Title(\312\361\251\200ding test)>>
endobj
xref
0 6
0000000000 65536 f
0 7
0000000000 00001 f
0000000016 00000 n
0000000062 00000 n
0000000114 00000 n
0000000227 00000 n
0000000448 00000 n
0000000546 00000 n
trailer
<</Size 6/Root 1 0 R>>
<</Size 7/Info 6 0 R/Root 1 0 R>>
startxref
546
699
%%EOF