[英]Extracting XML from XMLFormView
有沒有辦法讓 XML 出現在 XMLFormView 中? 我正在嘗試為 InfoPath 表單創建一個帶有“另存為 PDF”按鈕的自定義 web 部件。 想法是將 XML 與表單的 XSL 結合起來,並將生成的 HTML 轉換為 PDF,並作為彈出窗口呈現給用戶。
因為它要以彈出窗口的形式呈現,所以不能選擇使用 Workflows。
此屬性將為您提供基礎 XML 文件的 Url。 您可以閱讀 Stream 閱讀器來閱讀此 XML。
看看我的 codeplex 項目http://ip2html.codeplex.com/
它允許您從給定的 (InfoPath) XML & (XMLFormView) XSLT 生成 HTML。
We ended up using the XmlFormHostItem.NotifyHost
method to send HTML to a custom web part in a button-clicked event, which converted the HTML to PDF using Winnovative HTML to PDF converter.
HTML 從 InfoPath 代碼隱藏生成:
var formData = new XmlDocument();
var xslt = new XslCompiledTransform(true);
// Load the form data
formData.LoadXml(MainDataSource.CreateNavigator().InnerXml);
// Extract the stylesheet from the package
xslt.Load(ExtractFromPackage("Print.xsl")); // (uses Template.OpenFileFromPackage(string fileName) to get xsl)
// Perform XSL-transformation
// [...]
// Send HTML to web part
this.NotifyHost(formData.InnerXml);
此方法的一個缺點是每個表單僅觸發一次 NotifyHost 事件,因此如果用戶單擊“另存為 PDF”然后取消,他必須重新加載表單才能保存為 PDF。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.