Fax Software

Community Forums

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #2544
    vikewings
    Member

    I’ve had a VB6 app that generates output from a database, formats it for printing using a Printer object, and then uses WinFax SDK (10.03) with .SetPrintFromApp(1) to “print” the output to the Winfax printer. Winfax takes it from there and sends my fax. Works like a charm. Life is good.

    Now I’ve got a new requirement: Some faxes need a blank form sent along with the generated output. The blank form is generally going to be a one or two page PDF or DOC file. No problem, I thought. I see this handy little .AddAttachmentFile method and I tested it by just sending a fax with our normal coverpage and adding one of these attachments. Because PDF and DOC files are properly associated with Adobe Reader and MS Word, WinFax was able to convert the PDF and DOC files on-the-fly and fax them. Cool! I should have this requirement handled before lunch!

    Then came my problem. I tried putting both together and the AddAttachmentFile no longer works. It seems like once I execute .SetPrintFromApp(1), the .AddAttachmentFile no longer has any effect.

    Am I missing a step? Is there another SDK method or property that I need to look at? Is it something to do with the order of operations? Or are these two methods mutually exclusive?

    That would be shame because it seems like such a logical process. Sending faxes from “printer” output and appending an occasional “pre-made” document to the fax.

    I would be most grateful for any suggestions. Thanks.

    #4281
    Anonymous
    Member

    Do you have AddAttachmentFile set before AddRecipient() and SetPrintFromApp(1) ? Something like this:

    < other code goes here >

    sdk_ret = WinFaxSend.AddAttachmentFile(“whatever”)

    < other code goes here >

    sdk_ret = WinFaxSend.AddRecipient()
    sdk_ret = WinFaxSend.SetPrintFromApp(1)
    sdk_ret = WinFaxSend.ShowSendScreen(0)
    sdk_ret = WinFaxSend.Send(1)

    Do While WinFaxSend.IsReadyToPrint = 0
    DoEvents
    Loop

    note this code will fail with WinFax PRO 10.02 and Windows XP…get 10.03 or 10.04

    Edited By Moderator on 1140041499

    #4282
    vikewings
    Member

    I am using version 10.03. Here’s my test code that I’ve been using to try to get this to work. With this code, a fax is created with a cover page and then a page containing the very basic output for the Printer object, but the PDF file referenced by AddAttachmentFile is not appended. Interestingly, if I comment out the PrinterObj lines and the .SetPrintFromApp(1) line, it creates a fax with a cover page and the PDF file. But I cannot get it to create a fax with BOTH the document created in the PrinterObj and the attached PDF file. It seems like this should work!?

    ==============================================

    Dim sendObj As Object
    Dim sdk_ret As Integer

    ‘Sets the printer object device setting to the Winfax “printer”
    PrinterObj.Device = “WinFax”
    ‘start the creation of the document output
    PrinterObj.Action = paStartDoc
    ‘add some text content to the document to be output by the PrinterObj
    PrinterObj.Text = “This is my test fax main document generated from vsPrinter object”
    ‘finish the document
    PrinterObj.Action = paEndDoc

    ‘create the Winfax SDK Send object
    Set sendObj = CreateObject(“WinFax.SDKSend”)

    sdk_ret = sendObj.SetHold(1)

    ‘append an attachment to the fax
    sdk_ret = sendObj.AddAttachmentFile(“c:DevMobileDataTemplatessurvey.pdf”)

    sdk_ret = sendObj.SetCompany(“AAA Test Co.”)
    sdk_ret = sendObj.SetTo(“Joe Test”)
    sdk_ret = sendObj.SetSubject(“Test faxing”)
    sdk_ret = sendObj.SetCoverFile(“C:Program FilesWinfaxCoverPericulum.cvp”)
    sdk_ret = sendObj.SetCoverText(“Test cover text”)
    sdk_ret = sendObj.SetUseCover(1)
    sdk_ret = sendObj.SetNumber(“5176477900”)
    sdk_ret = sendObj.AddRecipient
    sdk_ret = sendObj.SetPrintFromApp(1)
    sdk_ret = sendObj.Send(1)

    Do While sendObj.IsReadyToPrint = 0
    DoEvents
    Loop

    MsgBox “Done”

    #4283
    Anonymous
    Member

    The WinFax print job should go after the Do While loop. So, just move the PrinterObject code where you actually print to WinFax after the Do While Loop.
    also, add this after you create the WinFaxSend object
    objWinFaxSend.SetClientID (“Client Name”)
    You need this, always…the name can be whatever you like.

    The following example code should send a cover page, an attachment, and whatever you print in the code..

    ‘Open an instance of WinFax

    Dim objWinFaxSend As Object
    Set objWinFaxSend = CreateObject(“WinFax.SDKSend8.0”)
    objWinFaxSend.SetClientID (“Client Name”)

    ‘ Begin Recipient Settings

    strRecipient = “GetFaxing”
    strFaxNumber = “555-555-2323”
    RetCode = objWinFaxSend.SetTo(strRecipient)
    RetCode = objWinFaxSend.SetNumber(strFaxNumber)

    ‘ Begin Job Settings

    RetCode = objWinFaxSend.SetResolution(1)
    RetCode = objWinFaxSend.SetDeleteAfterSend(1)
    RetCode = objWinFaxSend.SetUseCover(1)
    RetCode = objWinFaxSend.SetCoverText(“hello this is a test”)
    RetCode = objWinFaxSend.SetCoverFile(“c:program filessymantectalkworkscoverbasic1.cvp”)
    RetCode = objWinFaxSend.AddAttachmentFile(“whatever attachment.doc”)

    RetCode = objWinFaxSend.AddRecipient()

    RetCode = objWinFaxSend.SetPrintFromApp(1)

    RetCode = objWinFaxSend.Send(1)

    RetCode = objWinFaxSend.ShowSendScreen(0)

    ‘ this routine waits until “IsReadyToPrint” returns a Non-zero
    ‘ value (ready)
    ‘ this loop will wait but allow background
    ‘ processing to continue

    Do While objWinFaxSend.IsReadyToPrint = 0
    DoEvents
    Loop



    ‘ Code here for print job to winfax pro printer.
    ‘ should be nice and change driver back to default if it stays
    ‘ as WinFax.

    ‘ Wait until the EntryID is ready before moving on.
    ‘ the Send(1) you specified before is used here.
    ‘ We don’t care what the EntryID is,
    ‘ we just want to know that is it ready.
    ‘ this loop will wait but allow background processing to
    ‘ continue when ready IsEntryIDReady is not = to 1

    Do While objWinFaxSend.IsEntryIDReady(0) <> 1
    DoEvents
    Loop

    ‘ set winfax object instance to nothing

    Set objWinFaxSend = Nothing

    Edited By Moderator on 1140051782

    #4284
    vikewings
    Member

    That’s the ticket! Thank you very much for your help.

    #4285
    vrapp3
    Member

    I have a question. The posted code issues Send first and then waits for the print jobs to come from the application. How does it know when printing is finished? What if I need to print more than one document?

    #4286
    admin
    Keymaster

    if I can recall correctly, it only is designed for single print job.
    but you can also attach another document using the AddAtachmentFiles.
    if your app requires multiple print jobs, and they go to the same recipient you could:
    send each fax print job as a separate fax transmission.(probably not what you want)
    or
    combine each separate print job into a single PDF file using another tool/method. When complete, print (or attach) the single PDF file to the WinFax printer.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.