Hello Albert,

Am 21.03.2013 23:46, schrieb Albert Astals Cid:
> El Dijous, 21 de març de 2013, a les 19:33:35, Adam Reichold va escriure:
> Hello,
> 
> I just had a user point out to me that when using the Qt frontend's
> PDFConverter to save a file with changes (irrespective of whether some
> were actually made) will double the file size in every iteration.
> (Tested with it a few files using Poppler 0.22.1.)
> 
> I suspect this has something to do with incrementally updating the
> document structure? Is this a known limitation in calculating the
> change set or something like that or should I rather open a bug report
> to track this?
> 
>> This should not happen, are you saving the file over itself? Probably not, 
>> last time i tried i think that destroyed the file :D

No, I am save to a different file in every step.

>> Also as far as i remember we have code that does nothing if you don't do any 
>> change.
> 
>> Cheers,
>>   Albert

I attached a test case that triggers the behavior. Maybe my usage of the
PDFConverter is wrong. As it is, the program yields an 800 MB file from
starting with a 1.5 MB file for me, using Poppler 0.22.1.

Best regards, Adam.

> Best regards, Adam.
>> _______________________________________________
>> poppler mailing list
>> [email protected]
>> http://lists.freedesktop.org/mailman/listinfo/poppler
> _______________________________________________
> poppler mailing list
> [email protected]
> http://lists.freedesktop.org/mailman/listinfo/poppler
> 
#include <QDebug>
#include <QFile>
#include <QScopedPointer>

#include <poppler-qt4.h>

bool save(Poppler::Document* d, const QString& n)
{
    QScopedPointer< Poppler::PDFConverter > c(d->pdfConverter());

    c->setOutputFileName(n);
    c->setPDFOptions(c->pdfOptions() | Poppler::PDFConverter::WithChanges);

    return c->convert();
}

int main(int argc, char** argv)
{
    if(argc != 2)
        return 1;

    Poppler::Document* d = Poppler::Document::load(argv[1]);

    if(d == 0)
        return 2;

    qDebug() << "save:" << 1;
    bool ok = save(d, "file1.pdf");

    delete d;

    if(!ok)
        return 3;

    qDebug() << "size:" << QFile("file1.pdf").size() / 1024;

    for(int i = 1; i < 10; ++i)
    {
        Poppler::Document* d = Poppler::Document::load(QString("file%1.pdf").arg(i));

        if(d == 0)
            return 4;

        qDebug() << "save:" << i;
        bool ok = save(d, QString("file%1.pdf").arg(i+1));

        delete d;

        if(!ok)
            return 5;

        qDebug() << "size:" << QFile(QString("file%1.pdf").arg(i+1)).size() / 1024;
    }
    
    return 0;
}
_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler

Reply via email to