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

Free Support Forum - aspose.com

Validate PDF connverted into PDF/A 3B using MemoryStream

Hello,

how can I validate a previously converted PDF/A 3B file - using a MemoryStream (not saving a XML to disk)?

I tried accessing the MemoryStreams of the Convert() or Validate() methods but always ran into the exception that the MemoryStream is already closed.


(.Net 3.5)

Hi there,


Thanks for your inquriy. You can load existing PDFA document via stream in Document() object and use Validate() method for validation, It returns result as bool, so this can help you to accomplish the task. However if there is any difference in your requirements and my understanding then please share some more details along with sample code, so we will check this and guide you accordingly.

Please feel free to contact us for any further assistance.

Best Regards,

Thanks for your quick answer.

The boolean value is not enough. It’s good to know if the convertion was successfull, but that is no indication whether the resulting PDF is a 100% valid PDF/A document (e.g. missing fonts, missing/invalid metadata etc.)

For that I need the validation method after I converted the PDF to PDF/A AND I need the validation result as a MemoryStream.

Hi there,


Thanks for your feedback. If you want to get validation or conversion log in stream then please use respective overload of the methods. For example for validation you can use following code snippet for the purpose. Hopefully it will help you to accomplish the task. However if there is any difference in your requirement and my understanding then please share your sample code we will look into it and will guide you accordingly.

var inputstream = new MemoryStream(System.IO.File.ReadAllBytes(myDir+“Aufstieg_durch_Bildung_2013_PDFA3b.pdf”));

// Open document

Document pdfDocument = new Document(inputstream);

// Convert to PDF/A compliant document

MemoryStream log = new MemoryStream();

//during conversion process, the validation is also performed

pdfDocument.Validate(log, PdfFormat.PDF_A_3B);

pdfDocument.Dispose();

//convert MemoryStream back to byte array

byte[] data = log.ToArray();

//create a FileStream to save the output PDF file

FileStream output = new FileStream(myDir+"Aufstieg_durch_Bildung_2013_PDFA3b_log.xml", FileMode.Create, FileAccess.Write);

//write byte array contents in the output file stream

output.Write(data, 0, data.Length);

//close output file

output.Close();

Please feel free to contact us for any further assistance.


Best Regards,

Thanks for your answer.


Your code is working but the nevertheless - the MemoryStream “log” IS CLOSED.





At this point the solution for my requirement is that I’m going to convert the CLOSED MemoryStream into a byte array and then convert the byte array into a MemoryStream (one that I can work with)…


That’s NOT very efficient…

Hi there,


Thanks for your feedback. It is good that solution worked for you . However we have logged an investigation ticket PDFNEWNET-40109 in our issue tracking system to investigate the Memory Stream closing issue. We will keep you updated about the issue resolution progress.

We are sorry for the inconvenience caused.

Best Regards,