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 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,