title: Custom page size in PDFsharp
body: <p>Using PDFsharp .NET library, I need to set the page size in the PDF document same as that of the images.</p>
  
  <p>Example, image no. 1 measures 152px x 1775px.
  Image no. 2 measures 100px x 1582px</p>
  
  <p>The resulting PDF should have varying page size inside.</p>
  
  <p>Please help.</p>
  
  <p>With the following code, I am able to set the size of the images, the problem is now setting the page size.</p>
  
  <pre><code>PdfDocument doc = new PdfDocument();
  //doc.Pages.Add(new PdfPage());
  PdfPage page = doc.AddPage();
  
  XGraphics gfx = XGraphics.FromPdfPage(doc.Pages[0]);
  
  XImage xImage = XImage.FromFile(source);
  gfx.DrawImage(xImage, 0, 0, xImage.PixelWidth, xImage.PixelHeight);
  
  doc.Save(destinaton);
  doc.Close();
  // 
  </code></pre>