title: How to merge a physical file (pdf) and a generated one (pdf) and output them to the browser?
body: <p>Been struggling with this.</p>
  
  <p>I have a physical file (pdf) and a generated one that is generated by iTextSharp (pdf) my goal is to merge both of them and output it to the browser.</p>
  
  <p>By the way, I am using ASP.NET MVC 4</p>
  
  <p>So, in my controller, I have something like this:</p>
  
  <pre><code>public ActionResult Index()
  {
    MemoryStream memoryStream = new MemoryStream();
    var path = Server.MapPath("~/Doc/../myfile.pdf"); // This is my physical file
    var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read);
  
    GenerateFile(); // This is my generated file thru iTextSharp
  
    Response.AddHeader("Content-Disposition", "inline");
    memoryStream.Position = 0;
  
    return new FileStreamResult(// Maybe merged file goes here? not sure.
                               ,"application/pdf");
  }
  
  private void GenerateFile()
  {
    MemoryStream stream = new MemoryStream();
    var document = new Document(/*some settings here*/);
    PdfWriter.GetInstance(document, stream).CloseStream = false;
  
    document.Open();
    // generate pdf here
    document.Close();
  }
  </code></pre>
  
  <p>And is it possible to set the generated pdf as the first (or how many pages it will generate) page then append the physical file?</p>
  
  <p>Any help would be much appreciated. Thanks</p>