var pdf = new PDFDocument code example
Example: itext7 c# memorystream
public byte[] GeneratePdf()
{
var stream = new MemoryStream();
var writer = new PdfWriter(stream);
var pdf = new PdfDocument(writer);
var document = new Document(pdf);
document.Add(new Paragraph("Lorem Ipsum ..."));
document.Close();
return stream.ToArray();
}