Welcome Guest Search | Active Topics | Sign In | Register

Merge multiple documents Options
vj
Posted: Monday, August 29, 2011 12:35:36 PM
Rank: Newbie
Groups: Member

Joined: 8/29/2011
Posts: 3
Hello,

I am trying to merge multiple pdf documents into 1.

Code: C#
string[] myPDFDocs = new string[fileCount];
string[] fileEntries = Directory.GetFiles(sFilePath, "*.pdf");
int i = 0;

foreach (string fileName in fileEntries)
{
    myPDFDocs[i] = fileName;
    i++;
}
PdfDocument result =  PdfDocument.Merge(casePDFDocs);
result.Save(sFilePath + "new_File.pdf");


The above code doesn't work. any ideas?

Thanks
eo_support
Posted: Monday, August 29, 2011 12:49:23 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

What is casePDFDocs? Where do you initialize it? It's not shown in your code.

Thanks!
vj
Posted: Monday, August 29, 2011 12:51:12 PM
Rank: Newbie
Groups: Member

Joined: 8/29/2011
Posts: 3
Sorry, casePDFDocs is same as myPDFDocs my typo while posting the code. Here is the code that doesn't work

Code: C#
string[] myPDFDocs = new string[fileCount];
string[] fileEntries = Directory.GetFiles(sFilePath, "*.pdf");
int i = 0;

foreach (string fileName in fileEntries)
{
    myPDFDocs[i] = fileName;
    i++;
}
PdfDocument result =  PdfDocument.Merge(myPDFDocs);
result.Save(sFilePath + "new_File.pdf");
eo_support
Posted: Monday, August 29, 2011 12:55:57 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Then of course it won't work. : ) Please check all the available Merge functions here:

http://doc.essentialobjects.com/library/4/eo.pdf.pdfdocument.merge_overloads.aspx

You have to pick one from here instead of inventing your own. You give it an array of strings, which does not match any of the function in this list.

Thanks!
vj
Posted: Monday, August 29, 2011 1:48:09 PM
Rank: Newbie
Groups: Member

Joined: 8/29/2011
Posts: 3
Ok. Thanks! Here is the working code:

Code: C#
PdfDocument[] myPDFDocs = new PdfDocument[fileCount];
string[] fileEntries = Directory.GetFiles(sFilePath, "*.pdf");
int i = 0;

foreach (string fileName in fileEntries)
{
    myPDFDocs[i] =  new PdfDocument(fileName);
    i++;
}
PdfDocument result =  PdfDocument.Merge(myPDFDocs);
result.Save(sFilePath + "new_File.pdf");

Angel
eo_support
Posted: Monday, August 29, 2011 1:50:24 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Yeah. That will do!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.