在使用RazorPDF时,我无法显示希伯来语字符。我想知道是否有可能,或是否有任何其他好的解决方案隐蔽HTML到PDF。最好的方法是指定视图(我正在使用MVC 4)并获得一个PDF文档。
发布于 2013-09-04 07:55:11
对于云,您可以使用iTextSharp库来实现这一点。看看itextsharp.text.html.simpleparser.htmlworker.
其他可靠的方法是使用Ghostscript库(我不确定您是否可以在云中使用它)。您可以首先将Html转换为Postscript,然后将Postscript转换为PDF。
如果您需要.NET最完整的Ghostscript包装器,请查看:Ghostscript.NET。
下面是iTextSharp Html的示例:
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;
}https://stackoverflow.com/questions/18568685
复制相似问题