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.