Automating DWF COmposer or Viewer

Discussion in 'AutoCAD' started by Mike Tuersley, Aug 12, 2004.

  1. I hate to cross post but no one in the DWF ngs appears to know the answer, so...Has anyone worked with either Viewer or Composer and found a way to issue the print command without the dialog box? Either in VB, VB.NET or C#. My client wants to just pick a button [the view control is embedded on a custom form] and have the dwf kicked out at the appropriate plotter.

    Thanks!

    -- Mike
    ___________________________
    Mike Tuersley
    CADalyst's CAD Clinic
    Rand IMAGINiT Technologies
    ___________________________
    the trick is to realize that there is no spoon...
     
    Mike Tuersley, Aug 12, 2004
    #1
  2. Mike Tuersley

    Bob Guest

    DWF Viewer 4-5
    Easiest method is to use the SimplePrint API. However, you can't force
    landscape. PrintEX you can force landscape. Try the PrintEX code listed
    below.

    If you make improvments, please post the code so I can update mine. Also,
    if you can figure out how to overlay some text on a dwf please, please post
    the code. With Whip! you could use the API to merge two dwf's. I would
    have some text in one dwf and then merge it with another dwf. Can't do that
    with DWF Viewer.

    VB6:

    Option Explicit

    Private Declare Function CreateDC Lib "gdi32" Alias "CreateDCA" (ByVal
    lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As
    Long, ByVal lpInitData As Long) As Long

    Private Type DOCINFO
    cbSize As Long
    lpszDocName As String
    lpszOutput As String
    lpszDatatype As String
    fwType As Long
    End Type

    Private Declare Function StartPage Lib "gdi32" (ByVal hDC As Long) As Long
    Private Declare Function StartDoc Lib "gdi32" Alias "StartDocA" (ByVal hDC
    As Long, lpdi As DOCINFO) As Long
    Private Declare Function EndPage Lib "gdi32" (ByVal hDC As Long) As Long
    Private Declare Function EndDoc Lib "gdi32" (ByVal hDC As Long) As Long

    Public Sub PrintEXAPI()
    Dim di As DOCINFO
    Dim paCount As Integer
    Dim pa As IAdPageViewer

    On Error GoTo 10

    'Set up the control
    CExpressViewerControl1.ExecuteCommand ("FITTOWINDOW")
    Set pa = CExpressViewerControl1.Viewer

    'Printer settings
    Printer.TrackDefault = True
    Printer.Orientation = vbPRORLandscape
    Printer.PaperSize = vbPRPSLetter
    'Printer.PrintQuality = vbPRPQHigh

    'Print job name.
    di.lpszDocName = "My print queue name."

    'Print each page.
    For paCount = 1 To pa.Pages.Count
    pa.Page = paCount
    pa.WaitForPageLoaded
    'Start print
    Call StartDoc(Printer.hDC, di)
    'New page
    Call StartPage(Printer.hDC)
    'B&W
    pa.SetBlackAndWhite
    pa.SetBlackAndWhite '<-- It must be called twice. Bug in View
    Express.
    'Print
    pa.PrintEx Printer.hDC, pa.Page.View.Left, pa.Page.View.bottom,
    pa.Page.View.Right, pa.Page.View.Top, True
    'Restore colors
    pa.RestoreColors
    'End page
    Call EndPage(Printer.hDC)
    Next paCount

    'End print
    Call EndDoc(Printer.hDC)

    10
    If Err.Number <> 0 Then
    MsgBox Err.Description, vbSystemModal
    Err.Clear
    Exit Sub
    Resume
    End If

    End Sub


    so...Has anyone worked with either Viewer or Composer and found a way to
    issue the print command without the dialog box? Either in VB, VB.NET or C#.
    My client wants to just pick a button [the view control is embedded on a
    custom form] and have the dwf kicked out at the appropriate plotter.
     
    Bob, Aug 12, 2004
    #2
  3. Mike Tuersley

    bcoward Guest

    Mike,

    I'm sure you've tried the simple to inter-simple techniques but have you tried subclassing either the command button or the actual VBThunderForm and readdress the event synk?

    I've only downloaded the viewer in the last week or so. I'f you don't get it I'll look at it after I finish this Inventor stuff. let me know.

    Good luck,

    Bob Coward
    CADS, Inc

    800-366-0946


    Good luck
     
    bcoward, Aug 12, 2004
    #3
  4. Mike Tuersley

    bcoward Guest

    oops, Bob's post wasn't there when I wrote that last blurb.

    Like Bob's idea...good work
     
    bcoward, Aug 12, 2004
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.