title: Read a PDF file and return as stream from a WCF service?
body: <p>I want to create a WCF service (working like windows service). This service will read a PDF file from a specific path, extract pages, create a new PDF file and return it to the caller.</p>
  
  <p>How can I do this ? I use QuickPDF to process on PDF files, I can extract and create new PDF file. How can use this in a WCF service ?</p>
  
  <p>Waiting your helps...</p>
  
  <p>This is only sample code :</p>
  
  <pre><code>public Stream ExtractPdf(string PathOfOriginalPdfFile, int StartPage,int PageCount)
  {
          PDFLibrary qp = new PDFLibrary();
          Stream Stream_ = null;
  
          if (qp.UnlockKey(".................") == 0)
          {
              string fileName = @"..\..\Test Files\sample1.pdf";
              string OutputFile = @"..\..\Test Files\sample1_extracted.pdf";
  
              if (qp.Unlocked() == 1)
              {
  
                  int docID = qp.LoadFromFile(fileName, "");
  
                  int extractPageSuccess = qp.ExtractPages(StartPage, PageCount);
  
                  if (extractPageSuccess == 0)
                  {
                      // error
                  }
                  else
                  {
                      qp.SaveToFile(OutputFile);
                  }
              }
          }
  
          //
          // Codes here
          //
          return Stream_;
      }
  </code></pre>
  
  <p>I edited it :</p>
  
  <pre><code> public byte[] ExtractPdf(string PathOfOriginalPdfFile, int StartPage,int PageCount)
      {
  
          QuickPDFDLL0815.PDFLibrary qp = new QuickPDFDLL0815.PDFLibrary(@"C:\Program Files (x86)\Quick PDF Library\DLL\QuickPDFDLL0815.dll");
  
          string fileName = @"..\..\Test Files\sample1.pdf";
          byte[] binFile = null;
  
          if (qp.UnlockKey("...................") == 0)
          {
  
  
              if (qp.Unlocked() == 1)
              {
  
                  int docID = qp.LoadFromFile(fileName, "");
  
                  int extractPageSuccess = qp.ExtractPages(StartPage, PageCount);
  
                  if (extractPageSuccess == 0)
                  {
                      // error
                  }
                  else
                  {
                     binFile = qp.SaveToString();
                  }
              }
          }
  
          return binFile;
      }
  </code></pre>