Concatenating x Number of Times?

I trying to use the pdf.kit libary to create a single pdf document in an ASP.Net web application. What im trying to do, is allow a user to select using a checkbox any number of items. Once selected, they'll click submit then what I need to do is for each selected item, add a pdf document thats composed of a front page and a back page. See below:

string pdfFront = "C:\\Temp\\reg_front.pdf";
string pdfBack = "C:\\Temp\\reg_back.pdf";

public PdfFile(Collection<registration> registrations)
{
FileStream outStream = new FileStream("c:\\Temp\\newfile.pdf", FileMode.OpenOrCreate);
foreach (registration reg in registrations)
{
FileStream fStream = new FileStream(pdfFront, FileMode.Open, FileAccess.Read);
FileStream bStream = new FileStream(pdfBack, FileMode.Open, FileAccess.Read);
PdfFileEditor pdfEditor = new PdfFileEditor();
pdfEditor.Concatenate(fStream,bStream,outStream);
fStream.Close();
bStream.Close();
}
outStream.Flush();
outStream.Close();
}

Hopefully what im trying to do is a little clearer now...create one document composed of x number of front and back pdf files.

Whats atually happening though, is even though the foreach is looping through twice, the final file is only a single pair (front and back). It should be front, back, front, back, but instean its just front, back. I have no idea why this is doing this and any help would be appreciated.

Dennis

Hi,

Thank you for considering Aspose.

What you are doing is not feasible because you are overwriting the output stream. For this loop to work the result of each loop should be kept in a seperate stream, then in the end the array of output streams should be concatenated.

Hope this helps.

Thanks.