Hi, this is the problem:
i've got this piece of code...
It keeps throwing a NullReferenceException at the stamp.AlterContents(); line.
i've got no clue on what's going on. Any help appreciated!
public static byte[] concatAndAddContent(List<byte[]> pdf)
{
byte [] todos;
using(MemoryStream ms = new MemoryStream())
{
Document doc = new Document();
doc.Open();
PdfCopy copy = new PdfCopy(doc, ms);
PdfCopyFields copy2 = new PdfCopyFields(ms);
PdfReader reader;
foreach (byte[] p in pdf)
{
reader = new PdfReader(p);
int pages = reader.NumberOfPages;
// loop over document pages
for (int i = 1; i <= pages; i++)
{
PdfImportedPage page = copy.GetImportedPage(reader, i);
PdfCopy.PageStamp stamp = copy.CreatePageStamp(page);
PdfContentByte cb = stamp.GetUnderContent();
cb.SaveState();
stamp.AlterContents();
copy.AddPage(page);
}
}
doc.Close();
todos = ms.GetBuffer();
ms.Flush();
ms.Dispose();
}
return todos;
}
i've got iTextSharp version 5.0.4 in VisualStudio 2010