mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-03 07:12:28 +00:00
Fix overlay/underlay on page with no resources (fixes #527)
This commit is contained in:
parent
a3a3203f41
commit
73752683c9
@ -1,3 +1,8 @@
|
|||||||
|
2021-11-03 Jay Berkenbilt <ejb@ql.org>
|
||||||
|
|
||||||
|
* Bug fix: make overlay/underlay work on a page with no resource
|
||||||
|
dictionary. Fixes #527.
|
||||||
|
|
||||||
2021-11-02 Jay Berkenbilt <ejb@ql.org>
|
2021-11-02 Jay Berkenbilt <ejb@ql.org>
|
||||||
|
|
||||||
* Add QPDF::findPage to the public API. This is primarily to help
|
* Add QPDF::findPage to the public API. This is primarily to help
|
||||||
|
@ -5080,6 +5080,12 @@ print "\n";
|
|||||||
that could occur when given bogus input.
|
that could occur when given bogus input.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Properly handle overlay/underlay on completely empty pages
|
||||||
|
(with no resource dictionary).
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
|
12
qpdf/qpdf.cc
12
qpdf/qpdf.cc
@ -5226,6 +5226,12 @@ static void do_under_overlay_for_page(
|
|||||||
std::string content;
|
std::string content;
|
||||||
int min_suffix = 1;
|
int min_suffix = 1;
|
||||||
QPDFObjectHandle resources = dest_page.getAttribute("/Resources", true);
|
QPDFObjectHandle resources = dest_page.getAttribute("/Resources", true);
|
||||||
|
if (! resources.isDictionary())
|
||||||
|
{
|
||||||
|
QTC::TC("qpdf", "qpdf overlay page with no resources");
|
||||||
|
resources = QPDFObjectHandle::newDictionary();
|
||||||
|
dest_page.getObjectHandle().replaceKey("/Resources", resources);
|
||||||
|
}
|
||||||
for (std::vector<int>::iterator iter = pagenos[pageno].begin();
|
for (std::vector<int>::iterator iter = pagenos[pageno].begin();
|
||||||
iter != pagenos[pageno].end(); ++iter)
|
iter != pagenos[pageno].end(); ++iter)
|
||||||
{
|
{
|
||||||
@ -5257,7 +5263,11 @@ static void do_under_overlay_for_page(
|
|||||||
{
|
{
|
||||||
resources.mergeResources(
|
resources.mergeResources(
|
||||||
QPDFObjectHandle::parse("<< /XObject << >> >>"));
|
QPDFObjectHandle::parse("<< /XObject << >> >>"));
|
||||||
resources.getKey("/XObject").replaceKey(name, fo[from_pageno]);
|
auto xobject = resources.getKey("/XObject");
|
||||||
|
if (xobject.isDictionary())
|
||||||
|
{
|
||||||
|
xobject.replaceKey(name, fo[from_pageno]);
|
||||||
|
}
|
||||||
++min_suffix;
|
++min_suffix;
|
||||||
content += new_content;
|
content += new_content;
|
||||||
}
|
}
|
||||||
|
@ -596,3 +596,4 @@ QPDFWriter preserve object streams 1
|
|||||||
QPDFWriter exclude from object stream 0
|
QPDFWriter exclude from object stream 0
|
||||||
check unclosed --pages 1
|
check unclosed --pages 1
|
||||||
QPDF_pages findPage not found 0
|
QPDF_pages findPage not found 0
|
||||||
|
qpdf overlay page with no resources 0
|
||||||
|
@ -477,7 +477,7 @@ $td->runtest("compare files",
|
|||||||
show_ntests();
|
show_ntests();
|
||||||
# ----------
|
# ----------
|
||||||
$td->notify("--- Form XObject, underlay, overlay ---");
|
$td->notify("--- Form XObject, underlay, overlay ---");
|
||||||
$n_tests += 20;
|
$n_tests += 22;
|
||||||
|
|
||||||
$td->runtest("form xobject creation",
|
$td->runtest("form xobject creation",
|
||||||
{$td->COMMAND => "test_driver 55 fxo-red.pdf"},
|
{$td->COMMAND => "test_driver 55 fxo-red.pdf"},
|
||||||
@ -550,6 +550,15 @@ $td->runtest("page operations on form xobject",
|
|||||||
{$td->FILE => "page-ops-on-form-xobject.out",
|
{$td->FILE => "page-ops-on-form-xobject.out",
|
||||||
$td->EXIT_STATUS => 0},
|
$td->EXIT_STATUS => 0},
|
||||||
$td->NORMALIZE_NEWLINES);
|
$td->NORMALIZE_NEWLINES);
|
||||||
|
$td->runtest("overlay on page with no resources",
|
||||||
|
{$td->COMMAND =>
|
||||||
|
"qpdf --deterministic-id page-with-no-resources.pdf" .
|
||||||
|
" --overlay minimal.pdf -- a.pdf"},
|
||||||
|
{$td->STRING => "", $td->EXIT_STATUS => 0},
|
||||||
|
$td->NORMALIZE_NEWLINES);
|
||||||
|
$td->runtest("check overlay with no resources output",
|
||||||
|
{$td->FILE => "a.pdf"},
|
||||||
|
{$td->FILE => "overlay-no-resources.pdf"});
|
||||||
|
|
||||||
show_ntests();
|
show_ntests();
|
||||||
# ----------
|
# ----------
|
||||||
|
BIN
qpdf/qtest/qpdf/overlay-no-resources.pdf
Normal file
BIN
qpdf/qtest/qpdf/overlay-no-resources.pdf
Normal file
Binary file not shown.
21
qpdf/qtest/qpdf/page-with-no-resources.pdf
Normal file
21
qpdf/qtest/qpdf/page-with-no-resources.pdf
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
%PDF-1.3
|
||||||
|
%¿÷¢þ
|
||||||
|
1 0 obj
|
||||||
|
<< /Pages 2 0 R /Type /Catalog >>
|
||||||
|
endobj
|
||||||
|
2 0 obj
|
||||||
|
<< /Count 1 /Kids [ 3 0 R ] /Type /Pages >>
|
||||||
|
endobj
|
||||||
|
3 0 obj
|
||||||
|
<< /MediaBox [ 0.0 0.0 612 792 ] /Parent 2 0 R /Type /Page >>
|
||||||
|
endobj
|
||||||
|
xref
|
||||||
|
0 4
|
||||||
|
0000000000 65535 f
|
||||||
|
0000000015 00000 n
|
||||||
|
0000000064 00000 n
|
||||||
|
0000000123 00000 n
|
||||||
|
trailer << /Root 1 0 R /Size 4 /ID [<f47f51552a4f2e020e12a656e72ed64c><0c18b42478a35cdccff23c62f4c7b946>] >>
|
||||||
|
startxref
|
||||||
|
200
|
||||||
|
%%EOF
|
Loading…
Reference in New Issue
Block a user