简体   繁体   中英

iTextSharp - Improve HTML Image

I have a routine that prints a PDF of HTML code. It works very well except the embedded image DPI is too low, so the resolution is very poor. Is there a way I can set the stylesheet to use a higher DPI?

    HTMLWorker parser = new HTMLWorker(doc);

    string fontpath = Server.MapPath("/Fonts/arialuni.ttf");
    FontFactory.Register(fontpath, "Arial Unicode MS");

    StyleSheet styles = new StyleSheet();
    styles.LoadTagStyle(HtmlTags.TABLE, HtmlTags.SIZE, "6pt");
    styles.LoadTagStyle(HtmlTags.H3, HtmlTags.SIZE, "10pt");
    styles.LoadTagStyle(HtmlTags.H5, HtmlTags.SIZE, "6pt");
    styles.LoadTagStyle(HtmlTags.BODY, HtmlTags.FACE, "Arial Unicode MS");
    styles.LoadTagStyle(HtmlTags.BODY, HtmlTags.ENCODING, BaseFont.IDENTITY_H);

    parser.SetStyleSheet(styles);

HTML code -

div style="text-align: left; margin-left:40px;">
    <table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2">
        <tbody>
            <tr>
                <td style="width: 141px;"><img alt="" src="http://ephoms-prod.azurewebsites.net/images/eph_graphics/eph_logo_small.png"/></td>
                <td style="text-align: center;"><h4>Order Summary</h4></td>
            </tr>
        </tbody>
    </table>
</div>

更改图像尺寸解决了我的问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM