Convert a Docx to PDF given by a byte array by using a filter

Q: How do I convert their Docx (given by a byte array) to PDF and return that as a byte array. We can currently implement this by giving a file path, or by using a filter object.
There wasn’t any documentation/sample code for using a filter to input a byte array.

A: Here is code that uses a filter input with a memory stream:

static void SimpleConvert(String input_filename, String output_filename)
     {
         // Start with a PDFDoc (the conversion destination)
         using (PDFDoc pdfdoc = new PDFDoc())
         {
            // Loading bytes of the file into an in-memory array
             byte[] byte_array = System.IO.File.ReadAllBytes(input_path +input_filename);

             // instantiate filter with byte array
             var filter = new MemoryFilter(byte_array.Length, true);
             var filterWriter = new FilterWriter(filter);
             filterWriter.WriteBuffer(byte_array);
             filterWriter.Flush();

             // perform the conversion with no optional parameters
             pdftron.PDF.Convert.OfficeToPDF(pdfdoc, filter, null);

             // save the result into an in-memory byte array
             byte [] new_byte_output = pdfdoc.Save(SDFDoc.SaveOptions.e_linearized);
             File.WriteAllBytes(output_path + output_filename, new_byte_output);

             // And we're done!
             Console.WriteLine("Saved" + output_filename);
         }   
     }