我正在尝试从.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
''****************************************************************************
我最终只是编写了一个脚本来将文件复制到新位置并手动更改它们的名称。 由于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