Skip to content

Commit

Permalink
Adapt to pre-21.12 Poppler
Browse files Browse the repository at this point in the history
  • Loading branch information
attah committed May 6, 2023
1 parent 199b288 commit 4490093
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pdf2printable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,23 @@ int pdf_to_printable(std::string inFile, WriteFun writeFun, const PrintParameter
Pointer<PopplerDocument> doc(nullptr, g_object_unref);
GError* error = nullptr;

#if POPPLER_CHECK_VERSION(21, 12, 0)
if(inFile == "-")
{
doc = poppler_document_new_from_fd(STDIN_FILENO, nullptr, &error);
}
#else
Bytestream inBts;
if(inFile == "-")
{
inBts = Bytestream(std::cin);
// Safe until 21.12 at least, ignore deprecation.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
doc = poppler_document_new_from_data((char*)inBts.raw(), inBts.size(), nullptr, &error);
#pragma GCC diagnostic pop
}
#endif
else
{
if (!g_path_is_absolute(inFile.c_str()))
Expand Down

0 comments on commit 4490093

Please sign in to comment.