Tell abcPdf to scale the html to fit on a single pdf page

前端 未结 3 1577
孤街浪徒
孤街浪徒 2021-01-03 01:27

I am using abcPdf to convert an HTML report into a pdf file. The pdf has to be a single landscape A4 page.

Do you know if there is any way to tell abcPdf to scale th

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-03 02:16

    This might be a bit simpler

        /// 
        /// Calculate the height of given html
        /// 
        /// 
        /// 
        public int CalculateHeight(string html)
        {
            int id = _Document.AddImageHtml(html);
            int height = (int)(_Document.GetInfoInt(id, "ScrollHeight") * PixelToPointScale);
            _Document.Delete( id );
            return height;
        }
    

    [edit] Well scrollHeight fails with ver8 this works though

        private int AddImageHtml(string html)
        {
            try
            {
                return _Document.AddImageHtml("
    " + html + "
    "); } catch (Exception ex) { throw new Exception(html, ex); } } private double GetElementHeight(int id) { abcpdf.XRect[] tagRects = _Document.HtmlOptions.GetTagRects(id); string[] tagIds = _Document.HtmlOptions.GetTagIDs(id); for (int i=0;i

提交回复
热议问题