【问题标题】:Work around for WebBrowser.Print() and IE's failure to pass webpage title (.NET)解决 WebBrowser.Print() 和 IE 无法通过网页标题 (.NET) 的问题
【发布时间】:2014-12-10 00:33:20
【问题描述】:

我正在尝试从 .NET 应用程序批量打印 XML,并自动创建名称与网页标题相同的文件。但是 IE 拒绝将 html 网页的内容传递给 PFDCreator 的自动保存。它总是以标题作为 URL 结束。从 Firefox 手动打印时这不是问题,但 Visual Studio 使用 IE 包装器。任何解决方法的建议将不胜感激......

这是我目前的打印子:

''****************************************************************************

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

   If ListBox1.Items.Count > 0 Then
        Dim wb As New WebBrowser
        For Each file In OpenFileDialog1.FileNames
            wb.Navigate(file)
            Do Until wb.ReadyState = WebBrowserReadyState.Complete
                Application.DoEvents()
            Loop
            wb.Print()
       Next
        wb.Dispose()
   End If
    MsgBox("Printing Finished. " & FilesPrinted & " files printed")
End Sub

''****************************************************************************

【问题讨论】:

    标签: xml vb.net visual-studio-2010 pdf xslt


    【解决方案1】:

    我最终只是编写了一个脚本来将文件复制到新位置并手动更改它们的名称。因为 IE 传递了源文件名,这对我的使用来说已经足够了。

    其他仅供参考,这个问题是在微软论坛上提出的,似乎是另一个缺少 IE 的案例:

    http://answers.microsoft.com/en-us/ie/forum/ie11-windows_7/print-to-pdf-use-title-instead-of-url/b7578eae-b31a-4950-9db6-6cf845323d92?tab=question&status=AllReplies&status=AllReplies

    http://answers.microsoft.com/en-us/ie/forum/ie8-windows_xp/filenames-when-printing-to-a-pdf-driver/e5541ba9-d545-e011-9577-d485645a8348

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-09-03
      • 2019-04-26
      • 2011-11-24
      • 2019-06-10
      • 1970-01-01
      • 1970-01-01
      • 2018-05-24
      • 1970-01-01
      相关资源
      最近更新 更多