Bartender.print.messages Error While Exporting Printpreview To File 追蹤

0
Avatar
Legacy Poster

Hello,

 

Attached is my code that has been working for some time. Then today it will not export my print preview, it does so intermittently. I break the program to see what the parameters are and found an error message (does not throw an exception):

 

Item = In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user.
Item = Argument not specified for parameter 'index' of 'Public ReadOnly Default Property Item(index As Integer) As Seagull.BarTender.Print.Message'.

 

I'm not sure how to fix this.

The user selects a Label from a listbox of loaded formats. I then call the background worker and pass it btFormat which is an index of one of the formats loaded in the engine.

btFormat = btEngine.Documents.Item(lstlabels.SelectedIndex) 'Set the name of the label to open based on lstLabels
btFormat.Activate()     'Make the format active in btEngine
 
' Preview the BarTender format.
            backgroundWorker.RunWorkerAsync(btFormat)

Code from my background worker

Private Sub ShowPreview()
      
        Dim filename As String = String.Format("{0}\{1}1.jpg", previewPath, btFormat.BaseName)

       
        'Set File Location and show Preview in picbox
        picPreview.ImageLocation = filename  'prename  
        picPreview.Visible = True
        btnPrint.Enabled = True
        btnPreview.Enabled = True
    End Sub

    Private Sub backgroundWorker_DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs) Handles backgroundWorker.DoWork
        Dim format As LabelFormatDocument = CType(e.Argument, LabelFormatDocument)
        Dim prename As String = btFormat.BaseName & ".jpg"

        Try


            ' Export the format's print previews.
            format.ExportPrintPreviewToFile(previewPath, prename, ImageType.JPEG, Seagull.BarTender.Print.ColorDepth.ColorDepth24bit,
                                            New Resolution(picPreview.Width, picPreview.Height), System.Drawing.Color.White, OverwriteOptions.Overwrite,
                                            True, True, messages)
           

        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try


    End Sub

    ''' We are done exporting the preview, so let's show any messages
    ''' and display the label.

    Private Sub backgroundWorker_RunWorkerCompleted(ByVal sender As Object, ByVal e As RunWorkerCompletedEventArgs) Handles backgroundWorker.RunWorkerCompleted
        Try
            ShowPreview()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try



    End Sub

Thanks again

2 意見

0
Avatar
Legacy Poster
評論操作 永久連結

Just a thought...I set a breakpoint on the call to the background thread and checked the visualizer for btFormat, At the bottom of the log I found this message...

 

The ExportPrintPreviewToFile method requires Enterprise Automation edition. The
BarTender {0} edition is currently installed.

 

could this be causing the issue, since the code worked fine before, even today. It does not work now.

 

Thanks again.

0
Avatar
Legacy Poster
評論操作 永久連結

As it turns out I slept on it and decided to check the messages with code...found a bit in the sample files..And my new found error was due to me assigning the printer programmatically, when I bulk load my formats. I now have seven printer names that are invalid since they are not connected to my development machine, only 1 is.

 

Just thought I'd share...

 

 Private Sub backgroundWorker_RunWorkerCompleted(ByVal sender As Object, ByVal e As RunWorkerCompletedEventArgs) Handles backgroundWorker.RunWorkerCompleted
        Try
            If messages IsNot Nothing Then

                If messages.Count > 5 Then
                    MessageBox.Show(Me, "There are more than 5 messages from the print preview. Only the first 5 will be displayed.", appName)
                End If
                Dim count As Integer = 0

                For Each message As Seagull.BarTender.Print.Message In messages
                    MessageBox.Show(Me, message.Text, appName)
                    ' if (++count >= 5)
                    count += 1
                    If count >= 5 Then
                        Exit For
                    End If
                Next message
            End If
            ShowPreview()

        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try



    End Sub

登入寫評論。