如何在从HTML转换为PDF时更改pdf内容的字体 [英] How to change font of the pdf content when converting from HTML to PDF

查看:522
本文介绍了如何在从HTML转换为PDF时更改pdf内容的字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是转换的代码。



Here is the code for the convertion.

 Public Shared Function ExportHTM()
    Dim sbytes As [Byte]()
        Using mstream = New MemoryStream()
            Using PDF = New Document(iTextSharp.text.PageSize.A4, 5, 5, 15, 5)
                Using writer = PdfWriter.GetInstance( PDF, mstream )
                   PDF.Open()
                    Using StringWriter= New StringWriter()
                        Using HtmlTextWriter = New HtmlTextWriter(StringWriter)
              'How to apply  font and styles to pdfcontent' -- PDF content is a string and it contains html content
                            Using StringReader = New StringReader(pdfcontent)
                                Using htmlparser = New HTMLWorker( PDF)
                                    htmlparser.Parse(StringReader)
                                End Using
                            End Using
                        End Using
                    End Using
                    PDF.Close()
                End Using
            End Using
            sbytes = mstream.ToArray()
           mstream.Close()
        End Using
END function







有人可以帮助我如何将样式应用于pdfcontent?




Can anybody help me how can I apply styles to the pdfcontent?

推荐答案

使用字体 &安培; FontFactory 这个类。

见这个, iTextSharp - 使用字体 [ ^ ]。博客使用C#,但肯定可以从中得到这个想法。



-KR
Use Font & FontFactory classes for that.
See this, iTextSharp - working with fonts[^]. Blog uses C#, but certainly can get the idea from this.

-KR


你可以使用iTextSharp - 使用字体 [ ^ ]。
You could use iTextSharp - Working with Fonts[^].


这篇关于如何在从HTML转换为PDF时更改pdf内容的字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆