Normal Topic Creating PDF with command button (Read 187 times)
cbislander
Full Member
***
Offline



Posts: 107
Joined: Mar 22nd, 2018
Creating PDF with command button
May 11th, 2024 at 11:44am
Print Post Print Post  
I have a purchase order database that prints out purchase orders on paper, by just printing the form screen.  I want to print PDF's that will be created by pressing the command button.

Here is the code for that command:

var vTmp as Int
Var vShell as Int
Var vCOPY as String
AlternateDefaultPrinter("Microsoft Print to PDF")

vCopy = "T:\PURCHASE\PO-"+ P.O.# 
     If (@Mode() = 0) Or (@Mode() = 1)
     {
           // This prints the curent record with default settings.
           // See the documentation for @PrintAForm for other settings you can use.
           vTmp = @PrintAForm(0, 1, 1, 0, 28, -1, -1, -1, -1, 1, 1)
     }

RestoreDefaultPrinter()


What do I need to do so the PDF is save as "T:\PURCHASE\PO-3098" by just pressing the button?

Currently, I need to type it in manually after clicking the button.
  

PURCHASE.png ( 12 KB | 21 Downloads )
PURCHASE.png
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Creating PDF with command button
Reply #1 - Jun 18th, 2024 at 5:01pm
Print Post Print Post  
One quick option would be to copy the target to the clipboard using:
Code
Select All
SetCopyBuffer(vCopy) 


Then a simple Ctrl+V to paste it into the "File name:" box. But, that still requires additional input from the user. There are far more advanced ways to do this with a single click.

For example, I have a very complex system using WordMerge, and VBScript in the Word document to handle creating the PDF. I send out all my invoices as emails with a PDF attachment, using a single click (actually two, because the 2nd one asks if I'm sure I want to send all the invoices).
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
cbislander
Full Member
***
Offline



Posts: 107
Joined: Mar 22nd, 2018
Re: Creating PDF with command button
Reply #2 - Jun 22nd, 2024 at 2:26pm
Print Post Print Post  
Hi Carl,

That worked for what I need it to do. 

Here's the completed programming for the Print to PDF command

var vTmp as Int
Var vMess as String
Var vShell as String
Var vCOPY as String
Var vMacro as String

AlternateDefaultPrinter("Microsoft Print to PDF")

vCopy = "K:\PURCHASE\PO-"+ P.O.# 
SetCopyBuffer(vCopy)
@MsgBox("PRESS"," < Ctrl > + V ", "to generate Invoice# PDF")
     If (@Mode() = 0) Or (@Mode() = 1)
     {
           // This prints the curent record with default settings.
           // See the documentation for @PrintAForm for other settings you can use.
           vTmp = @PrintAForm(0, 1, 1, 0, 28, -1, -1, -1, -1, 1, 1)
     }


RestoreDefaultPrinter()

That way the user can opt to name the file differently if necessary.

Thanks
  
Back to top
 
IP Logged