2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-22 10:58:58 +00:00

Explicitly override inherited rotate in flattenRotations

This commit is contained in:
Jay Berkenbilt 2021-02-21 07:54:09 -05:00
parent e899926e0d
commit 7540d2082a
5 changed files with 114 additions and 1 deletions

View File

@ -1200,4 +1200,10 @@ QPDFPageObjectHelper::flattenRotation()
this->oh.addPageContents(
QPDFObjectHandle::newStream(qpdf, "\nQ\n"), false);
this->oh.removeKey("/Rotate");
QPDFObjectHandle rotate_obj = getAttribute("/Rotate", false);
if (! rotate_obj.isNull())
{
QTC::TC("qpdf", "QPDFPageObjectHelper flatten inherit rotate");
this->oh.replaceKey("/Rotate", QPDFObjectHandle::newInteger(0));
}
}

View File

@ -571,3 +571,4 @@ qpdf password stdin 0
qpdf password file 0
QPDFFileSpecObjectHelper empty compat_name 0
QPDFFileSpecObjectHelper non-empty compat_name 0
QPDFPageObjectHelper flatten inherit rotate 0

View File

@ -2248,7 +2248,7 @@ $td->runtest("explicit keep files open = n",
show_ntests();
# ----------
$td->notify("--- Rotate Pages ---");
$n_tests += 6;
$n_tests += 8;
# Do absolute, positive, and negative on ranges that include
# inherited and non-inherited.
# Pages 11-15 inherit /Rotate 90
@ -2281,6 +2281,15 @@ $td->runtest("check output",
{$td->FILE => "a.pdf"},
{$td->FILE => "minimal-rotated.pdf"});
$td->runtest("flatten with inherited rotate",
{$td->COMMAND =>
"qpdf --static-id --flatten-rotation" .
" inherited-rotate.pdf a.pdf"},
{$td->STRING => "", $td->EXIT_STATUS => 0});
$td->runtest("check output",
{$td->FILE => "a.pdf"},
{$td->FILE => "inherited-flattened.pdf"});
show_ntests();
# ----------
$td->notify("--- Flatten Form/Annotations ---");

Binary file not shown.

View File

@ -0,0 +1,97 @@
%PDF-1.3
%¿÷¢þ
%QDF-1.0
1 0 obj
<<
/Pages 2 0 R
/Type /Catalog
>>
endobj
2 0 obj
<<
/Count 1
/Kids [
3 0 R
]
/Rotate 270
/Type /Pages
>>
endobj
%% Page 1
3 0 obj
<<
/Contents 4 0 R
/MediaBox [
0
0
612
792
]
/Parent 2 0 R
/Resources <<
/Font <<
/F1 6 0 R
>>
/ProcSet 7 0 R
>>
/Rotate 90
/Type /Page
>>
endobj
%% Contents for page 1
4 0 obj
<<
/Length 5 0 R
>>
stream
BT
/F1 24 Tf
72 720 Td
(Potato) Tj
ET
endstream
endobj
5 0 obj
44
endobj
6 0 obj
<<
/BaseFont /Helvetica
/Encoding /WinAnsiEncoding
/Name /F1
/Subtype /Type1
/Type /Font
>>
endobj
7 0 obj
[
/PDF
/Text
]
endobj
xref
0 8
0000000000 65535 f
0000000025 00000 n
0000000079 00000 n
0000000175 00000 n
0000000403 00000 n
0000000502 00000 n
0000000521 00000 n
0000000639 00000 n
trailer <<
/Root 1 0 R
/Size 8
/ID [<ab4c755c7750297943d9d0473ed27c28><e29efdb11fd4d5afe3f4b707ba817a50>]
>>
startxref
674
%%EOF