We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose.PDF is not working when set new value for metadata via Parallel.For

Env

  • Windows 10 .NET 4.7
  • Aspose.PDF 22.12

Description

Aspose.PDF not work when change metadata properties with Parallel thread mode. If I change Parallel to for, it’s OK.

Code

void Main()
{
    // it's OK
    //for (var i = 1; i < 6; i++)
    //{
    //    var doc = new Aspose.Pdf.Document(@"C:\Users\XCL\Desktop\test\" + i + ".pdf");
    //    doc.Info.Title = "111";
    //    doc.Info.Author = "222";
    //    doc.Info.Subject = "333";
    //    doc.Info.Keywords = "444";
    //    doc.Save(@"C:\Users\XCL\Desktop\test\out\" + i + ".pdf");
    //}

    // it's not working for all files but last one
    Parallel.For(1, 6, (i) =>
    {
        var doc = new Aspose.Pdf.Document(@"C:\Users\XCL\Desktop\test\" + i + ".pdf");
        doc.Info.Title = "111";
        doc.Info.Author = "222";
        doc.Info.Subject = "333";
        doc.Info.Keywords = "444";
        doc.Save(@"C:\Users\XCL\Desktop\test\out\" + i + ".pdf");
    });
}

Preview

image.png (48.9 KB)
image.png (43.7 KB)

Test Files

test.zip (560.5 KB)

Note

I think I found more bugs for basic functions, you should strengthen the testing of basic features.

@xucongli1989

We have logged this problem in our issue tracking system as PDFNET-53368. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.