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

QPDFPageObjectHelper: getPageImages -> getImages

This commit is contained in:
Jay Berkenbilt 2020-12-31 13:23:49 -05:00
parent e7a8554563
commit 63ea46193d
9 changed files with 24 additions and 13 deletions

View File

@ -1,5 +1,10 @@
2020-12-31 Jay Berkenbilt <ejb@ql.org>
* Rename QPDFPageObjectHelper::getPageImages to
QPDFPageObjectHelper::getImages and make it support form XObjects
as well as pages. The old name will be preserved for
compatibility.
* Add QPDFObjectHandle::isFormXObject to test whether an object is
a form XObject.

View File

@ -268,7 +268,7 @@ static void check(char const* filename,
page_iter != pages.end(); ++page_iter)
{
QPDFPageObjectHelper& page(*page_iter);
std::map<std::string, QPDFObjectHandle> images = page.getPageImages();
std::map<std::string, QPDFObjectHandle> images = page.getImages();
if (images.size() != 1)
{
throw std::logic_error("incorrect number of images on page");

View File

@ -159,7 +159,7 @@ int main(int argc, char* argv[])
QPDFPageObjectHelper& page(*iter);
// Get all images on the page.
std::map<std::string, QPDFObjectHandle> images =
page.getPageImages();
page.getImages();
for (auto& iter2: images)
{
QPDFObjectHandle& image = iter2.second;

View File

@ -143,7 +143,7 @@ FuzzHelper::testPages()
{
page.coalesceContentStreams();
page.parsePageContents(&discard_contents);
page.getPageImages();
page.getImages();
pldh.getLabelForPage(pageno);
QPDFObjectHandle page_obj(page.getObjectHandle());
page_obj.getJSON(true).unparse();

View File

@ -78,6 +78,10 @@ class QPDFPageObjectHelper: public QPDFObjectHelper
// name to the image object, which is always a stream. Works with
// form XObjects as well as pages.
QPDF_DLL
std::map<std::string, QPDFObjectHandle> getImages();
// Old name -- calls getImages()
QPDF_DLL
std::map<std::string, QPDFObjectHandle> getPageImages();
// Convert each inline image to an external (normal) image if the

View File

@ -1320,7 +1320,7 @@ QPDFObjectHandle::getGeneration() const
std::map<std::string, QPDFObjectHandle>
QPDFObjectHandle::getPageImages()
{
return QPDFPageObjectHelper(*this).getPageImages();
return QPDFPageObjectHelper(*this).getImages();
}
std::vector<QPDFObjectHandle>

View File

@ -388,6 +388,12 @@ QPDFPageObjectHelper::getMediaBox(bool copy_if_shared)
std::map<std::string, QPDFObjectHandle>
QPDFPageObjectHelper::getPageImages()
{
return getImages();
}
std::map<std::string, QPDFObjectHandle>
QPDFPageObjectHelper::getImages()
{
std::map<std::string, QPDFObjectHandle> result;
QPDFObjectHandle resources = getAttribute("/Resources", false);

View File

@ -3639,8 +3639,7 @@ static void do_show_pages(QPDF& pdf, Options& o)
<< page.getGeneration() << " R" << std::endl;
if (o.show_page_images)
{
std::map<std::string, QPDFObjectHandle> images =
ph.getPageImages();
std::map<std::string, QPDFObjectHandle> images = ph.getImages();
if (! images.empty())
{
std::cout << " images:" << std::endl;
@ -3765,8 +3764,7 @@ static void do_json_pages(QPDF& pdf, Options& o, JSON& j)
j_page.addDictionaryMember("object", page.getJSON());
JSON j_images = j_page.addDictionaryMember(
"images", JSON::makeArray());
std::map<std::string, QPDFObjectHandle> images =
ph.getPageImages();
std::map<std::string, QPDFObjectHandle> images = ph.getImages();
for (auto const& iter2: images)
{
JSON j_image = j_images.addArrayElement(JSON::makeDictionary());
@ -4785,8 +4783,7 @@ static void handle_transformations(QPDF& pdf, Options& o)
++pageno;
QPDFPageObjectHelper& ph(*iter);
QPDFObjectHandle page = ph.getObjectHandle();
std::map<std::string, QPDFObjectHandle> images =
ph.getPageImages();
std::map<std::string, QPDFObjectHandle> images = ph.getImages();
for (auto& iter2: images)
{
std::string name = iter2.first;

View File

@ -516,8 +516,7 @@ void runtest(int n, char const* filename1, char const* arg2)
std::cout << "page " << pageno << ":" << std::endl;
std::cout << " images:" << std::endl;
std::map<std::string, QPDFObjectHandle> images =
page.getPageImages();
std::map<std::string, QPDFObjectHandle> images = page.getImages();
for (auto const& iter2: images)
{
std::string const& name = iter2.first;
@ -1488,7 +1487,7 @@ void runtest(int n, char const* filename1, char const* arg2)
{
std::cout << "page " << ++pageno << std::endl;
std::map<std::string, QPDFObjectHandle> images =
(*p_iter).getPageImages();
(*p_iter).getImages();
for (std::map<std::string, QPDFObjectHandle>::iterator i_iter =
images.begin(); i_iter != images.end(); ++i_iter)
{