GetGeneratedFilename

The GetGeneratedFilename method returns the full path of the file that is currently being generated. This function should be called in the message handling loop and will return invalid results as soon as the processing of StartDoc is finished.

 

Syntax

ActiveX:

BSTR GetGeneratedFilename()

DLL:

void GetGeneratedFilename(HANDLE hPrinter, LPSTR Buf, int MaxBuf)

 

Parameters

hPrinter

Handle to printer returned by any of the DriverInit function calls.

Buf

[out] Address of buffer that will contain the file name.

MaxBuf

Size of the Buf buffer. The file name will be truncated if it is larger than the input buffer.

 

Return Value

This method returns the full path of the file that is currently being generated.

 

Remarks

This function should be called from a DOCX message handling function before the StartDocPost message is sent, i.e. in the StartDocPre event handler.

 

Example

<Flags()>
Public Enum acFileNameOptions As Integer
    ' Please check FileNameOptions for the complete flags version
    NoPrompt = &H1
    UseFileName = &H2
    Concatenate = &H4
    DisableCompression = &H8
    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
    DOCX1 = 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,
    Concatenate = 0x00000004,
    DisableCompression = 0x00000008,
    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(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(false);
 
    // Close Printer
    DOCX1.DriverEnd();
 
    // Destroy DOCX object
    DOCX1 = 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");
}