I have a really simple VB .NET application similar to the COM samples that is supposed to generate a PDF document and auto save it to a particular location. When I run the app, it runs to completion but never triggers the PDFCreator eReady event. It just opens PDFCreator and shows the dialog. When it does this, the Printer Stop is checked by default and if I uncheck it (or hit F2) the file prints and saves correctly. Is there any way to shut that Printer Stop setting off completely?
Hi,
could you post your code, then we can take a look at what could be causing this.
regards,
Robin
Well, yes...but it's just the sample .NET code modified to use the autosave feature. It will occasionally work, but most of the time it functions as I described first time around.
Public
Class Form1Inherits System.Windows.Forms.FormPrivate WithEvents PDFJob As PDFCreator.clsPDFCreatorPrivate pErr As PDFCreator.clsPDFCreatorErrorDim pd As System.Drawing.Printing.PrintDocumentRegion " Windows Form Designer generated code "Public Sub New()MyBase.New()'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Button1 As System.Windows.Forms.ButtonPrivate Sub InitializeComponent()Me.Button1 = New System.Windows.Forms.ButtonMe.SuspendLayout()'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(72, 40)Me.Button1.Name = "Button1"Me.Button1.Size = New System.Drawing.Size(120, 48)Me.Button1.TabIndex = 0Me.Button1.Text = "Button1"'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)Me.ClientSize = New System.Drawing.Size(496, 262)Me.Controls.Add(Me.Button1)Me.Name = "Form1"Me.Text = "Form1"Me.ResumeLayout(False)End Sub
#
End Region
MsgBox("Status: """ & PDFJob.cOutputFilename & """ was created!")
PDFJob.cPrinterStop =
Private Sub PDFCreator_eReady() Handles PDFJob.eReadyTrueEnd Sub
pErr = PDFJob.cError
MsgBox("Status: Error[" & pErr.Number & "]: " & pErr.Description)
Private Sub PDFJob_eError() Handles PDFJob.eErrorEnd Sub
PDFJob =
pErr =
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.LoadNew PDFCreator.clsPDFCreatorNew PDFCreator.clsPDFCreatorErrorIf Not PDFJob.cStart("/NoProcessingAtStartup") Then
MsgBox("[PDFCreator] ERROR: " & pErr.Number & " - " & pErr.Description)
Exit Sub
Else
PDFJob.cOption("UseAutosave") = 1
PDFJob.cOption("UseAutosaveDirectory") = 1
PDFJob.cOption("AutosaveDirectory") = "C:\\PDFTest"
PDFJob.cOption("AutosaveFilename") = "SOMEFILENAME.PDF"
PDFJob.cOption("AutosaveFormat") = 0
' 0 = PDFPDFJob.cClearCache()
PDFJob.cClearLogfile()
PDFJob.cErrorClear()
PDFJob.cSaveOptions()
End If
End Sub
PDFJob.cClose()
Application.DoEvents()
System.Threading.Thread.Sleep(100)
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.ClosingWhile (PDFJob.cProgramIsRunning)End While
pErr =
NothingPDFJob =
NothingGC.Collect()
End Sub
pd =
pd.PrinterSettings.PrinterName = "PDFCreator"
pd.DocumentName = "PDFCreator Dot Net - Sample2"
pd.Print()
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.ClickNew System.Drawing.Printing.PrintDocumentAddHandler pd.PrintPage, AddressOf pd_PrintPageMe.Close()End Sub
Private Sub pd_PrintPage(ByVal sender As Object, ByVal ev As System.Drawing.Printing.PrintPageEventArgs)Dim x As Single, y As Single, r As Single
x = .Width / 2
y = .Height / 2
r = .Width / 4
With pd.PrinterSettings.DefaultPageSettings.PaperSizeEnd With
DrawCircles(x - r / 2, y - r / 2, r, 5, ev)
End Sub
Private Sub DrawCircles(ByVal x As Single, ByVal y As Single, ByVal r As Single, ByVal rec As Long, ByVal ev As System.Drawing.Printing.PrintPageEventArgs)If rec <> 0 Then
.DrawString("PDFCreator",
.DrawEllipse(p, x - r, y, r, r)
.DrawEllipse(p, x + r, y, r, r)
.DrawEllipse(p, x, y - r, r, r)
.DrawEllipse(p, x, y + r, r, r)
.DrawEllipse(p, x, y, r, r)
Dim p As New Pen(Color.Red)With ev.GraphicsNew Font("Arial", 16), Brushes.Black, 100, 100, New StringFormat)End With
DrawCircles(x - r / 2, y - r / 2, r / 2, rec - 1, ev)
DrawCircles(x - r / 2, y + r, r / 2, rec - 1, ev)
DrawCircles(x + r, y - r / 2, r / 2, rec - 1, ev)
DrawCircles(x + r, y + r, r / 2, rec - 1, ev)
End If
End
End Sub Class
#