Hi,
I'm generating two pdf's dynamically,in which first pdf1 has only two lines (always)second one have large data.Can I merge these two so that pdf2 should start from the end of pdf1 content instead next page.
Please help if DynamicPDF can do this and let me know if I'm not clear.
Thanks in advance.
Merging from same page
Re: Merging from same page
Support · Jan 26, 2011Hello,
Yes you can use the ImportedPageArea and ImprotedPageContents class to import the contents of the pdf2 and add them to the pdf1. You will have to specify the x & y co-ordinates with respect to the pdf1 when you create the ImportedPageArea object.
MergeDocument doc = new MergeDocument("pdf1.pdf");
ImportedPageContents contents = new ImportedPageContents("pdf2.pdf", 1);
ImportedPageArea pgarea = new ImportedPageArea(contents, 0, 100);
doc.Pages[0].Elements.Add(pgarea);
doc.Draw(@"c:\test.pdf");
Here is the link to the documentation for the classes used in the code:
http://www.DynamicPDF.com/Support/NET_Help_Library_10_03/ceTe.DynamicPDF~ceTe.DynamicPDF.Merger_namespace.html
Thanks,
ceTe Software Support Team.
Re: Merging from same page
Forum member · Jan 26, 2011Thanks for you quick reply and support.
This will exactly help me if I'm able to get 'ImportedPageContents' from an byte[].
Right now I'm merging with byte[]s and I see ImportedPageContents is taking only string or pdf.As we have enivronmental security issues i cannot use physical paths.It will be helpful if I get any info on getting ImportedPageContents from an Byte[].
Thanks much.
Re: Merging from same page
Support · Jan 27, 2011Hello,
Yes, you can import the contents from the PDF document which is in the form of byte array without any problem using our DynamicPDF Merger for .NET product. You will have to use the PdfDocument class which takes byte array as parameter and create an object of it. You can then use this PdfDocument to import the contents and add it to the page of the PDF document. Below is the sample code for it.
Byte[] bytedata = File.ReadAllBytes(@"C:\temp\Test.pdf");
PdfDocument pdfdoc = new PdfDocument(bytedata);
MergeDocument document = new MergeDocument();
ImportedPageContents contents = new ImportedPageContents(pdfdoc.Pages[0]);
ImportedPageArea pgarea = new ImportedPageArea(contents, 0, 100);
document.Append(pdfdoc);
document.Pages[0].Elements.Add(pgarea);
document.Draw(@"C:\temp\DocumentC.pdf");
Thanks,
ceTe Software Supprot Team.
Re: Merging from same page
Forum member · Jan 27, 2011I'm able to do it now,Thank you very much for your support/help
Regards .