Thank you for your response.
I think for my purposes I can use the "DocReportName" since all I need to know is what category this document will belong to so that if there are 2 with the same name they will both belong to the same category anyway.
Now I am running into another problem, I think it has something to do with what you wrote, but I am not exactly sure I understood it:
So if both documents had the same name, the resultant merged print job item would retain the name. Otherwise, the name would be either null or the key would not exist.
The OnHandleDispatched function I am running works fine when I save one document. However when I try to save more than one document the DocReportName is empty for both files. Would you be able to explain why this may be happening?
Here is my basic fucntion:
Code: Select all
Protected Overloads Overrides Function OnHandleDispatched(ByVal printJob As IPrintJob) As Boolean
If TryCast(printJob.Properties(PrintJobProperty.Targets), List(Of String)).Contains([Enum].GetName(GetType(PrintJobTarget), PrintJobTarget.Publish)) Then
'first get the firmfile and username
Dim order As SoftPro.OrderTracking.Client.IOrder = TryCast(printJob.Properties("Order"), SoftPro.OrderTracking.Client.IOrder)
Dim firmfile As String = order.Number
Dim currentUser As String = order.CurrentUser.UserName
'get the connection string
Dim strConnect As String = My.Settings.ConnectionString
strSQL = "Select PDFLoc from controlrecord"
Dim oData As New clsData
Dim pdfLoc As String = oData.GetDataReader(strConnect, strSQL, "PDFLoc")
'rip through the individual items in the print job
For Each item As IPrintJobItem In printJob.Items
Dim fi As FileInfo = TryCast(item.Properties("FileLocation"), FileInfo)
''''''''''''''''''This line of code is bringing up empty string when there are more t han one document'''''''''''''''''
Dim desc As String = TryCast(item.Properties("DocReportName"), String)
Dim fileName As String = DateTime.Now.Millisecond & fi.Name
Dim numPages As Integer = GetNoOfPagesPDF(fi.FullName)
File.Move(fi.FullName, pdfLoc & fileName)
Next
MsgBox("Your document(s) have been published to the web successfully.")
Return True
End If
'allow the pipeline to continue
Return False
End Function