For a company, 7-PDF Printer was configured as a network pdf printer that was used as PDF Invoice printer directly from a ERP SAP system.

After pdf creation the generated pdf-file is delivered to a FAX-Server for sending the PDF via FAX. For this, a user can put the fax-number to an input-field by 7-PDF Printer. After 7-PDF Printer has generated PDF and has the fax-number, it send all via SMTP to the fax-server.

The example code shows that complex process above. All this with some few lines of VBScript Code in conjunction with 7-PDF Printer. Enjoy!

  1. Dim global_success, faxnr, SMTPServer, Recipient, From, Subject, Message
  2.  
  3. Sub OnConfigLoaded()
  4.     Rem -- Modify the configuration to extract text from the printer
  5.     Rem -- output.
  6.    
  7.     faxnr = InputBox("Fax number entry (without special characters and spaces):", "Send invoice")
  8.    
  9.    Context("Config")("showsettings") = "never"
  10.     Context("Config")("showpdf") = "no"   
  11.     Context("Config")("output") = "C:\pdf-processing\print\<date>-<time>.pdf"
  12.     Context("Config")("superimpose") = "C:\pdf-processing\print\background.pdf"
  13.     Context("Config")("author") = "<username>"
  14.     Context("Config")("confirmoverwrite") = "no"
  15.     Context("Config")("mergefile") = "C:\pdf-processing\print\agb.pdf"
  16.     Context("Config")("mergeposition") = "top"
  17.    
  18. End Sub
  19.  
  20. Sub OnSuccess()
  21.   global_success = true
  22. End Sub
  23.  
  24. Sub OnAfterPrint()
  25.    
  26.   If global_success Then
  27.    
  28.     Rem -- Absender <username>@mailserver.de
  29.     Rem -- Empfänger faxnr@fax.local
  30.    
  31.     SMTPServer = "smtp.mailserver.local"
  32.     Recipient = faxnr & "@fax.local"
  33.     From = Context("DocumentAuthor") & "@mailserver.de"
  34.     Subject = "Your SAP Invoice"
  35.     Message = "Enclosed you will receive your SAP invoice for the
  36. Technician's order of the technician " & Context("DocumentAuthor")
  37. & vbcrlf & "Thank you for your order!"
  38.  
  39.     set msg = CreateObject("CDO.Message")
  40.     msg.From = From
  41.     msg.To = Recipient
  42.     msg.Subject = Subject
  43.     msg.TextBody = Message
  44.    
  45.     ' To add an attachment uncomment this line
  46.     msg.AddAttachment Context("OutputFileName")
  47.  
  48.     msg.Configuration.Fields ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTPServer
  49.     msg.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
  50.     msg.Configuration.Fields.Update
  51.  
  52.     msg.Send
  53.    
  54.     MsgBox "The bill has been sent."
  55.    
  56.     ' Del PDF
  57.     Set objFSO = CreateObject("Scripting.FileSystemObject")
  58.     objFSO.DeleteFile(Context("OutputFileName"))
  59.    
  60.   Else
  61.    
  62.     MsgBox "An error occurred while sending the invoice. Please try again!"
  63.    
  64.   End If
  65.  
  66. End Sub

Download Example File

You can download and run the example yourself. The files needed are available here. The VBS file must be placed in the macros sub folder of the PDF writer installation. You can use the MacroDir setting to change the location of the VBS files if needed.

Downloads

Attachment Size
Example file 1.1 KB

LiveZilla Live Chat Software
Top