hello ,
i have a problem when i use PDFSharp to save a PDF file using .save() and i give it the path, the PDF file is fine and it show's everything . But when i use .Save() to stream to get the byte array and then i write it as PDF it shows a blank empty PDF even tho it has the same size as the normal save with the path .
below is the code i used :
note : pDoc is pdfDocument .
Code:
MigraDoc.DocumentObjectModel.Document doc = new MigraDoc.DocumentObjectModel.Document();
MigraDoc.Rendering.DocumentRenderer renderer = new DocumentRenderer(doc);
MigraDoc.Rendering.PdfDocumentRenderer pdfRenderer = new MigraDoc.Rendering.PdfDocumentRenderer();
pdfRenderer.PdfDocument = pDoc;
pdfRenderer.DocumentRenderer = renderer;
using (MemoryStream ms = new MemoryStream())
{
pdfRenderer.Save(ms, false);
byte[] buffer = new byte[ms.Length];
ms.Seek(0, SeekOrigin.Begin);
ms.Flush();
ms.Read(buffer, 0, (int)ms.Length);
file.writeAllBytes(@"D:\test.pdf",buffer);
}
The main idea is i want to get the correct array of byte to that pDoc.
any idea ? please help thanks