title: How to add multiple fpages to fixed document in xps?
body: <p>My requirement is to create xps document which has 10 pages (say). I am using the following code to create a xps document. Please take a look.</p>
  
  <pre><code>// Create the new document
          XpsDocument xd = new XpsDocument("D:\\9780545325653.xps", FileAccess.ReadWrite);
  
          IXpsFixedDocumentSequenceWriter xdSW = xd.AddFixedDocumentSequence();
  
          IXpsFixedDocumentWriter xdW = xdSW.AddFixedDocument();
  
          IXpsFixedPageWriter xpW = xdW.AddFixedPage();
  
              fontURI = AddFontResourceToFixedPage(xpW, @"D:\arial.ttf");
  
              image = AddJpegImageResourceToFixedPage(xpW, @"D:\Single content\20_1.jpg");
  
              StringBuilder pageContents = new StringBuilder();
  
              pageContents.Append(ReadFile(@"D:\Single content\20.fpage\20.fpage", i));
  
              xmlWriter = xpW.XmlWriter;
              xmlWriter.WriteRaw(pageContents.ToString());               
          }
          xmlWriter.Close();
          xpW.Commit();
  
          // Commit the fixed document
          xdW.Commit();
          // Commite the fixed document sequence writer
          xdSW.Commit();
          // Commit the XPS document itself
          xd.Close();
  
      }
  
      private static string AddFontResourceToFixedPage(IXpsFixedPageWriter pageWriter, String fontFileName)
      {
          string fontUri = "";
          using (XpsFont font = pageWriter.AddFont(false))
          {
              using (Stream dstFontStream = font.GetStream())
              using (Stream srcFontStream = File.OpenRead(fontFileName))
              {
                  CopyStream(srcFontStream, dstFontStream);
  
                  // commit font resource to the package file
                  font.Commit();
              }
              fontUri = font.Uri.ToString();
          }
          return fontUri;
      }
  
      private static Int32 CopyStream(Stream srcStream, Stream dstStream)
      {
          const int size = 64 * 1024; // copy using 64K buffers
          byte[] localBuffer = new byte[size];
          int bytesRead;
          Int32 bytesMoved = 0;
  
          // reset stream pointers
          srcStream.Seek(0, SeekOrigin.Begin);
          dstStream.Seek(0, SeekOrigin.Begin);
  
          // stream position is advanced automatically by stream object
          while ((bytesRead = srcStream.Read(localBuffer, 0, size)) &gt; 0)
          {
              dstStream.Write(localBuffer, 0, bytesRead);
              bytesMoved += bytesRead;
          }
          return bytesMoved;
      }
  
      private static string ReadFile(string filePath,int i)
      {
  
          FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.ReadWrite);
  
          StringBuilder sb = new StringBuilder();
          using (StreamReader sr = new StreamReader(fs))
          {
              String line;
              // Read and display lines from the file until the end of 
              // the file is reached.
              while ((line = sr.ReadLine()) != null)
              {
                  sb.AppendLine(line);
              }
          }
          string allines = sb.ToString();
  
          //allines = allines.Replace("FontUri=\"/Resources/f7728e4c-2606-4fcb-b963-d2d3f52b013b.odttf\"", "FontUri=\"" + fontURI + "\" ");
  
          //XmlReader xmlReader = XmlReader.Create(fs, new XmlReaderSettings() { IgnoreComments = true });
  
          XMLSerializer serializer = new XMLSerializer();
  
          FixedPage fp = (FixedPage)serializer.DeSerialize(allines, typeof(FixedPage));
  
          foreach (Glyphs glyph in fp.lstGlyphs)
          {
              glyph.FontUri = fontURI;
          }
  
          fp.Path.PathFill.ImageBrush.ImageSource = image;
  
          fs.Close();
  
          string fpageString = serializer.Serialize(fp);
  
  
  
          return fpageString;
      }
  
      private static string AddJpegImageResourceToFixedPage(IXpsFixedPageWriter pageWriter, String imgFileName)
      {
          XpsImage image = pageWriter.AddImage("image/jpeg");
          using (Stream dstImageStream = image.GetStream())
          using (Stream srcImageStream = File.OpenRead(imgFileName))
          {
              CopyStream(srcImageStream, dstImageStream); // commit image resource to the package file 
              //image.Commit();
          }
  
          return image.Uri.ToString();
  
      }
  </code></pre>
  
  <p>If you see it, i would have passed single image and single fpage to create a xps document. I want to pass multiple fpages list and image list to create a xps document which has multiple pages..?</p>