So I've written a little wrapper utility that allows a user to select multiple Word Documents, and then convert each of them into a separate pdf file. I used the .NET samples as a guide. My code is below:
Dim fileinfo As System.IO.FileInfo
Dim sFile As RadListDataItem
Dim sPDF As String
Dim opt As PDFCreator.clsPDFCreatorOptions = pdfCreator.cOptions
Dim DefaultPrinter As String
For Each sFile In radFileList.Items
fileinfo = My.Computer.FileSystem.GetFileInfo(sFile.Value.ToString)
sPDF = fileinfo.Name.Replace(".docx", "")
sPDF = sPDF.Replace(".doc", "")
With opt
.UseAutosave = 1
.UseAutosaveDirectory = 1
.AutosaveDirectory = txtSaveLocation.Text
.AutosaveFormat = 0
.AutosaveFilename = sPDF
.RemoveAllKnownFileExtensions = 0
End With
If My.Computer.FileSystem.FileExists(txtSaveLocation.Text & "\\" & sPDF & ".pdf") Then
My.Computer.FileSystem.DeleteFile(txtSaveLocation.Text & "\\" & sPDF & ".pdf")
End If
With pdfCreator
.cOptions = opt
.cClearCache()
DefaultPrinter = .cDefaultPrinter
.cDefaultPrinter = "PDFCreator"
.cPrinterStop = True
.cPrintFile(fileinfo.FullName)
ReadyState = False
.cPrinterStop = False
With Timer1
.Interval = maxTime * 1000
.Enabled = True
Do While Not ReadyState And .Enabled
System.Windows.Forms.Application.DoEvents()
Loop
.Enabled = False
End With
pdfCreator.cPrinterStop = True
pdfCreator.cDefaultPrinter = DefaultPrinter
.cDefaultPrinter = DefaultPrinter
End With
Next
When selecting 40 charts - sometimes all 40 will generate - sometimes its only 37, sometimes its 39, etc. Its not the specific files, because its not a file that always causes the problem.
Any ideas? I'm super stuck, and when I step through the code, it seems to work fine, which leads me to think its a timing issue, but I don't know what else to do.