BBjForm::preview

Description

In BBj 12.0 and higher, this method adds the maximize, style, zoom, password, and secure parameters.

In BBj 7.0, this method previews the document in a SysGui window.

In BBj 4.0 and higher, this method previews the document.

Syntax

Variable

Description

void

preview()

void

preview(BBjPrintPreviewpreviewControl)

void

preview(boolean maximize, string style, BBjNumber zoom, string editPassword, string openPassword)

void

preview(boolean maximize, string style, BBjNumber zoom, boolean secure)

void

preview(boolean maximize, string style, BBjNumber zoom, boolean secure)

Parameters

Variable

Description

previewControl

Specifies the preview control in a SysGui window.

maximize

Initially maximize the preview.

style

Sets the page display style, one of HEIGHT, WIDTH, or TWO.

zoom

Sets initial zoom percent.

editpassword

Sets admin password for saved PDF.

openpassword

Sets password to allow opening the PDF.

secure

Create a secure PDF.

Return Value

None.

Remarks

In BBj 10.0 and higher, these methods apply to PDF forms.

Example 1

rem 'Preview the document

rem 'Obtain the instance to the BBjAPI object
myAPI! = BBjAPI()

rem 'Obtain an instance of a default BBjPrinter object
let myBBjPrinter! = myAPI!.getBBjPrinter(0)

rem 'Get BBjForm for the selected printer
let myBBjForm! = myBBjPrinter!.getForm(1)

rem 'Preview the document
myBBjForm!.preview()
release

Example 2 - Window

rem ' addPrintPreview

let myAPI! = BBjAPI()

rem 'Open the SysGui device
SYSGUI = UNT
OPEN (SYSGUI)"X0"

rem 'Obtain the instance of the BBjSysGui object
let mySysGui! = myAPI!.getSysGui()

rem 'Set addWindow param values
X = 10
Y = 10
WIDTH = 800
HEIGHT = 600
TITLE$="addPrintPreview"

rem 'Set the current context
mySysGui!.setContext(0)

rem 'Create a window
myWindow! = mySysGui!.addWindow(X,Y,WIDTH,HEIGHT,TITLE$,$00010003$)

rem 'Add a print preview control to the window
myPrintPreview! = myWindow!.addPrintPreview(101,50,50,700,500,"",$$)
myPrintPreview!.setZoom(2)

form! = myAPI!.getBBjPrinter(0).getForm(0)
page! = form!.createPage()
para! = page!.newParagraph()
para!.setHorizontalFill(1)
para!.setFont(new java.awt.Font("Courier",java.awt.Font.PLAIN,24))
para!.setText("BBjPrintPreview, new for BBj 7!")
page!.add(para!)
form!.preview(myPrintPreview!)

rem 'Register the CALLBACK routines
CALLBACK(ON_CLOSE,APP_CLOSE,mySysGui!.getContext())

rem 'Process Events
process_events

rem 'Callback routine called when the user closes the application window
APP_CLOSE:
release

Example 3 - Password

declare BBjPrinter printer!
declare BBjForm form!
declare BBjFormPage page!
declare BBjFormImage image!

rem 'Obtain an instance of a default BBjPrinter object
printer!=BBjAPI().getBBjPrinter(1)

rem 'Get BBjForm for the selected printer
form!=printer!.getForm(0)

rem 'Get a page
page!=form!.createPage()

rem 'Create an image element for the page
logo$="https://www.basis.cloud/images/basislogo.jpg"
image!=page!.newImage(logo$,0,0,150,53)

rem 'Add the element to the page
page!.add(image!)

rem 'Preview the form with a custom secure password
form!.preview(false,"HEIGHT", 1.0, “test”)
release

Example 4 - Secure

Note: Saved PDF documents are by default secure. To turn off the default security, use the option provided in this example below:

declare BBjPrinter printer!

declare BBjForm form!

declare BBjFormPage page!

declare BBjFormImage image!

REM Obtain an instance of a default BBjPrinter object

printer!=BBjAPI().getBBjPrinter(1)

REM Get BBjForm for the selected printer

form!=printer!.getForm(0)

REM Get a page

page!=form!.createPage()

REM Create an image element for the page

logo$="https://www.basis.cloud/images/basislogo.jpg"

image!=page!.newImage(logo$,0,0,150,53)

REM Add the element to the page

page!.add(image!)

REM Preview the form

form!.preview(false,"HEIGHT", 1.0, false)

release

Example - Purchase Requisition

See Also

BBjAPI

BBj Object Variables

BBj Object Assignment

BBj Object Error Handling

BBj Object Operators

BBjPrintPreviewBuilder::secure

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.