首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >RazorPDF编码

RazorPDF编码
EN

Stack Overflow用户
提问于 2013-09-02 08:27:40
回答 1查看 1.1K关注 0票数 0

在使用RazorPDF时,我无法显示希伯来语字符。我想知道是否有可能,或是否有任何其他好的解决方案隐蔽HTML到PDF。最好的方法是指定视图(我正在使用MVC 4)并获得一个PDF文档。

EN

回答 1

Stack Overflow用户

发布于 2013-09-04 07:55:11

对于云,您可以使用iTextSharp库来实现这一点。看看itextsharp.text.html.simpleparser.htmlworker.

其他可靠的方法是使用Ghostscript库(我不确定您是否可以在云中使用它)。您可以首先将Html转换为Postscript,然后将Postscript转换为PDF。

如果您需要.NET最完整的Ghostscript包装器,请查看:Ghostscript.NET

下面是iTextSharp Html的示例:

代码语言:javascript
复制
private MemoryStream createPDF(string html)
{
    MemoryStream msOutput = new MemoryStream();
    TextReader reader = new StringReader(html);

    // step 1: creation of a document-object
    Document document = new Document(PageSize.A4, 30, 30, 30, 30);            

    // step 2:
    // we create a writer that listens to the document
    // and directs a XML-stream to a file
    PdfWriter writer = PdfWriter.GetInstance(document, msOutput);

    // step 3: we create a worker parse the document
    HTMLWorker worker = new HTMLWorker(document);

    // step 4: we open document and start the worker on the document
    document.Open();
    worker.StartDocument();

    // step 5: parse the html into the document
    worker.Parse(reader);

    // step 6: close the document and the worker
    worker.EndDocument();
    worker.Close();
    document.Close();

    return msOutput;
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18568685

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档