Yanor.net/
Wiki
Blog
GitHub
Sandbox
開始行:
* XMLWorker [#b004f80a]
** 概要 [#oa7bf0e6]
- HTMLのParseHtml()は上手く動かない事がある?
Unable to cast object of type 'iTextSharp.text.html.simp...
- HTMLWorkerはすでにdeprecatedなので、XMLWorkerを使う。
** コード [#sdcae9d3]
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.tool.xml;
using System.IO;
public class HtmlToPdf
{
private const string JapaneseFontName = "c:\\windows...
public static byte[] ConvertHtmlToPdf(string html)
{
MemoryStream output = new MemoryStream();
using (var document = new Document(PageSize.A4, ...
using (var writer = PdfWriter.GetInstance(docume...
{
document.Open();
var fontname = JapaneseFontName;
var fontProvider = new XMLWorkerFontProvider...
fontProvider.Register(fontname, "Serif");
var cssText = @"body {font-family: Serif;}";
using (var cssMS = new MemoryStream(System.T...
using (var htmlMS = new MemoryStream(System....
{
var xmlWorker = XMLWorkerHelper.GetInsta...
xmlWorker.ParseXHtml(writer, document, h...
}
document.Close();
}
return output.ToArray();
}
}
** 参考 [#f2e53114]
- http://sourceforge.net/projects/itextsharp/files/xmlwor...
- http://stackoverflow.com/questions/21106710/applying-st...
- http://stackoverflow.com/questions/16101481/use-externa...
- http://stackoverflow.com/questions/15354005/html-to-lis...
- http://stackoverflow.com/questions/12113425/itextsharp-...
終了行:
* XMLWorker [#b004f80a]
** 概要 [#oa7bf0e6]
- HTMLのParseHtml()は上手く動かない事がある?
Unable to cast object of type 'iTextSharp.text.html.simp...
- HTMLWorkerはすでにdeprecatedなので、XMLWorkerを使う。
** コード [#sdcae9d3]
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.tool.xml;
using System.IO;
public class HtmlToPdf
{
private const string JapaneseFontName = "c:\\windows...
public static byte[] ConvertHtmlToPdf(string html)
{
MemoryStream output = new MemoryStream();
using (var document = new Document(PageSize.A4, ...
using (var writer = PdfWriter.GetInstance(docume...
{
document.Open();
var fontname = JapaneseFontName;
var fontProvider = new XMLWorkerFontProvider...
fontProvider.Register(fontname, "Serif");
var cssText = @"body {font-family: Serif;}";
using (var cssMS = new MemoryStream(System.T...
using (var htmlMS = new MemoryStream(System....
{
var xmlWorker = XMLWorkerHelper.GetInsta...
xmlWorker.ParseXHtml(writer, document, h...
}
document.Close();
}
return output.ToArray();
}
}
** 参考 [#f2e53114]
- http://sourceforge.net/projects/itextsharp/files/xmlwor...
- http://stackoverflow.com/questions/21106710/applying-st...
- http://stackoverflow.com/questions/16101481/use-externa...
- http://stackoverflow.com/questions/15354005/html-to-lis...
- http://stackoverflow.com/questions/12113425/itextsharp-...
ページ名: