Merge Dynamic PDF report with PDF from physical location

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF CoreSuite for .NET (v7)  /  Merge Dynamic PDF report with PDF from physical location

DynamicPDF CoreSuite for .NET (v7) Forum

Hi,
I am working in MVC4 Razor c#.I have to merge two reports. Out of these one report is generating at run time (Devexpress xtrareports) and other reports are present on physical location.

This is the code which i am using to generate PDF for Devexpress,and this code is working fine :

    XtraReport rpt= new XtraReport();
    rpt.CreateDocument();
    using (MemoryStream ms = new MemoryStream())
            {
                PdfExportOptions opts = new PdfExportOptions();
                opts.ShowPrintDialogOnOpen = false;
                rpt.ExportToPdf(ms, opts);
                ms.Seek(0, SeekOrigin.Begin);
                byte[] report = ms.ToArray();
                Page.Response.ContentType = "application/pdf";
                Page.Response.Clear();
                Page.Response.OutputStream.Write(report, 0, report.Length);
                Page.Response.End();
             
            }

Question : How i can use your merge library to merge a number of PDFs present on physical location with the PDF generating using the above code?
Posted by a ceTe Software moderator
Hello,

Yes, you can merge dynamically generated PDF report with existing PDF documents without any problem using our DynamicPDF Merger for .NET product. Build the complete PDF report dynamically and get the PDF data in form of byte array. Load this PDF byte array in the PdfDocument class object. Merge PdfDocument object with MergeDocument object by appending it using Append method. Then you can append the existing PDF documents using Append method of the MergeDocument object by accessing the PDFs using file path.  Please refer to the documentation on document merge here.

Below is the sample code to generate PDF from scratch, appending it to MergeDocument and appending existing PDF documents.

            //Generating PDF dynamically from scratch.
            Document document = new Document();
            Page page = new Page();
            document.Pages.Add(page);
            Label label = new Label("This is to test", 100, 100, 200, 50);
            page.Elements.Add(label);
           //Outputting document on the form of byte array.
            byte[] byteData = document.Draw();

            //Create MergeDocument object.
            MergeDocument mergeDocument = new MergeDocument();
            //Load the dynamically generated PDF which is in the form of Byte array.
            PdfDocument pdf = new PdfDocument(byteData);
            //Appending he PDF byte data to the MergeDocumet class members.
            mergeDocument.Append(pdf);
            //Appending existing PDFs to mergeDocument object.
            mergeDocument.Append(@"C:\Temp\DocumentA.pdf");
            //Save final merged PDF to disk.
            mergeDocument.Draw(@"C:\Temp\MyDocument.pdf");

Thanks,
ceTe Software Support Team.
Hi,
Thanks for your reply.i had checked your latest code snippet its working fine.But the Physical PDF which i am getting to merge showing boxes in background. Whereas in original it having white background.Is  there any option on your site to send attachment so that you can also see this ?
I am also having some questions regarding your support. Can i perform a live chat ?
Posted by a ceTe Software moderator
Hello,

Our live chat is open from 8:30 AM To 5:00 PM US EST. We also offer free standard support with all our products and here is the email address support@cete.com to send your questions and attachments.

With regards to the boxes in the background issue, please include the following information in your email.

1.Input (original) PDF document.
2.Output PDF document.
3.Sample code used for merging.
4.Exact version and build number of the DynamicPDF DLL file.

Thanks,
ceTe Software Support Team.

All times are US Eastern Standard time. The time now is 1:16 AM.