title: c# How to return a byte array from pdf using iTextsharp
body: <p>All,</p>
  
  <p>i created the following method to take in a tiff byte array with multiple tiff page document</p>
  
  <p>i need to convert this to pdf, then return a pdf byte array</p>
  
  <p>i have 2 problems with this code
  <strong>1 - i want to RETURN a byte [].
  2 - the pdf generated is repeating the pages.</strong></p>
  
  <pre><code>    public void convertImage(byte[] documentContent)
      {
          Document document = new Document(PageSize.LETTER, 0, 0, 0, 0);
  
          PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(@"C:\Data\Output.pdf", FileMode.Create)); --for testing purposes
  
  
  
          Bitmap oldImage;
  
          using (var ms = new MemoryStream(documentContent))
          {
              oldImage = new Bitmap(ms);
          }
  
  
          Size newSize = new Size(1024, 737);
  
  
          using (Bitmap bmp1 = new Bitmap(oldImage, newSize))
          {
              int total = oldImage.GetFrameCount(FrameDimension.Page);
  
              document.Open();
  
              PdfContentByte cb = writer.DirectContent;
  
              for (int k = 0; k &lt; total; ++k)
              {
                  bmp1.SelectActiveFrame(FrameDimension.Page, k);
  
                  iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(bmp1, ImageFormat.Bmp);
  
                  var scaleparcent = 72f / img.DpiX * 100;
  
                  img.ScalePercent(scaleparcent);
  
                  img.ScaleAbsoluteHeight(document.PageSize.Height);
                  img.ScaleAbsoluteWidth(document.PageSize.Width);
  
                  img.SetAbsolutePosition(0, 0);
  
                  cb.AddImage(img);
  
                  document.NewPage();
  
              }
          }
  
          byte[] bytes = null;
  
          document.Close();
      }
  </code></pre>
  
  <p>some one help please?</p>