我知道有好几个人问过这样的问题,但没有人回答我的问题。
嗯,我有xsl
和 xml
并想要生成 pdf
使用像 Apache.FOP 这样的处理器。
我无法使用任何 JAVA
程序之类的。只能使用 C# 库/exe。
我尝试使用 nFop
:
- 1.x 版使用 Java.io 和..
- 2.0 版无法设置 XsltSettings
我当前的软件使用 XSL + XML -> HTML
(在 C# 上使用标准 Stystm.Xml.Xsl
)和 wktmltopdf
生成 PDF
从创建HTML
.
但是当表格对于页面而言太长时,表格会被拆分,并且在下一页上您没有任何列标题(这对我的问题非常重要)。
我认为没有针对纯 C 的免费 FO 处理器
最佳答案
看看FoNET .
public static bool XMLToPDF(string pXmlFile, string pXslFile, string pFoFile, string pPdfFile)
{
string lBaseDir = System.IO.Path.GetDirectoryName(pXslFile);
XslCompiledTransform lXslt = new XslCompiledTransform();
lXslt.Load(pXslFile);
lXslt.Transform(pXmlFile, pFoFile);
FileStream lFileInputStreamFo = new FileStream(pFoFile, FileMode.Open);
FileStream lFileOutputStreamPDF = new FileStream(pPdfFile, FileMode.Create);
FonetDriver lDriver = FonetDriver.Make();
lDriver.BaseDirectory = new DirectoryInfo(lBaseDir);
lDriver.CloseOnExit = true;
lDriver.Render(lFileInputStreamFo, lFileOutputStreamPDF);
lFileInputStreamFo.Close();
lFileOutputStreamPDF.Close();
return System.IO.File.Exists(pPdfFile);
}
关于c# - XSL + XML -> 用于 C# 的 PDF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26887432/