Hi ,
I am getting error while creating document from stream . Please find the code sample I am using :
Stream inputStream = this.fupManualFileUpload.FileContent;
Aspose.Pdf.Generator.Pdf testpdf = new Aspose.Pdf.Generator.Pdf(inputStream);
Document pdfDocument = new Document(testpdf);
Please suggest. I am need to create a docuemnt from the in memory stream which i have obtained earlier.
I am unable to use the overload method
Document.Document(Stream input) ;
Its giving me “Invalid file format” exception
I even tried doing - Document pdfDocument = new Document(inputStream ); but its failing
Any updates? I am looking for a quick reply . Clients are waiting
Hi Yogesh,
Hi,
Please find the resource file which I am using for creating stream attached in this post as well as first post . Yes I am facing issue while using Aspose.Pdf.Document
Following is the error message :
You are in direct-to-file mode,please use Close() instead of Save().
At times i am also getting invalid pdf file format exception . please guide
My intension is to fetch the stream from the upload control using ( Aspose.Pdf.Facades.PdfExtractor) , and then do the barcode validation on the stream , and also do other validations (PDF standard/A )/ transparency / embedded fonts by creating the Aspose.Pdf.Document from the created stream
I am able to do the barcode validation on the stream , but unable to use the same stream to create the Aspose.Pdf.Document
I need to handle it in memory stream
My simple question is , how can i use the overloaded method
Document.Document(Stream input)
Hi,
Any updates? Please let me know
Hi Yogesh,
byte[] buffer = File.ReadAllBytes(“HelloWorld.pdf”);<o:p></o:p>
MemoryStream inputStream = new MemoryStream(buffer);
// load PDF document
Aspose.Pdf.Document doc = new Aspose.Pdf.Document(inputStream);
MemoryStream outputStream = new MemoryStream();
doc.Save(outputStream);
//convert MemoryStream back to byte array
byte[] data = outputStream.ToArray();
//create a FileStream to save the output PDF file
FileStream output = new FileStream("HelloWorld_out.pdf", FileMode.Create,
FileAccess.Write);
//write byte array contents in the output file stream
output.Write(data, 0, data.Length);
//close output file
output.Close();