Fix PoDoFo 1.0.x API compatibility. PoDoFo 1.0.x has significant API changes from earlier versions: - PdfMemDocument constructor changed to Load() method - GetPage() -> GetPages().GetPageAt() - PdfRect -> Rect with direct member access - ePdfDataType_* -> PdfDataType::* - PdfStream -> PdfObjectStream with CopyTo() - PdfVecObjects -> PdfIndirectObjectList - GetIndirectKey() -> FindKey() on dictionary - Various pointer-to-reference changes --- scribus/pdflib_core.h.orig 2019-03-05 22:44:41.000000000 +0000 +++ scribus/pdflib_core.h 2026-04-23 11:07:36.778455651 +0000 @@ -168,9 +168,14 @@ bool PDF_Image(PageItem* c, const QString& fn, double sx, double sy, double x, double y, bool fromAN = false, const QString& Profil = "", bool Embedded = false, eRenderIntent Intent = Intent_Relative_Colorimetric, QString* output = NULL); bool PDF_EmbeddedPDF(PageItem* c, const QString& fn, double sx, double sy, double x, double y, bool fromAN, const QString& Profil, bool Embedded, int Intent, ShIm& imgInfo, QString* output = NULL); #if HAVE_PODOFO +#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(1, 0, 0)) + void copyPoDoFoObject(const PoDoFo::PdfObject& obj, uint scObjID, QMap& importedObjects, PoDoFo::PdfIndirectObjectList& allObjects); + void copyPoDoFoDirect(const PoDoFo::PdfObject& obj, QList& referencedObjects, QMap& importedObjects); +#else void copyPoDoFoObject(const PoDoFo::PdfObject* obj, uint scObjID, QMap& importedObjects); void copyPoDoFoDirect(const PoDoFo::PdfVariant* obj, QList& referencedObjects, QMap& importedObjects); #endif +#endif int bytesWritten() { return Spool.pos(); } --- scribus/pdflib_core.cpp.orig 2019-03-05 22:44:41.000000000 +0000 +++ scribus/pdflib_core.cpp 2026-04-23 11:31:33.647914439 +0000 @@ -6595,6 +6595,298 @@ #ifdef HAVE_PODOFO // Try to catch potential pdf parsing exceptions early // so we can use the raster fallback if needed +#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(1, 0, 0)) + // PoDoFo 1.0.x API + QScopedPointer doc; + try + { + doc.reset(new PoDoFo::PdfMemDocument()); + doc->Load(fn.toLocal8Bit().data()); + } + catch(PoDoFo::PdfError& e) + { + qDebug() << "PoDoFo error, falling back to raster!"; + qDebug() << e.what(); + return false; + } + + try + { + int pageIndex = qMin(qMax(1, c->pixm.imgInfo.actualPageNumber), c->pixm.imgInfo.numberOfPages) - 1; + PoDoFo::PdfPage& page = doc->GetPages().GetPageAt(pageIndex); + PoDoFo::PdfObject* contents = page.GetContents() ? &page.GetContents()->GetObject() : nullptr; + const PoDoFo::PdfObject* resources = &page.GetResources().GetObject(); + + // Get resources from parent if resources dict is empty + if (!resources || resources->GetDictionary().GetSize() == 0) + { + resources = nullptr; + const PoDoFo::PdfObject* par = &page.GetObject(); + while (par && !resources) + { + const PoDoFo::PdfDictionary& dict = par->GetDictionary(); + const PoDoFo::PdfObject* resObj = dict.FindKey("Resources"); + if (resObj) + { + if (resObj->IsReference()) + resources = doc->GetObjects().GetObject(resObj->GetReference()); + else + resources = resObj; + break; + } + const PoDoFo::PdfObject* parentObj = dict.FindKey("Parent"); + if (parentObj && parentObj->IsReference()) + par = doc->GetObjects().GetObject(parentObj->GetReference()); + else + par = nullptr; + } + } + + if (contents && contents->GetDataType() == PoDoFo::PdfDataType::Dictionary) + { + const PoDoFo::PdfObjectStream* stream = contents->GetStream(); + QMap importedObjects; + QList referencedObjects; + uint xObj = newObject(); + uint xResources = newObject(); + uint xParents = 0; + importedObjects[page.GetObject().GetIndirectReference()] = xObj; + StartObj(xObj); + PutDoc("<<\n/Type /XObject\n/Subtype /Form\n/FormType 1"); + PoDoFo::Rect pageSize = page.GetRect(); + double rotation = 0; + page.TryGetRotationRaw(rotation); + int rotInt = (int)rotation; + double imgWidth = (rotInt == 90 || rotInt == 270) ? pageSize.Height : pageSize.Width; + double imgHeight = (rotInt == 90 || rotInt == 270) ? pageSize.Width : pageSize.Height; + QMatrix pageM; + pageM.translate(pageSize.X, pageSize.Y); + pageM.rotate(rotInt); + if (rotInt == 90) + pageM.translate(0.0, -imgHeight); + else if (rotInt == 180) + pageM.translate(-imgWidth, -imgHeight); + else if (rotInt == 270) + pageM.translate(-imgWidth, 0.0); + pageM.scale(imgWidth, imgHeight); + pageM = pageM.inverted(); + PutDoc("\n/BBox [" + QString::number(pageSize.X, 'f')); + PutDoc(" " + QString::number(pageSize.Y, 'f')); + PutDoc(" " + QString::number(pageSize.X + pageSize.Width, 'f')); + PutDoc(" " + QString::number(pageSize.Y + pageSize.Height, 'f')); + PutDoc("]"); + PutDoc("\n/Matrix [" + QString::number(pageM.m11(), 'f') + " " + + QString::number(pageM.m12(), 'f') + " " + + QString::number(pageM.m21(), 'f') + " " + + QString::number(pageM.m22(), 'f') + " " + + QString::number(pageM.dx(), 'f') + " " + + QString::number(pageM.dy(), 'f') + " "); + PutDoc("]"); + PutDoc("\n/Resources " + QString::number(xResources) + " 0 R"); + const PoDoFo::PdfObject* groupObj = page.GetObject().GetDictionary().FindKey("Group"); + if (groupObj) + { + PutDoc("\n/Group "); // PDF 1.4 + copyPoDoFoDirect(*groupObj, referencedObjects, importedObjects); + } + + PoDoFo::charbuff mbuffer; + stream->CopyTo(mbuffer); + size_t mlen = mbuffer.size(); + if (mlen > 0 && mbuffer[mlen-1] == '\n') + --mlen; + PutDoc("\n/Length " + QString::number(mlen)); + const PoDoFo::PdfObject* filterObj = contents->GetDictionary().FindKey("Filter"); + if (filterObj) + { + PutDoc("\n/Filter "); + copyPoDoFoDirect(*filterObj, referencedObjects, importedObjects); + } + const PoDoFo::PdfObject* decodeObj = contents->GetDictionary().FindKey("DecodeParms"); + if (decodeObj) + { + PutDoc("\n/DecodeParms "); + copyPoDoFoDirect(*decodeObj, referencedObjects, importedObjects); + } + PutDoc("\n>>\nstream\n"); + { + QByteArray buffer = QByteArray::fromRawData(mbuffer.data(), mlen); + EncodeArrayToStream(buffer, xObj); + } + PutDoc("\nendstream\nendobj\n"); + // write resources + if (resources) + { + PoDoFo::PdfIndirectObjectList& allObjects = doc->GetObjects(); + copyPoDoFoObject(*resources, xResources, importedObjects, allObjects); + } + else + { + StartObj(xResources); + PutDoc("<< >>\nendobj\n"); + } + if (xParents) + { + // create structured parents + } + // write referenced objects + PoDoFo::PdfIndirectObjectList& allObjects = doc->GetObjects(); + for (int i=0; i < referencedObjects.size(); ++i) + { + PoDoFo::PdfObject* nextObj = allObjects.GetObject(referencedObjects[i]); + if (nextObj) + copyPoDoFoObject(*nextObj, importedObjects[nextObj->GetIndirectReference()], importedObjects, allObjects); + } + + Seite.ImgObjects[ResNam+"I"+QString::number(ResCount)] = xObj; + imgInfo.ResNum = ResCount; + ResCount++; + imgInfo.Width = qMax(1, (int) imgWidth); + imgInfo.Height = qMax(1, (int) imgHeight); + imgInfo.xa = sx * imgWidth / imgInfo.Width; + imgInfo.ya = sy * imgHeight / imgInfo.Height; + imgInfo.sxa = sx * imgWidth / imgInfo.Width; + imgInfo.sya = sy * imgHeight / imgInfo.Height; + + return true; + } + else if (contents && contents->GetDataType() == PoDoFo::PdfDataType::Array) + { + QMap importedObjects; + QList referencedObjects; + uint xObj = newObject(); + uint xResources = newObject(); + uint xParents = 0; + importedObjects[page.GetObject().GetIndirectReference()] = xObj; + StartObj(xObj); + PutDoc("<<\n/Type /XObject\n/Subtype /Form\n/FormType 1"); + PoDoFo::Rect pageSize = page.GetRect(); + double rotation = 0; + page.TryGetRotationRaw(rotation); + int rotInt = (int)rotation; + double imgWidth = (rotInt == 90 || rotInt == 270) ? pageSize.Height : pageSize.Width; + double imgHeight = (rotInt == 90 || rotInt == 270) ? pageSize.Width : pageSize.Height; + QMatrix pageM; + pageM.translate(pageSize.X, pageSize.Y); + pageM.rotate(rotInt); + if (rotInt == 90) + pageM.translate(0.0, -imgHeight); + else if (rotInt == 180) + pageM.translate(-imgWidth, -imgHeight); + else if (rotInt == 270) + pageM.translate(-imgWidth, 0.0); + pageM.scale(imgWidth, imgHeight); + pageM = pageM.inverted(); + PutDoc("\n/BBox [" + QString::number(pageSize.X, 'f')); + PutDoc(" " + QString::number(pageSize.Y, 'f')); + PutDoc(" " + QString::number(pageSize.X + pageSize.Width, 'f')); + PutDoc(" " + QString::number(pageSize.Y + pageSize.Height, 'f')); + PutDoc("]"); + PutDoc("\n/Matrix [" + QString::number(pageM.m11(), 'f') + " " + + QString::number(pageM.m12(), 'f') + " " + + QString::number(pageM.m21(), 'f') + " " + + QString::number(pageM.m22(), 'f') + " " + + QString::number(pageM.dx(), 'f') + " " + + QString::number(pageM.dy(), 'f') + " "); + PutDoc("]"); + PutDoc("\n/Resources " + QString::number(xResources) + " 0 R"); + const PoDoFo::PdfObject* groupObj = page.GetObject().GetDictionary().FindKey("Group"); + if (groupObj) + { + PutDoc("\n/Group "); // PDF 1.4 + copyPoDoFoDirect(*groupObj, referencedObjects, importedObjects); + } + + // Collect all stream content + std::string outBuffer; + const PoDoFo::PdfArray& carray = contents->GetArray(); + for(unsigned int ci = 0; ci < carray.size(); ++ci) + { + const PoDoFo::PdfObject& arrObj = carray[ci]; + if(arrObj.HasStream()) + { + PoDoFo::charbuff tempBuf; + arrObj.GetStream()->CopyTo(tempBuf); + outBuffer.append(tempBuf.data(), tempBuf.size()); + } + else if(arrObj.IsReference()) + { + PoDoFo::PdfObject* nextObj = doc->GetObjects().GetObject(arrObj.GetReference()); + while(nextObj != nullptr) + { + if(nextObj->IsReference()) + { + nextObj = doc->GetObjects().GetObject(nextObj->GetReference()); + } + else if(nextObj->HasStream()) + { + PoDoFo::charbuff tempBuf; + nextObj->GetStream()->CopyTo(tempBuf); + outBuffer.append(tempBuf.data(), tempBuf.size()); + break; + } + else + { + break; + } + } + } + } + + size_t mlen = outBuffer.size(); + PutDoc("\n/Length " + QString::number(mlen)); + PutDoc("\n>>\nstream\n"); + { + QByteArray buffer = QByteArray::fromRawData(outBuffer.data(), mlen); + EncodeArrayToStream(buffer, xObj); + } + PutDoc("\nendstream\nendobj\n"); + // write resources + if (resources) + { + PoDoFo::PdfIndirectObjectList& allObjects = doc->GetObjects(); + copyPoDoFoObject(*resources, xResources, importedObjects, allObjects); + } + else + { + StartObj(xResources); + PutDoc("<< >>\nendobj\n"); + } + if (xParents) + { + // create structured parents + } + // write referenced objects + PoDoFo::PdfIndirectObjectList& allObjects = doc->GetObjects(); + for (int i=0; i < referencedObjects.size(); ++i) + { + PoDoFo::PdfObject* nextObj = allObjects.GetObject(referencedObjects[i]); + if (nextObj) + copyPoDoFoObject(*nextObj, importedObjects[nextObj->GetIndirectReference()], importedObjects, allObjects); + } + + Seite.ImgObjects[ResNam+"I"+QString::number(ResCount)] = xObj; + imgInfo.ResNum = ResCount; + ResCount++; + imgInfo.Width = qMax(1, (int) imgWidth); + imgInfo.Height = qMax(1, (int) imgHeight); + imgInfo.xa = sx * imgWidth / imgInfo.Width; + imgInfo.ya = sy * imgHeight / imgInfo.Height; + imgInfo.sxa = sx * imgWidth / imgInfo.Width; + imgInfo.sya = sy * imgHeight / imgInfo.Height; + + return true; + } + + } + catch(PoDoFo::PdfError& e) + { + qDebug() << "PoDoFo error!"; + qDebug() << e.what(); + return false; + } +#else + // PoDoFo < 1.0.0 API #if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(0, 5, 99)) QScopedPointer doc; #else @@ -6618,7 +6910,7 @@ e.PrintErrorMsg(); return false; } - + try { PoDoFo::PdfPage* page = doc->GetPage(qMin(qMax(1, c->pixm.imgInfo.actualPageNumber), c->pixm.imgInfo.numberOfPages) - 1); @@ -6734,7 +7026,7 @@ nextObj = allObjects->GetObject(referencedObjects[i]); copyPoDoFoObject(nextObj, importedObjects[nextObj->Reference()], importedObjects); } - + Seite.ImgObjects[ResNam+"I"+QString::number(ResCount)] = xObj; imgInfo.ResNum = ResCount; ResCount++; @@ -6747,10 +7039,10 @@ // pageSize.GetHeight(). Adjust scale factor to compensate for the difference. imgInfo.sxa = sx * imgWidth / imgInfo.Width; imgInfo.sya = sy * imgHeight / imgInfo.Height; - + return true; } - else if (contents && contents->GetDataType() == PoDoFo::ePdfDataType_Array)//Page contents might be an array + else if (contents && contents->GetDataType() == PoDoFo::ePdfDataType_Array)//Page contents might be an array { QMap importedObjects; QList referencedObjects; @@ -6795,12 +7087,12 @@ PutDoc("\n/Group "); // PDF 1.4 copyPoDoFoDirect(nextObj, referencedObjects, importedObjects); } - + char * mbuffer = NULL; long mlen = 0; // copied from podofoimpose PoDoFo::PdfMemoryOutputStream outMemStream ( 1 ); -// PoDoFo::PdfFilteredEncodeStream outMemStream (outMemStreamRaw, ePdfFilter_FlateDecode, false); +// PoDoFo::PdfFilteredEncodeStream outMemStream (outMemStreamRaw, ePdfFilter_FlateDecode, false); PoDoFo::PdfArray carray(page->GetContents()->GetArray()); for(unsigned int ci = 0; ci < carray.size(); ++ci) { @@ -6810,12 +7102,12 @@ } else if(carray[ci].IsReference()) { - + nextObj = doc->GetObjects().GetObject(carray[ci].GetReference()); - + while(nextObj != NULL) { - + if(nextObj->IsReference()) { nextObj = doc->GetObjects().GetObject(nextObj->GetReference()); @@ -6826,9 +7118,9 @@ break; } } - + } - + } // end of copy mlen = outMemStream.GetLength(); @@ -6878,7 +7170,7 @@ nextObj = allObjects->GetObject(referencedObjects[i]); copyPoDoFoObject(nextObj, importedObjects[nextObj->Reference()], importedObjects); } - + Seite.ImgObjects[ResNam+"I"+QString::number(ResCount)] = xObj; imgInfo.ResNum = ResCount; ResCount++; @@ -6891,10 +7183,10 @@ // pageSize.GetHeight(). Adjust scale factor to compensate for the difference. imgInfo.sxa = sx * imgWidth / imgInfo.Width; imgInfo.sya = sy * imgHeight / imgInfo.Height; - + return true; } - + } catch(PoDoFo::PdfError& e) { @@ -6902,7 +7194,8 @@ e.PrintErrorMsg(); assert (false); return false; - } + } +#endif #endif return false; } @@ -6910,6 +7203,96 @@ #if HAVE_PODOFO +#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(1, 0, 0)) +// PoDoFo 1.0.x API + +void PDFLibCore::copyPoDoFoDirect(const PoDoFo::PdfObject& obj, QList& referencedObjects, QMap& importedObjects) +{ + switch (obj.GetDataType()) + { + case PoDoFo::PdfDataType::Reference: + { + const PoDoFo::PdfReference reference(obj.GetReference()); + uint objNr; + if (!importedObjects.contains(reference)) + { + objNr = newObject(); + importedObjects[reference] = objNr; + referencedObjects.append(reference); + } + else + { + objNr = importedObjects[reference]; + } + PutDoc(" " + QString::number(objNr) + " 0 R"); + } + break; + case PoDoFo::PdfDataType::Array: + { + const PoDoFo::PdfArray& array(obj.GetArray()); + PutDoc("["); + for (unsigned int i=0; i < array.size(); ++i) + { + copyPoDoFoDirect(array[i], referencedObjects, importedObjects); + } + PutDoc("]"); + } + break; + case PoDoFo::PdfDataType::Dictionary: + { + const PoDoFo::PdfDictionary& dict(obj.GetDictionary()); + PutDoc("<<"); + for (auto it = dict.begin(); it != dict.end(); ++it) + { + std::string escapedName = it->first.GetEscapedName(); + PutDoc("\n/" + QString::fromStdString(escapedName)); + copyPoDoFoDirect(it->second, referencedObjects, importedObjects); + } + PutDoc(" >>"); + } + break; + default: + { + std::string str; + obj.ToString(str); + PutDoc(" " + QString::fromStdString(str)); + } + } +} + +void PDFLibCore::copyPoDoFoObject(const PoDoFo::PdfObject& obj, uint scObjID, QMap& importedObjects, PoDoFo::PdfIndirectObjectList& allObjects) +{ + QList referencedObjects; + StartObj(scObjID); + copyPoDoFoDirect(obj, referencedObjects, importedObjects); + if (obj.HasStream()) + { + PoDoFo::charbuff mbuffer; + const PoDoFo::PdfObjectStream* stream = obj.GetStream(); + stream->CopyTo(mbuffer); + size_t mlen = mbuffer.size(); + if (mlen > 0 && mbuffer[mlen-1] == '\n') + --mlen; + PutDoc("\nstream\n"); + { + QByteArray buffer = QByteArray::fromRawData(mbuffer.data(), mlen); + EncodeArrayToStream(buffer, scObjID); + } + PutDoc("\nendstream"); + } + PutDoc("\nendobj\n"); + // recurse: + for (int i=0; i < referencedObjects.size(); ++i) + { + PoDoFo::PdfObject* nextObj = allObjects.GetObject(referencedObjects[i]); + if (nextObj) + copyPoDoFoObject(*nextObj, importedObjects[nextObj->GetIndirectReference()], importedObjects, allObjects); + } +} + +#else +// PoDoFo < 1.0.0 API + void PDFLibCore::copyPoDoFoDirect(const PoDoFo::PdfVariant* obj, QList& referencedObjects, QMap& importedObjects) { switch (obj->GetDataType()) @@ -6960,7 +7343,7 @@ PutDoc(" " + str); } } - + } void PDFLibCore::copyPoDoFoObject(const PoDoFo::PdfObject* obj, uint scObjID, QMap& importedObjects) @@ -6988,7 +7371,7 @@ QByteArray buffer = QByteArray::fromRawData(mbuffer, mlen); EncodeArrayToStream(buffer, scObjID); } // disconnect QByteArray from raw data - free (mbuffer); + free (mbuffer); PutDoc("\nendstream"); } PutDoc("\nendobj\n"); @@ -6999,6 +7382,8 @@ copyPoDoFoObject(nextObj, importedObjects[nextObj->Reference()], importedObjects); } } + +#endif #endif --- scribus/scimgdataloader_pdf.cpp.orig 2019-03-05 22:44:41.000000000 +0000 +++ scribus/scimgdataloader_pdf.cpp 2026-04-23 11:10:47.697384598 +0000 @@ -54,6 +54,11 @@ #ifdef HAVE_PODOFO try { +#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(1, 0, 0)) + PoDoFo::PdfMemDocument doc; + doc.Load(fn.toLocal8Bit().data()); + m_imageInfoRecord.numberOfPages = doc.GetPages().GetCount(); +#else PoDoFo::PdfError::EnableDebug( false ); #if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(0, 7, 0)) PoDoFo::PdfError::EnableLogging( false ); @@ -64,6 +69,7 @@ PoDoFo::PdfDocument doc( fn.toLocal8Bit().data() ); #endif m_imageInfoRecord.numberOfPages = doc.GetPageCount(); +#endif if (page > m_imageInfoRecord.numberOfPages) { qDebug() << "Incorrect page number specified!"; @@ -73,8 +79,12 @@ catch(PoDoFo::PdfError& e) { qDebug() << "PoDoFo error while reading page count!"; +#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(1, 0, 0)) + qDebug() << e.what(); +#else e.PrintErrorMsg(); - } +#endif + } #endif args.append("-r"+QString::number(gsRes)); args.append("-sOutputFile="+tmpFile); --- scribus/plugins/import/ai/importai.cpp.orig 2019-03-05 22:44:39.000000000 +0000 +++ scribus/plugins/import/ai/importai.cpp 2026-04-23 11:11:35.589620759 +0000 @@ -367,6 +367,92 @@ outf.open(QIODevice::WriteOnly); try { +#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(1, 0, 0)) + // PoDoFo 1.0.x API + PoDoFo::PdfMemDocument doc; + doc.Load(infile.toLocal8Bit().data()); + PoDoFo::PdfPage& curPage = doc.GetPages().GetPageAt(0); + const PoDoFo::PdfObject* piece = curPage.GetObject().GetDictionary().FindKey("PieceInfo"); + if (piece != nullptr) + { + if (piece->IsReference()) + piece = doc.GetObjects().GetObject(piece->GetReference()); + const PoDoFo::PdfObject* illy = piece ? piece->GetDictionary().FindKey("Illustrator") : nullptr; + if (illy != nullptr) + { + if (illy->IsReference()) + illy = doc.GetObjects().GetObject(illy->GetReference()); + const PoDoFo::PdfObject* priv = illy ? illy->GetDictionary().FindKey("Private") : nullptr; + if (priv != nullptr && priv->IsReference()) + priv = doc.GetObjects().GetObject(priv->GetReference()); + if (priv == nullptr) + priv = illy; + int num = 0; + if (priv != nullptr) + { + const PoDoFo::PdfObject* numBl = priv->GetDictionary().FindKey("NumBlock"); + if (numBl != nullptr) + { + if (numBl->IsReference()) + numBl = doc.GetObjects().GetObject(numBl->GetReference()); + if (numBl) + num = static_cast(numBl->GetNumber()) + 1; + } + } + if (num == 0) + num = 99999; + QString name = "AIPrivateData%1"; + QString Key = name.arg(1); + const PoDoFo::PdfObject* data = priv ? priv->GetDictionary().FindKey(PoDoFo::PdfName(Key.toUtf8().constData())) : nullptr; + if (data != nullptr && data->IsReference()) + data = doc.GetObjects().GetObject(data->GetReference()); + if (data == nullptr && priv != nullptr) + { + name = "AIPDFPrivateData%1"; + Key = name.arg(1); + data = priv->GetDictionary().FindKey(PoDoFo::PdfName(Key.toUtf8().constData())); + if (data != nullptr && data->IsReference()) + data = doc.GetObjects().GetObject(data->GetReference()); + } + if (data != nullptr) + { + if (num == 2) + { + Key = name.arg(1); + data = priv->GetDictionary().FindKey(PoDoFo::PdfName(Key.toUtf8().constData())); + if (data != nullptr && data->IsReference()) + data = doc.GetObjects().GetObject(data->GetReference()); + if (data && data->HasStream()) + { + PoDoFo::charbuff buffer; + data->GetStream()->CopyTo(buffer); + outf.write(buffer.data(), buffer.size()); + } + } + else + { + for (int a = 2; a < num; a++) + { + Key = name.arg(a); + data = priv->GetDictionary().FindKey(PoDoFo::PdfName(Key.toUtf8().constData())); + if (data != nullptr && data->IsReference()) + data = doc.GetObjects().GetObject(data->GetReference()); + if (data == nullptr) + break; + if (data->HasStream()) + { + PoDoFo::charbuff buffer; + data->GetStream()->CopyTo(buffer); + outf.write(buffer.data(), buffer.size()); + } + } + } + } + ret = true; + } + } +#else + // PoDoFo < 1.0.0 API PoDoFo::PdfError::EnableDebug( false ); #if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(0, 7, 0)) PoDoFo::PdfError::EnableLogging( false ); @@ -449,13 +535,18 @@ } } } +#endif outf.close(); } catch (PoDoFo::PdfError& e) { outf.close(); qDebug("Scribus caught and handled the following exception from PoDoFo while processing a PDF format ai file:\n----\n"); +#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(1, 0, 0)) + qDebug() << e.what(); +#else e.PrintErrorMsg(); +#endif qDebug("----\nThe ai file could not be imported.\n"); QFile::remove(outfile); return false; --- scribus/plugins/import/ps/importps.cpp.orig 2019-03-05 22:44:39.000000000 +0000 +++ scribus/plugins/import/ps/importps.cpp 2026-04-23 11:11:59.464236962 +0000 @@ -149,6 +149,14 @@ { try { +#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(1, 0, 0)) + PoDoFo::PdfMemDocument doc; + doc.Load(fName.toLocal8Bit().data()); + PoDoFo::PdfPage& curPage = doc.GetPages().GetPageAt(0); + PoDoFo::Rect rect = curPage.GetMediaBox(); + b = rect.Width - rect.X; + h = rect.Height - rect.Y; +#else PoDoFo::PdfError::EnableDebug( false ); #if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(0, 7, 0)) PoDoFo::PdfError::EnableLogging( false ); @@ -165,11 +173,16 @@ b = rect.GetWidth() - rect.GetLeft(); h = rect.GetHeight() - rect.GetBottom(); } +#endif } catch(PoDoFo::PdfError& e) { qDebug("%s", "PoDoFo error while reading page size!"); +#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(1, 0, 0)) + qDebug() << e.what(); +#else e.PrintErrorMsg(); +#endif } } #endif