I am using ITextSharp to convert HTML to PDF but i want the PDF to be generated of size 5cm width. I used the following code
var pgSize = new iTextSharp.text.Rectangle(2.05f, 2.05f);
Document doc = new Document(pgSize);
but it is just resizing the pdf and my data disappeared in the pdf or get hide. How can i align the data in the center in PDF or resize the pdf? Here is my code public void ConvertHTMLToPDF(string HTMLCode) {
        try
        {
            System.IO.StringWriter stringWrite = new StringWriter();
            System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
            StringReader reader = new StringReader(HTMLCode);
            var pgSize = new iTextSharp.text.Rectangle(2.05f, 2.05f);                
            Document doc = new Document(pgSize);
            HTMLWorker parser = new HTMLWorker(doc);
            PdfWriter.GetInstance(doc, new FileStream(Server.MapPath("~") + "/App_Data/HTMLToPDF.pdf",
            FileMode.Create));
            doc.Open();
            foreach (IElement element in HTMLWorker.ParseToList(
            new StringReader(HTMLCode), null))
            {
                doc.Add(element);
            }
            doc.Close();
            Response.End();
        }
        catch (Exception ex)
        {
        }
    }