c# - iText7 Create PDF in memory instead of physical file -


how 1 create pdf in memorystream instead of physical file using itext7? have no idea how in latest version, help?

i tried following code, pdfsm not populated:

string filepath = "./abc.pdf";  memorystream pdfsm = new bytearrayoutputstream();  pdfdocument doc = new pdfdocument(new pdfreader(filepath), new pdfwriter(pdfsm)); .......  doc.close(); 

the full testing code below reference, worked when past filepath pdfwriter not memory stream:

    public static readonly string sourcefolder = "../../formtest/";      public static readonly string destinationfolder = "../../output/";      static void main(string[] args)     {          string srcfilepattern = "i-983";         string destpattern = "i-129_2014_";          string src = sourcefolder + srcfilepattern + ".pdf";         string dest = destinationfolder + destpattern + "_flattened.pdf";         memorystream returnsm = new memorystream();          pdfdocument doc = new pdfdocument(new pdfreader(src), new pdfwriter(returnsm));          pdfacroform form = pdfacroform.getacroform(doc, false);          foreach (pdfformfield field in form.getformfields().values)          {             var fieldname = field.getfieldname();             var type = field.gettype();             if (fieldname != null)             {                 if (type.name.equals("pdftextformfield"))                 {                         field.setvalue("t");                 }             }                        }         form.flattenfields();                  doc.close();      } 


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -