The GetDocumentTitle method returns the title of the document that is currently being printed. This function should be called in the message handling loop and will return invalid results as soon as the document finishes printing.
BSTR GetDocumentTitle(long JobID)
void GetDocumentTitle(HANDLE hPrinter, long JobID, LPSTR buf, long MaxBuf)
JobID
Job ID as retrieved by the DOCX message handling function.
hPrinter
Handle to printer returned by any of the DriverInit function calls.
Buf
[out] Address of buffer that will contain the document title.
MaxBuf
This is the Size of the Buf buffer. The document title will be truncated if it is larger than the input buffer.
This method returns the title of the document that is currently being printed.
This function should be called from a DOCX message handling function before the EndDocPost message is sent.
<Flags()> Public Enum acFileNameOptions As Integer ' Please check FileNameOptions for the complete flags version NoPrompt = &H1 UseFileName = &H2 EmbedFonts = &H10 BroadcastMessages = &H20 End Enum ' Define the ActiveX DOCX Object Friend WithEvents DOCX1 As New AxCDIntfEx.AxCDIntfEx Public Sub ActiveXEventHandling() ' Define parent form to the ActiveX Objet DOCX1.Parent = Me ' Constants for Activation codes Const strLicenseTo As String = "DOCX Converter Developer Evaluation" Const strActivationCode As String = "07EFCDAB010001002EE718DAABD90353AA8141F60B6762C695F4D5BA97F516CBE3EB407DC717EC1D28DE39A61F1ACE26924C99AFB190" Const AMYUNIPRINTERNAME As String = "Amyuni DOCX Converter" ' Get a reference to the installed printer. ' This will fail if the printer name passed to the DriverInit method is ' not found in the printer’s folder DOCX1.DriverInit(AMYUNIPRINTERNAME) ' Start Capture of Events DOCX1.CaptureEvents(True) ' The SetDefaultPrinter function sets the system default printer to the one ' initialized by the DriverInit functions. DOCX1.SetDefaultPrinter() ' Resulting DOCX document stored here DOCX1.DefaultDirectory = "C:\Temp" ' Set Printer options, it needs to have BroadcastMessages option DOCX1.FileNameOptionsEx = acFileNameOptions.NoPrompt Or acFileNameOptions.BroadcastMessages ' The EnablePrinter() method needs to be called right before each print job. ' Calling the EnablePrinter() method will start a 20 second time-out value DOCX1.EnablePrinter(strLicenseTo, strActivationCode) ' The BatchConvert method converts a number of files to DOCX. DOCX1.BatchConvert("C:\Temp\*.ppt") ' The RestoreDefaultPrinter function resets the system default printer ' to the printer that was the default before the call to SetDefaultPrinter. DOCX1.RestoreDefaultPrinter() ' Stop Capture of Events DOCX1.CaptureEvents(False) ' Close Printer DOCX1.DriverEnd() ' Destroy DOCX object DOCX = Nothing End Sub Public Sub DOCX1_StartDocPre(sender As Object, e As EventArgs)Handles DOCX1.StartDocPre Dim filename As String = sender.GetGeneratedFilename() MsgBox("Starting Document Preprocess" & Environment.NewLine & "Filename= " & filename) End Sub Public Sub DOCX1_StartDocPost(sender As Object, e As AxCDIntfEx._DCDIntfEvents_StartDocPostEvent) Handles DOCX1.StartDocPost Dim title As String = sender.GetDocumentTitle(e.jobID) MsgBox("Starting Document Postprocess" & Environment.NewLine & "Title= " & title) End Sub Public Sub DOCX1_EndDocPre(sender As Object, e As AxCDIntfEx._DCDIntfEvents_EndDocPreEvent) Handles DOCX1.EndDocPre Dim title As String = sender.GetDocumentTitle(e.jobID) MsgBox("Ending Document Preprocess" & Environment.NewLine & "Title= " & title) End Sub Public Sub DOCX1_EndDocPost(sender As Object, e As AxCDIntfEx._DCDIntfEvents_EndDocPostEvent) Handles DOCX1.EndDocPost MsgBox("Ending Document Postprocess") End Sub Public Sub DOCX1_StartPage(sender As Object, e As AxCDIntfEx._DCDIntfEvents_StartPageEvent) Handles DOCX1.StartPage Dim title As String = sender.GetDocumentTitle(e.jobID) MsgBox("Starting Page" & Environment.NewLine & "Title= " & title) End Sub Public Sub DOCX1_EndPage(sender As Object, e As AxCDIntfEx._DCDIntfEvents_EndPageEvent) Handles DOCX1.EndPage Dim title As String = sender.GetDocumentTitle(e.jobID) MsgBox("Ending Page" & Environment.NewLine & "Title= " & title) End Sub Public Sub DOCX1_EnabledPre(sender As Object, e As EventArgs)Handles DOCX1.EnabledPre MsgBox("Enabling Printer") End Sub
[Flags] public enum acFileNameOptions { NoPrompt = 0x00000001, UseFileName = 0x00000002, EmbedFonts = 0x00000010, BroadcastMessages = 0x00000020, } // Define the ActiveX DOCX Object public AxCDIntfEx.AxCDIntfEx DOCX1; public void ActiveXEventHandling() { // Define ActiveX Objet this.DOCX1 = new AxCDIntfEx.AxCDIntfEx(); ((System.ComponentModel.ISupportInitialize)(this.DOCX1)).BeginInit(); this.DOCX1.StartDocPre += new System.EventHandler(this.StartDocPre); this.DOCX1.StartDocPost += new AxCDIntfEx._DCDIntfEvents_StartDocPostEventHandler(this.StartDocPost); this.DOCX1.EndDocPre += new AxCDIntfEx._DCDIntfEvents_EndDocPreEventHandler(this.EndDocPre); this.DOCX1.EndDocPost += new AxCDIntfEx._DCDIntfEvents_EndDocPostEventHandler(this.EndDocPost); this.DOCX1.StartPage += new AxCDIntfEx._DCDIntfEvents_StartPageEventHandler(this.StartPage); this.DOCX1.EndPage += new AxCDIntfEx._DCDIntfEvents_EndPageEventHandler(this.EndPage); this.DOCX1.EnabledPre += new System.EventHandler(this.EnabledPre); this.Controls.Add(this.DOCX1); ((System.ComponentModel.ISupportInitialize)(this.DOCX1)).EndInit(); // Constants for Activation codes const string strLicenseTo = "DOCX Converter Developer Evaluation"; const string strActivationCode = "07EFCDAB010001002EE718DAABD90353AA8141F60B6762C695F4D5BA97F516CBE3EB407DC717EC1D28DE39A61F1ACE26924C99AFB190"; const string AMYUNIPRINTERNAME = "Amyuni DOCX Converter"; // Get a reference to the installed printer. // This will fail if the printer name passed to the DriverInit method is // not found in the printer’s folder DOCX1.DriverInit(AMYUNIPRINTERNAME); // Start Capture of Events DOCX1.CaptureEvents(Convert.ToSByte(true)); // The SetDefaultPrinter function sets the system default printer to the one // initialized by the DriverInit functions. DOCX1.SetDefaultPrinter(); // Resulting DOCX document stored here DOCX1.DefaultDirectory = "c:\\Temp"; // Set Printer options, it needs to have BroadcastMessages option DOCX1.FileNameOptionsEx =(int)(acFileNameOptions.NoPrompt | acFileNameOptions.BroadcastMessages); // The EnablePrinter() method needs to be called right before each print job. // Calling the EnablePrinter() method will start a 20 second time-out value DOCX1.EnablePrinter(strLicenseTo, strActivationCode); // The BatchConvert method converts a number of files to DOCX. DOCX1.BatchConvert("c:\\Temp\\*.ppt"); // The RestoreDefaultPrinter function resets the system default printer // to the printer that was the default before the call to SetDefaultPrinter. DOCX1.RestoreDefaultPrinter(); // Stop Capture of Events DOCX1.CaptureEvents(Convert.ToSByte(false)); // Close Printer DOCX1.DriverEnd(); // Destroy DOCX object DOCX = null; } public void StartDocPre(object sender, EventArgs e) { String filename = DOCX1.GetGeneratedFilename(); MessageBox.Show("Starting Document Preprocess" + Environment.NewLine + "Filename= " + filename); } public void StartDocPost(object sender, AxCDIntfEx._DCDIntfEvents_StartDocPostEvent e) { String title = DOCX1.GetDocumentTitle(e.jobID); MessageBox.Show("Starting Document Postprocess" + Environment.NewLine + "Title= " + title); } public void EndDocPre(object sender, AxCDIntfEx._DCDIntfEvents_EndDocPreEvent e) { String title = DOCX1.GetDocumentTitle(e.jobID); MessageBox.Show("Ending Document Preprocess" + Environment.NewLine + "Title= " + title); } public void EndDocPost(object sender, AxCDIntfEx._DCDIntfEvents_EndDocPostEvent e) { MessageBox.Show("Ending Document Postprocess"); } public void StartPage(object sender, AxCDIntfEx._DCDIntfEvents_StartPageEvent e) { String title = DOCX1.GetDocumentTitle(e.jobID); MessageBox.Show("Starting Page" + Environment.NewLine + "Title= " + title); } public void EndPage(object sender, AxCDIntfEx._DCDIntfEvents_EndPageEvent e) { String title = DOCX1.GetDocumentTitle(e.jobID); MessageBox.Show("Ending Page" + Environment.NewLine + "Title= " + title); } public void EnabledPre(object sender, EventArgs e) { MessageBox.Show("Enabling Printer"); }