Pdf from byte array or stream

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF Generator for .NET (v3 and older)  /  Pdf from byte array or stream

DynamicPDF Generator for .NET (v3 and older) Forum

 Dec 17 2010 5:05 PM
Hi
Can you help me with sample code to generate PDF from a byte array or memory stream,also cam can I do merging with same inputs(byte array/stream).
I went through the sample i'm not able to find the one I requested.

Thanks in advance.

Regards,
Ajith
 Dec 20 2010 9:10 AM
Posted by a ceTe Software moderator
Hello Ajith,

Can you please let us know exactly what version of DynamicPDF product you are using? You can merge the PDF document which is in the form of byte array or PDF steam without any problem using our DynamicPDF Merger for .NET product. You will have to use PdfDocument class constructor which takes byte array or stream as parameter and create object of it. Then you will have to build the MergeDocument object using this PdfDocument object. Below is the sample code to get the PDF document in the form of byte array and merge it using PdfDocument object.

            Byte[] bytedata = File.ReadAllBytes(@"C:\temp\DocumentC.pdf");
            PdfDocument pdfdoc = new PdfDocument(bytedata);
            MergeDocument document = new MergeDocument(pdfdoc);
            document.Draw(@"C:\temp\Test.pdf");

Thanks,
ceTe Software Support Team
 Dec 20 2010 11:17 AM
Hi
I'm using version 4.0.3.20,trying to generate report using merge document from a byte array(which has multiple reports),but I'm getting only the last report in display.I want to display all the reports as one document,please help me in achieving this and let me know if you are not clear.()

The byte array I'm getting if from a reportviewer(VS2008).

Thanks.
 Dec 20 2010 11:57 AM
Posted by a ceTe Software moderator
Hello Ajith,

The sample code which we have posted earlier is to merge a single PDF document. If you are generating reports in a loop  then you can use Append method of the MergeDocument object and append all your reports to make a single PDF document. Below is the code for appending the PDF document which is in the form of byte array. You will have to make sure that each time you are loading the required PDF stream in the PdfDocument object.

            MergeDocument document = new MergeDocument();      
            Byte[] bytedata = File.ReadAllBytes(@"C:\temp\DocumentC.pdf");
            PdfDocument pdfdoc = new PdfDocument(bytedata);
            document.Append(pdfdoc);
            document.Draw(@"C:\temp\Test.pdf");

If the above suggestions do not meet your requirements then please send over the sample code which you are using to our support team at support@cete.com so that they can look into it further.

Thanks,
ceTe Software Support Team

All times are US Eastern Standard time. The time now is 7:17 PM.