Meridian 2010


Example code is for an older version of Meridian, newer code is available.
' Copyright (c) 2019 ActivePDF, Inc.
' ActivePDF Meridian 2010
' Example generated 07/18/19 

Imports System

' Make sure to add the ActivePDF product .NET DLL(s) to your application.
' .NET DLL(s) are typically found in the products 'bin' folder.

Public Class Examples
  Sub Example()
    Dim strPath As String, intStartPrinting As Integer, intWait As Integer

    strPath = AppDomain.CurrentDomain.BaseDirectory

    ' Instantiate Object
    Dim oMER As APMeridian.Meridian = New APMeridian.Meridian()
    ' Specify the IP address and Port to use to reach the Meridian Server
    oMER.StartRemoteClient("", 54545)
    ' Must use either SetUniuqeInput or SetProcessAndThread
    ' Call SetUniqueInput with the full path to the input
    ' it is best to use a unique filename to avoid potential
    ' name collisions, if the filename is unique set the second
    ' parameter to true
    oMER.SetUniqueInput(strPath & "Word.doc", true)
    ' Here we are using SetUniqueInput, as the print job is
    ' from Microsoft Word, Word will add 'Microsoft Word - '
    ' to the print job so we need to let meridian know using
    ' UniqueInputPrefix
    oMER.UniqueInputPrefix = "Microsoft Word - "
    ' Path and filename of the created PDF
    oMER.OutputDirectory = strPath
    oMER.NewDocumentName = "Word.pdf"
    ' Set the ModelPrinter to the remote Meridian printer
    ' This printer must be added locally to the remote system
    oMER.ModelPrinter = "\\\Meridian"
    ' Prepare to start the printing process
    intStartPrinting = oMER.StartPrinting()
    If intStartPrinting <> 0 Then
      ErrorHandler("StartPrinting", intStartPrinting)
    End If
    ' Automate Word to print a document to Meridian
    ' NOTE: You must add the 'Microsoft.Office.Interop.Word' reference
    Dim oWORD As Microsoft.Office.Interop.Word._Application = New Microsoft.Office.Interop.Word.Application()
    oWORD.ActivePrinter = oMER.ModelPrinter
    oWORD.DisplayAlerts = Microsoft.Office.Interop.Word.WdAlertLevel.wdAlertsNone
    oWORD.Visible = False
    Dim oDOC As Microsoft.Office.Interop.Word.Document = oWORD.Documents.Open(strPath & "Word.doc")
    oDOC = Nothing
    oWORD = Nothing
    ' End the printing process
    ' Wait(seconds) for job to complete
    intWait = oMER.Wait(30)
    If intWait <> 0 Then
      ErrorHandler("Wait", intWait)
    End If
    ' Release Object
    oMER = Nothing
    ' Process Complete
  End Sub
  ' Error Handling
  ' Error messages written to debug output
  Sub ErrorHandler(ByVal strMethod, ByVal RtnCode)
    WriteResults(strMethod + " error:  " + rtnCode.ToString())
  End Sub
  ' Write output data
  Sub WriteResults(content As String)
    ' Choose where to write out results
    ' Debug output
    'System.Diagnostics.Debug.WriteLine("ActivePDF: * " + content)
    ' Console
    ' Log file
    'Using tw = New System.IO.StreamWriter(AppDomain.CurrentDomain.BaseDirectory & "application.log", True)
    '   tw.WriteLine("[" + DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss") + "]: => " + content)
    'End Using
  End Sub
End Class

Copyright © 2019 ActivePDF, Inc