

Use memory stream with pdfwriter pdf#
PdfDocument pdfDoc = new PdfDocument(writer) .PdfWriter: When this PdfWriter is added to a certain PdfDocument, the PDF representation of every Element added to this Document will be written to the outputstream attached to writer (file or network). Okay, we are now all set to create our first PDF document. using iTextSharp using iTextSharp.text using Let's also create a folder where we save our PDF's right click the solution and add a folder, name it 'pdf'. MemoryStream memStream new MemoryStream() PdfWriter wri PdfWriter.GetInstance(doc, memStream). PdfWriter writer = new PdfWriter(mainStream) To make the use of the component simple in code, add the following using statements in your code.

writer.CloseStream false doc.Close() // Build email memoryStream.Position. MainStream = addNewPage(mainStream, newPageStream) Ĭode to Add new page : public static MemoryStream addNewPage(MemoryStream mainStream, MemoryStream newPageStream) PdfWriter writer PdfWriter.GetInstance(doc, memoryStream) // Build pdf code. I have two html strings, I'm trying to write both of them to 2 memoryStreams, then read one pdfDocument and CopyPagesTo to the other pdfDocument, then finally return the memoryStream with the combined documents.
