The thing I would like to do is to ‘print’ the contents of a TextArea or – better still – a file to a .PDF, .SVG or Postscript the user can use or print himself, without having to use Printer.Configure.
I tried to get Printer.Print working but can’t. Why calling it so when it can’t do what it seems to say?
So I tried Printer.Configure anyway and got stuck again. Yes, it looks really good and it does produce a PDF file. Only, it’s a completely empty one because nowhere can I find a way to tell it what content has to be printed.
One nice touch : setting MyPrinter.OutputFile = Application.path & "/Output.pdf" from the start causes Configure to choose already the option ‘Print to File’.
So how to make the two options – without (preferably) and with - using Configure work?
Again, some very simple example code for ‘beginners’ in the help browser would be a great benefit.
I hope you like the little programme
' Gambas class file
Public MyPrinter As New Printer
Public fText As New TextArea(Me) As "fText"
Public MyButton As New Button(Me) As "MyButton"
Public MyButton2 As New Button(Me) As "MyButton2"
Public Sub MyButton2_Click()
With MyPrinter
'I tried :
.print = Application.path & "/Output.pdf"
'but as you see, that doesn't work.
End With
End
Public Sub Form_Open()
With fText
.width = 1
.height = 100
.wrap = True
.text = "Please add some text and print it to Output.pdf."
End With
With MyButton
.width = 1
.height = 26
.text = "MyPrinter.Configure"
End With
With MyButton2
.width = 1
.height = 26
.text = "Trying to print"
End With
With Me
.width = 300
.padding = 20
.Arrangement = Arrange.Vertical
.height = fText.Height + MyButton.Height + MyButton2.height + (.Padding * 2)
fText.SetFocus
End With
MyPrinter.OutputFile = Application.path & "/Output.pdf"
End
Public Sub MyButton_Click()
MyPrinter.Configure
End