|
Rank: Newbie Groups: Member
Joined: 3/15/2013 Posts: 4
|
PdfDocument[] docs = new PdfDocument[] { }; docs[0] = new PdfDocument("D:\\For Delete\\1.pdf"); docs[1] = new PdfDocument("D:\\For Delete\\2.pdf");
//Merge them into a single PDF file mergedDoc = PdfDocument.Merge(docs);
//You are also free to modify the merged document PdfPage page = mergedDoc.Pages.Add();
//Save the result mergedDoc.Save("D:\\For Delete\\Merge.pdf");
Please help
Thanks VJ
|
|
Rank: Advanced Member Groups: Member
Joined: 11/13/2008 Posts: 43
|
Vijay Pote wrote:Please help What's the problem...?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi Vijay,
You need to troubleshoot such simple problem yourself. We do not troubleshoot your code.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 3/15/2013 Posts: 4
|
That is fine, i did my troubleshooting. but this is something i am trying to merge multiple pdf documents into one single pdf dynamically.
if i use :
PdfDocument docs1 = new PdfDocument("D:\\For Delete\\1.pdf"); PdfDocument docs2 = new PdfDocument("D:\\For Delete\\2.pdf");
it works fine, but i am trying to do it dynamically it fails.
PdfDocument[] docs = new PdfDocument[] { }; while(_reader.read()) { docs[i] = new PdfDocument("D:\\For Delete\\1.pdf"); }
The code is compiles fine with no error but when i run it i get Index was outside the bounds of the array
I am asking everyone here ... what is the alternative to do this. Has any one tried creating pdf merge dynamically ?
let me know as i am fighting on this for quite some time now.
Thanks VJ
|
|
Rank: Advanced Member Groups: Member
Joined: 11/13/2008 Posts: 43
|
Vijay Pote wrote:PdfDocument[] docs = new PdfDocument[] { };VJ That's an array, not a generic collection. Look at it again - how big is it, i.e. how many "spaces" does the PdfDocument[] have? Have a read through this: http://msdn.microsoft.com/en-us/library/aa288453(v=vs.71).aspx
|
|
Rank: Newbie Groups: Member
Joined: 3/15/2013 Posts: 4
|
Hi Mark,
Thanks for your reply, will go over it tonight and will let you know.
Thanks
|
|
Rank: Advanced Member Groups: Member
Joined: 11/13/2008 Posts: 43
|
OK, in the interests of helping you out, this has NOTHING to do with EssentialObjects - it's purely a C# problem. Look at this:
Code: C#
int[] IntegerArray = new int[] { };
IntegerArray[0] = 0;
IntegerArray[1] = 1;
It will compile fine, but will break on the second line, just like your code does. Why, because IntegerArray[0] doesn't exist, so you can't store a value there. All the first line has done is to create an array with no size. However, this will also compile but will not break on the second line:
Code: C#
int[] IntegerArray = new int[2];
IntegerArray[0] = 0;
IntegerArray[1] = 1;
Generics were introduced in .NET 2 to get round this "problem" - I suggest you read up on them...
|
|
Rank: Newbie Groups: Member
Joined: 3/15/2013 Posts: 4
|
Cool, Thanks Mark!
I will go over it and will resolve my issue bases on your suggestion.
Appreciate for your help!
Thanks
|
|