Hi,
I'm evaluating the trial version of Spire.Doc (5.3.46.3020).
I want to batch convert all doc files in a folder to pdf.
code :
Dim di As New IO.DirectoryInfo("c:\doc\subst\")
Dim diar1 As IO.FileInfo() = di.GetFiles("*.doc")
Dim dra As IO.FileInfo
'list the names of all files in the specified directory
Dim doc As New Document()
For Each dra In diar1
doc = New Document()
doc.LoadFromFile(dra.FullName, FileFormat.Doc)
doc.SaveToFile("c:\doc\subst\pdf\" + Mid(dra.Name, 1, InStr(dra.Name, ".") - 1) + ".PDF", FileFormat.PDF)
doc.Close()
Next
The problem I have is that some doc files don't work the the SaveToFile crashes or hangs. I attached one of these files.
Do you have special requirement of doc document ?
I tried with .Net2.0 & .NET3.5 (5.3.46.3035) DLLs.
I also tested version 5.3.83.3035
Here I get these errors in doc QMManualEntry_01_00000101.doc:
1.
System.NotSupportedException was unhandled
Message="Das angegebene Pfadformat wird nicht unterstützt."
Source="mscorlib"
StackTrace:
bei System.Security.Util.StringExpressionSet.CanonicalizePath(String path, Boolean needFullPath)
bei System.Security.Util.StringExpressionSet.CreateListFromExpressions(String[] str, Boolean needFullPath)
bei System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList)
bei System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, String[] pathList, Boolean checkForDuplicates, Boolean needFullPath)
bei System.IO.Path.GetFullPath(String path)
bei Spire.Pdf.PdfDocumentBase.Save(String filename)
bei Spire.Doc.Document.ᜂ(String A_0)
bei Spire.Doc.Document.SaveToFile(String fileName, FileFormat fileFormat)
bei ToPDF.Form1.button1_Click(Object sender, EventArgs e) in C:\VBAA_NET\Doc2PDF\Form1.vb:Zeile 44.
bei System.Windows.Forms.Control.OnClick(EventArgs e)
bei System.Windows.Forms.Button.OnClick(EventArgs e)
bei System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
bei System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
bei System.Windows.Forms.Control.WndProc(Message& m)
bei System.Windows.Forms.ButtonBase.WndProc(Message& m)
bei System.Windows.Forms.Button.WndProc(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
bei System.Windows.Forms.Application.Run(Form mainForm)
bei ToPDF.Program.Main() in C:\VBAA_NET\Doc2PDF\Program.vb:Zeile 12.
bei System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
bei System.Threading.ThreadHelper.ThreadStart_Context(Object state)
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
bei System.Threading.ThreadHelper.ThreadStart()
InnerException:
2.
System.ArgumentException was unhandled
Message="Die Breite oder Höhe des Rechtecks {X=0,Y=0,Width=0,Height=0} kann nicht 0 (null) sein."
Source="System.Drawing"
StackTrace:
bei System.Drawing.Bitmap.Clone(RectangleF rect, PixelFormat format)
bei spr₮.ᜀ(DocPicture A_0)
bei spr₮.ᜀ(DocPicture A_0, sprᵛ A_1, Boolean A_2)
bei spr₮.ᜁ(DocPicture A_0, sprᵛ A_1, Boolean A_2)
bei Spire.Doc.Fields.DocOleObject.Spire.Doc.Layout.IDocumentBase.Draw(spr₮ dc, sprᵛ ltWidget)
bei sprᵛ.ᜀ(spr₮ A_0)
bei sprᵛ.ᜀ(spr₮ A_0)
bei sprᵛ.ᜀ(spr₮ A_0)
bei sprᵛ.ᜀ(spr₮ A_0)
bei sprᵛ.ᜀ(spr₮ A_0)
bei sprᵛ.ᜀ(spr₮ A_0)
bei sprᵛ.ᜀ(spr₮ A_0)
bei sprᵛ.ᜀ(spr₮ A_0)
bei sprᵛ.ᜀ(spr₮ A_0)
bei sprᠦ.ᜀ(spr₮ A_0)
bei sprᲛ.ᜀ(Int32 A_0, Int32 A_1, ImageType A_2, MemoryStream A_3, Boolean A_4, Boolean A_5, Boolean A_6)
bei spr᧥.ᜀ(sprᲛ A_0)
bei spr᧥.ᜀ(Document A_0)
bei Spire.Doc.Document.ᜂ(String A_0)
bei Spire.Doc.Document.SaveToFile(String fileName, FileFormat fileFormat)
bei ToPDF.Form1.button1_Click(Object sender, EventArgs e) in C:\VBAA_NET\Doc2PDF\Form1.vb:Zeile 38.
bei System.Windows.Forms.Control.OnClick(EventArgs e)
bei System.Windows.Forms.Button.OnClick(EventArgs e)
bei System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
bei System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
bei System.Windows.Forms.Control.WndProc(Message& m)
bei System.Windows.Forms.ButtonBase.WndProc(Message& m)
bei System.Windows.Forms.Button.WndProc(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
bei System.Windows.Forms.Application.Run(Form mainForm)
bei ToPDF.Program.Main() in C:\VBAA_NET\Doc2PDF\Program.vb:Zeile 12.
bei System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
bei System.Threading.ThreadHelper.ThreadStart_Context(Object state)
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
bei System.Threading.ThreadHelper.ThreadStart()
InnerException: