Hi there!
Aspose.PDF raises a System.NullReferenceException
when converting or saving the
editorial_twopages_fax4g.pdf (51.5 KB) PDF file.
This wasn’t an issue with Aspose.PDF 24.1 or 24.5, but it is with Aspose.PDF 24.6.
Code to reproduce the issue when saving to a memory stream:
static void Main(string[] args)
{
var path = @"editorial_twopages_fax4g.pdf";
var stream = OpenPdfIntoMemoryStream(path);
var pdfDocument = new Document(stream);
pdfDocument.Convert(new PdfFormatConversionOptions(PdfFormat.v_1_4));
var convertedPdfStream = new MemoryStream();
pdfDocument.Save(convertedPdfStream); // Error
pdfDocument.Dispose();
convertedPdfStream.Dispose();
Console.ReadLine();
}
public static MemoryStream OpenPdfIntoMemoryStream(string path)
{
byte[] fileBytes = File.ReadAllBytes(path);
MemoryStream memoryStream = new MemoryStream(fileBytes);
return memoryStream;
}
StackTrace:
at #=z6HQ73iZOcVn4IPseLrDIRR$vX_pBsgPiWx9hUs5KcGQhwh_y2VGxeUg=.#=z4R26j98Vgq_u(Page #=zruQ1L_I=, OperatorCollection #=zR57ABIc=, Resources #=zhWwfL2Y=, Int32 #=zlFqeQp7j6Pcm, #=z2crw$xFaZKx77JuPmy4S4ZtagWH$$zGX2BDZy487sU971FI2Eg== #=zQ3WPP2INM3zM)
at #=z6HQ73iZOcVn4IPseLrDIRR$vX_pBsgPiWx9hUs5KcGQhwh_y2VGxeUg=.#=zhi7s9$trWul6(Page #=zruQ1L_I=, #=z2crw$xFaZKx77JuPmy4S4ZtagWH$$zGX2BDZy487sU971FI2Eg== #=zQ3WPP2INM3zM)
at #=z6HQ73iZOcVn4IPseLrDIRR$vX_pBsgPiWx9hUs5KcGQhwh_y2VGxeUg=.#=zS6lrtf4=()
at #=z6HQ73iZOcVn4IPseLrDIRR$vX_pBsgPiWx9hUs5KcGQhwh_y2VGxeUg=.#=z13ECSi0=()
at #=zc20jbNI2c1pSKKi26XxxeSmRlTtitUo1VBSj4rJRf3wExz4KYJthhKY=.#=z9Ny8urI=()
at #=z6HQ73iZOcVn4IPseLrDIRR$vX_pBsgPiWx9hUs5KcGQhwh_y2VGxeUg=.#=zXPJA8SM=(PdfFormatConversionOptions #=z6nTZAe8=)
at Aspose.Pdf.Document.#=zHHW26sE=(PdfFormatConversionOptions #=z6nTZAe8=, Boolean #=zKCS8GjGudgz7)
at Aspose.Pdf.Document.Convert(PdfFormatConversionOptions options)
at ReproduceAsposeConversionErrorEditorial.Program.Main(String[] args) in ReproduceAsposeConversionErrorEditorial\Program.cs:line 19
Code to reproduce the issue when converting the PDF:
static void Main(string[] args)
{
var path = @"editorial_twopages_fax4g.pdf";
var stream = OpenPdfIntoMemoryStream(path);
var pdfDocument = new Document(stream);
pdfDocument.Convert(new PdfFormatConversionOptions(PdfFormat.PDF_A_2B)); // Error. Happens also with other formats, like (but not limited to) PDF_A_1B.
var convertedPdfStream = new MemoryStream();
pdfDocument.Save(convertedPdfStream);
pdfDocument.Dispose();
convertedPdfStream.Dispose();
Console.ReadLine();
}
public static MemoryStream OpenPdfIntoMemoryStream(string path)
{
byte[] fileBytes = File.ReadAllBytes(path);
MemoryStream memoryStream = new MemoryStream(fileBytes);
return memoryStream;
}
StackTrace:
at #=z6HQ73iZOcVn4IPseLrDIRR$vX_pBsgPiWx9hUs5KcGQhwh_y2VGxeUg=.#=z4R26j98Vgq_u(Page #=zruQ1L_I=, OperatorCollection #=zR57ABIc=, Resources #=zhWwfL2Y=, Int32 #=zlFqeQp7j6Pcm, #=z2crw$xFaZKx77JuPmy4S4ZtagWH$$zGX2BDZy487sU971FI2Eg== #=zQ3WPP2INM3zM)
at #=z6HQ73iZOcVn4IPseLrDIRR$vX_pBsgPiWx9hUs5KcGQhwh_y2VGxeUg=.#=zhi7s9$trWul6(Page #=zruQ1L_I=, #=z2crw$xFaZKx77JuPmy4S4ZtagWH$$zGX2BDZy487sU971FI2Eg== #=zQ3WPP2INM3zM)
at #=z6HQ73iZOcVn4IPseLrDIRR$vX_pBsgPiWx9hUs5KcGQhwh_y2VGxeUg=.#=zS6lrtf4=()
at #=z6HQ73iZOcVn4IPseLrDIRR$vX_pBsgPiWx9hUs5KcGQhwh_y2VGxeUg=.#=z13ECSi0=()
at #=zc20jbNI2c1pSKKi26XxxeSmRlTtitUo1VBSj4rJRf3wExz4KYJthhKY=.#=z9Ny8urI=()
at #=z6HQ73iZOcVn4IPseLrDIRR$vX_pBsgPiWx9hUs5KcGQhwh_y2VGxeUg=.#=zXPJA8SM=(PdfFormatConversionOptions #=z6nTZAe8=)
at Aspose.Pdf.Document.#=zHHW26sE=(PdfFormatConversionOptions #=z6nTZAe8=, Boolean #=zKCS8GjGudgz7)
at Aspose.Pdf.Document.Convert(PdfFormatConversionOptions options)
at ReproduceAsposeConversionErrorEditorial.Program.Main(String[] args) in ReproduceAsposeConversionErrorEditorial\Program.cs:line 19