|
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
|
|
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!
|
|
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");
|
|
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.aspxYou 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!
|
|
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");
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Yeah. That will do!
|
|