—ENVIRONMENT—
NET 5.0 launched with a Docker
Aspose.PDF 21.3.0
Faced the following problem.
I load a pdf file into the file stream, perform some manipulations with it.
After that, I want to save the modified PDF file in the MemoryStream for further uploading to Azure Storage.
I get the following error on the Save method:
private async Task Test(Stream fileStream)
{
//Create stream for saving modified PDF:
await using var pdfStream = new MemoryStream();
//Generate PDF Document from existing PDF file:
using var pdf = new Document(fileStream);
//Smth manipulation with PDF:
pdf.Info.Title = "Title 123";
//Trying to save:
pdf.Save(pdfStream, SaveFormat.Pdf);
}
----Stack Trace----
{System.NullReferenceException: Object reference not set to an instance of an object.
at #=zV9gaqLDs7tq37p9ji_s_YvaPa99t.#=zzi3k3eY=(#=zom62Wen0KGta9DeaszuV2xAq7eiD #=z73u$UjOuikYN)
at #=zAuqTDSVGFjRJlBSK2ZZDgkU=.#=zw6WtBQQ=(#=zom62Wen0KGta9DeaszuV2xAq7eiD #=z73u$UjOuikYN)
at #=qCnKzzbwMZneKAFTH0eaklA0SiGgrE4IbiFRhh2tvvCo=.#=zfmcQ4lEGLdnUyKTUboI1DWY=(Object #=z8Gm2Bxc=)
at #=qCnKzzbwMZneKAFTH0eaklA0SiGgrE4IbiFRhh2tvvCo=.#=z_Rb1c6lQJ2Y0zNylw16EIXwavKFDXjjuv8SNPDs=(MethodBase #=z8Gm2Bxc=, Boolean #=zL0M6Z1I=)
at #=qCnKzzbwMZneKAFTH0eaklA0SiGgrE4IbiFRhh2tvvCo=.#=zvqSCiUhw9h4I24sD5NmTi1OlMn4qrZWZUUEQD22eCNtI(#=qCnKzzbwMZneKAFTH0eaklA0SiGgrE4IbiFRhh2tvvCo= #=z8Gm2Bxc=, #=qznaZ9H63UU8eUp0qWP3c9LDNbSDEr$KS66l_PWcHCSA= #=zL0M6Z1I=)
at #=qCnKzzbwMZneKAFTH0eaklA0SiGgrE4IbiFRhh2tvvCo=.#=zRo$$wXZ2hIBFJZoHw8EyvrVgwUuV__5pifIb3lc=()
at #=qCnKzzbwMZneKAFTH0ea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US31ql9h31wcSikDj6rvFUUrxMB9QQA=(Boolean #=z8Gm2Bxc=)
at #=qCnKzzbwMZneKAFTH0eaklA0SiGgrE4IbiFRhh2tvvCo=.#=z5yRSj4iiUS31ql9h31wcSikDj6rvFUUrxMB9QQA=(Boolean #=z8Gm2Bxc=)
at #=qCnKzzbwMZneKAFTH0eaklA0SiGgrE4IbiFRhh2tvvCo=.#=zxpBGI7f1KNUJPwH3kg==()
at #=qCnKzzbwMZneKAFTH0eaklA0SiGgrE4IbiFRhh2tvvCo=.#=zW8nUYFyNUYzrx0Rr0jucg0$YFcmj(Object[] #=z8Gm2Bxc=, Type[] #=zL0M6Z1I=, Type[] #=zvL3P1xg=, Object[] #=ziQODuK4=)
at #=qCnKzzbwMZneKAFTH0eaklA0SiGgrE4IbiFRhh2tvvCo=.#=zgrZ5u5PGPC$$eGkM67nqluI3ZSdpV0yqQg==(Stream #=z8Gm2Bxc=, String #=zL0M6Z1I=, Object[] #=zvL3P1xg=, Type[] #=ziQODuK4=, Type[] #=z4bb1W2U=, Object[] #=z08VKlFM=)
at #=qCnKzzbwMZneKAFTH0eaklA0SiGgrE4IbiFRhh2tvvCo=.#=zkSWZku_9Cy6J8PCLGRyXF1xDzHGqjbesewW4FNQ=(Stream #=z8Gm2Bxc=, String #=zL0M6Z1I=, Object[] #=zvL3P1xg=)
at #=qCnKzzbwMZneKAFTH0eaklA0SiGgrE4IbiFRhh2tvvCo=.#=z8GilYU4UBK1VM0CfaSRZ5im4LbV4ikUvwQ==(Stream #=z8Gm2Bxc=, String #=zL0M6Z1I=, Object[] #=zvL3P1xg=)
at Aspose.Pdf.Document.#=zknqjwvMm3koH(Stream #=zYmCarLg=, SaveOptions #=zKUeVSM0iPemA)
at Aspose.Pdf.Document.#=zhNNMKwgnXtgq(Stream #=zYNJ3CormTKlf, SaveOptions #=z4Gp8a2g=)
at Aspose.Pdf.Document.Save(Stream outputStream, SaveOptions options)
at TestApp.PdfService.CreateAsync(Int32 firstId, Int32 secondId, IFormFile file) in C:\TestApp\PdfService\Services\TestService.cs:line 106}