New User - Product Demo

The Amyuni PDF Converter is our Printer Driver that enables you to convert any documents to PDF format. If you have any questions about installing and using the Amyuni PDF Converter please post them here.
Post Reply
SupaHoopsa
Posts: 1
Joined: Fri Oct 29 2004

New User - Product Demo

Post by SupaHoopsa »

I have just found this product on the Internet and it looks like it will suit my requirements perfectly.

However, I am trying to create a simple demo to show my management team and I am struggling !!

I have attached a simple VB.NET project, with the idea being that the user can open a file and then simply click on the convert button and a PDF rendition of the document will be created. The project seems to run OK, but it doesn't seem to create the PDF document.

Code: Select all

Public Class frmPDFConv
    Inherits System.Windows.Forms.Form

    Const PDFPrinter As String = "Amyuni PDF Converter"
    Const NoPrompt As Long = 1
    Const DocTitleWord As String = "Word.doc"
    Const UseFileName As Long = 2
    Private PDFConv As CDIntfEx.CDIntfEx
    Private strPathName As String

#Region " 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

        'Initialise PDF printer
        PDFConv = New CDIntfEx.CDIntfEx
        PDFConv.DriverInit(PDFPrinter)
    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            PDFConv.DriverEnd()
            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 txtPathname As System.Windows.Forms.TextBox
    Friend WithEvents btOpen As System.Windows.Forms.Button
    Friend WithEvents btConv As System.Windows.Forms.Button
    Friend WithEvents btExit As System.Windows.Forms.Button
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents txtPDFName As System.Windows.Forms.TextBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.btOpen = New System.Windows.Forms.Button
        Me.txtPathname = New System.Windows.Forms.TextBox
        Me.btConv = New System.Windows.Forms.Button
        Me.btExit = New System.Windows.Forms.Button
        Me.Label1 = New System.Windows.Forms.Label
        Me.txtPDFName = New System.Windows.Forms.TextBox
        Me.SuspendLayout()
        '
        'btOpen
        '
        Me.btOpen.Location = New System.Drawing.Point(8, 24)
        Me.btOpen.Name = "btOpen"
        Me.btOpen.Size = New System.Drawing.Size(88, 24)
        Me.btOpen.TabIndex = 0
        Me.btOpen.Text = "Open File"
        '
        'txtPathname
        '
        Me.txtPathname.Location = New System.Drawing.Point(8, 64)
        Me.txtPathname.Name = "txtPathname"
        Me.txtPathname.Size = New System.Drawing.Size(384, 20)
        Me.txtPathname.TabIndex = 1
        Me.txtPathname.Text = ""
        '
        'btConv
        '
        Me.btConv.Enabled = False
        Me.btConv.Location = New System.Drawing.Point(112, 192)
        Me.btConv.Name = "btConv"
        Me.btConv.Size = New System.Drawing.Size(136, 24)
        Me.btConv.TabIndex = 2
        Me.btConv.Text = "Create PDF Rendition"
        '
        'btExit
        '
        Me.btExit.Location = New System.Drawing.Point(304, 232)
        Me.btExit.Name = "btExit"
        Me.btExit.Size = New System.Drawing.Size(88, 24)
        Me.btExit.TabIndex = 3
        Me.btExit.Text = "E&xit"
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(8, 104)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(112, 23)
        Me.Label1.TabIndex = 4
        Me.Label1.Text = "New PDF file Name"
        '
        'txtPDFName
        '
        Me.txtPDFName.Location = New System.Drawing.Point(120, 104)
        Me.txtPDFName.Name = "txtPDFName"
        Me.txtPDFName.Size = New System.Drawing.Size(176, 20)
        Me.txtPDFName.TabIndex = 5
        Me.txtPDFName.Text = ""
        '
        'frmPDFConv
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(400, 266)
        Me.Controls.Add(Me.txtPDFName)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.btExit)
        Me.Controls.Add(Me.btConv)
        Me.Controls.Add(Me.txtPathname)
        Me.Controls.Add(Me.btOpen)
        Me.Name = "frmPDFConv"
        Me.Text = "AiMSPDF Converter"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btOpen.Click
        Dim openFileDialog1 As New OpenFileDialog

        openFileDialog1.InitialDirectory = "c:\"
        openFileDialog1.Filter = "Word Files(*.doc)|*.doc|All files (*.*)|*.*"
        openFileDialog1.FilterIndex = 1
        openFileDialog1.RestoreDirectory = True

        If openFileDialog1.ShowDialog() = DialogResult.OK Then
            txtPathname.Text = openFileDialog1.FileName
        End If
    End Sub

    Private Sub btExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btExit.Click
        Me.Close()
    End Sub

    Private Sub btConv_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btConv.Click
        Dim strFileType As String

        If Not IsNothing(txtPathname.Text) Then
            'Set file  Location for PDFconverter
            Try
                Call PrintToServer(txtPathname.Text)
            Catch Exc As Exception
                'Catch any error messages that can occur
                MsgBox(Exc.Message & " In Button3_Click")
            End Try

        End If
    End Sub

    Public Sub PrintToServer(ByVal inputFileName As String)

        'Make adjustment for type of file to convert
        'the lock method is used. The document name is passed to the function
        PDFConv.Lock("Word.doc")

        'Set default location for PDF output
        PDFConv.SetDocFileProps(DocTitleWord, NoPrompt + UseFileName, "", "C:\Alpine\Docs\" & txtPDFName.Text & ".pdf")

        'New with version 2.10 enable printer
        PDFConv.EnablePrinter("Evaluation", "07EFCDAB0100010080E81ED8695B5D5DD4A66B3D891DF13B90ED3FCFC04AE7D033319A199F61DE1FEF19A21B51B2BC74C1EB08360E8F51FD203838987BAD982DAA91718A2885E010D88B2A6942773D07371E9BEFE37F4401F0C2")

        'pass the file to the print function where file will be converter to PDF
        PrintMicrosoftWord(inputFileName)
        'StorePdf(Server.MapPath("./") & Session("loginName") & ("\w" & Generate_uniqueID() & ".pdf"))
        'The Unlock is called and a 10 second timeout is given.
        ' It waits for the print job to finish or the timeout 
        'event whichever comes first and then unlocks the job.
        PDFConv.Unlock(DocTitleWord, 1000)
    End Sub

    Public Sub PrintMicrosoftWord(ByVal inputFileName As String)

        Dim PDFWord As New Word.Application
        Dim MsDoc As Word.Document

        Try
            PDFWord.Visible = True
            PDFWord.ActivePrinter = (PDFPrinter)
            MsDoc = PDFWord.Documents.Open(inputFileName)
            MsDoc.PrintOut(Background:=False)
            CType(MsDoc, Word._Document).Close()

        Catch Exc As Exception
            'Catch and display errors
            MsgBox(Exc.Message & " In Word")
        End Try

        CType(PDFWord, Word._Application).Quit()
        MsDoc = Nothing
        PDFWord = Nothing
    End Sub

    Private Sub txtPDFName_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtPDFName.TextChanged
        btConv.Enabled = True
    End Sub
End Class
Is there any chance someone could take a quick look at the code to see if there is anything obvious that I am doing wrong.

Your help would be very gratefully appreciated[/code] :?
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

Hello,

Please try the following:

1 - Go to your Printers folder, right click on "Amyuni PDF Converter", choose 'Pause Printing' and run your code.
double click on the printer and check what is the document name being printed, is is 'Word.doc'?

If it is not than you need to choose the value of DocTitleWord also you can set DocTitleWord as parameter for the lock function.

2 - If the above didn't help or was not application please try to change the output file name in your call to SetDoFileProps:

PDFConv.SetDocFileProps(DocTitleWord, NoPrompt + UseFileName, "", "C:\Alpine\Docs\Test.pdf")

C:\Alpine\Docs should be a valid directory on your system.

Hope this helps.
Post Reply