I\'m using iTextSharp version: 5.5.6; iTextSharp XML Worker version: 5.5.6
I got some code from Here, but after I run the code, the PDF file will never open
(as discovered through the comments)
You need to call doc.Close() before calling buf = memStream.ToArray();. This let's iTextSharp know that you are actually done and it should flush any buffers and write the PDF trailer.
doc.Close()
buf = memStream.ToArray();