title: iTextSharp - PDF - Resize Document to Accommodate a Large Image
body: <p>I'm using iTextSharp to convert large images to PDF documents.</p>
  
  <p>This works, but the images appear cropped, because they exceed boundaries of the generated document.</p>
  
  <p>So the question is - how to make the document same size as the image being inserted into it? </p>
  
  <p>I'm using the following code:</p>
  
  <pre><code>  Document doc = new Document(PageSize.LETTER.Rotate());
    try
    {
       PdfWriter.GetInstance(doc, new FileStream(saveFileDialog1.FileName,FileMode.Create));
       doc.Open();
       doc.Add(new Paragraph());
       iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(imagePath);
       doc.Add(img);
     }
     catch
     {
        // add some code here incase you have an exception
     }
     finally
     {
        //Free the instance of the created doc as well
        doc.Close();
     }
  </code></pre>