2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-06-01 01:40:51 +00:00

Remove warning that gives false positives in some normal cases

This commit is contained in:
Jay Berkenbilt 2021-02-23 08:26:05 -05:00
parent 039eb4a253
commit 9e00be7ffa
4 changed files with 13 additions and 27 deletions

View File

@ -785,10 +785,12 @@ QPDFPageObjectHelper::removeUnreferencedResourcesHelper(
if ((! local_unresolved.empty()) && resources.isDictionary())
{
// Don't issue a warning for this case. There are some cases
// of names that aren't XObject references, for example,
// /Artifact in tagged PDF. Until we are certain that we know
// the meaning of every name in a content stream, we don't
// want to give warnings because they will be false positives.
QTC::TC("qpdf", "QPDFPageObjectHelper unresolved names");
ph.oh.warnIfPossible(
"Unresolved names found while scanning content stream; "
"not attempting to remove unreferenced objects from this object");
return false;
}

View File

@ -2018,7 +2018,7 @@ my @sp_cases = (
[1, 'broken data', '--pages broken-lzw.pdf --', 'split-out.pdf',
{$td->FILE => "broken-lzw.out", $td->EXIT_STATUS => 3}],
);
$n_tests += 43;
$n_tests += 42;
$n_compare_pdfs += 2;
for (@sp_cases)
{
@ -2178,38 +2178,27 @@ foreach my $i (qw(1 2))
{$td->FILE => "shared-form-xobject-split-$i.pdf"});
}
my @fo_resources = (['form-xobjects-no-resources', 0],
['form-xobjects-some-resources1', 3],
['form-xobjects-some-resources2', 3]);
my @fo_resources = (['form-xobjects-no-resources', 1],
['form-xobjects-some-resources1', 0],
['form-xobjects-some-resources2', 0]);
foreach my $d (@fo_resources)
{
my ($f, $status) = @$d;
my $expout = ($status == 0 ?
{$td->STRING => ""} :
{$td->FILE => "$f.out"});
$expout->{$td->EXIT_STATUS} = $status;
my ($f, $compare) = @$d;
$td->runtest("split $f",
{$td->COMMAND =>
"qpdf --empty --static-id --pages $f.pdf 1 --" .
" --remove-unreferenced-resources=yes a.pdf"},
$expout, $td->NORMALIZE_NEWLINES);
{$td->STRING => "", $td->EXIT_STATUS => 0},
$td->NORMALIZE_NEWLINES);
$td->runtest("check output ($f)",
{$td->FILE => "a.pdf"},
{$td->FILE => "$f-out.pdf"});
if ($status == 0)
if ($compare)
{
compare_pdfs("$f.pdf", "a.pdf");
}
}
$td->runtest("no warn with pages warnings",
{$td->COMMAND =>
"qpdf --no-warn --empty --static-id".
" --pages form-xobjects-some-resources1.pdf 1 --" .
" --remove-unreferenced-resources=yes a.pdf"},
{$td->STRING => "", $td->EXIT_STATUS => 3},
$td->NORMALIZE_NEWLINES);
show_ntests();
# ----------
$td->notify("--- Keep Files Open ---");

View File

@ -1,2 +0,0 @@
WARNING: form-xobjects-some-resources1.pdf, stream object 8 0: Unresolved names found while scanning content stream; not attempting to remove unreferenced objects from this object
qpdf: operation succeeded with warnings; resulting file may have some problems

View File

@ -1,3 +0,0 @@
WARNING: form-xobjects-some-resources2.pdf, stream object 6 0: Unresolved names found while scanning content stream; not attempting to remove unreferenced objects from this object
WARNING: form-xobjects-some-resources2.pdf, stream object 8 0: Unresolved names found while scanning content stream; not attempting to remove unreferenced objects from this object
qpdf: operation succeeded with warnings; resulting file may have some problems