In a sharepoint site I have several lists that contain pdf files. After gathering related files I want to merge them into one pdf file. It seems the pdffileeditor can do this, but I am having trouble with the resulting file - I get an "Error processing page". I've pasted some code below which I pieced together from the documentation and posts in the forum. I am using version 4.4.0 of the pdf.kit. Can you tell me where I am going wrong? thanks
sAttID = myItem[sAttachmentIDField].ToString();
SPListItemCollection myFileAttachments = GetAttachmentList(strFormAttLib, sAttachmentIDField, sAttID); //this returns files related to spDestinationFile (which is a SPFile obtained prior to this snippet)
int i = myFileAttachments.Count;
if (i > 0)
{
Stream[] pdfStreams = new Stream[i + 1];
Stream fsOrig = spDestinationFile.OpenBinaryStream();
pdfStreams[0] = fsOrig;
int m = 1;
foreach (SPListItem myAtt in myFileAttachments)
{
SPFile myAttFile = myAtt.File;
Stream myAttStream = myAttFile.OpenBinaryStream();
pdfStreams[m] = myAttStream;
m = m + 1;
}
MemoryStream combStream = new MemoryStream();
PdfFileEditor pdfEditor = new PdfFileEditor();
pdfEditor.Concatenate(pdfStreams, combStream);
spDestinationFile = destinationWeb.Files.Add(destinationFilePath, combStream,true);
combStream.Close();
}