Save

Saves a picture and optionally overlay ink to a file or blob from an InkPicture control or saves an OLE object in an OLE control or an OLE storage object in syntax 1 and syntax 2. The syntax you use depends on the type of object you want to save.

Saves the contents to a PDF document in syntax 3.

To

To

Save the contents of an InkPicture control

Syntax 1

Save an OLE object

Syntax 2

Save the contents of a PDF document.

Syntax 3


Syntax 1: For InkPicture controls

Description

Saves a picture and optionally overlay ink to a file or blob from an InkPicture control.

Applies to

InkPicture controls

Syntax

inkpicname.Save( t | b , format { , WithInk } )

Argument

Description

inkpicname

The name of the InkPicture control from which you want to save a picture.

t

A string containing the name and location of the file into which the picture will be saved.

b

The name of a blob passed by reference that will hold the picture in the control.

format

An integer specifying the format in which the picture is to be saved. Values are:

0 -- BMP (bitmap)

1 -- JPEG (Joint Photographic Experts Group)

2 -- GIF (Graphics Interchange Format)

3 -- TIFF (Tagged Image File Format)

4 -- PNG (Portable Network Graphics)

WithInk (optional)

A boolean specifying whether overlay ink should be saved with the picture. Values are:

True -- overlay ink is saved with the picture (default)

False -- overlay ink is not saved with the picture


Return value

Integer. Returns 1 for success and -1 for failure.

Usage

Use the Save function to save the image in an InkPicture control to a file or blob with or without any ink annotations that have been made to it. By default, the ink is saved with the image.

Examples

The following example saves the image in an InkPicture control and its ink annotations in bitmap format into a blob, and attempts to update the image in the database:

int li_return
blob lblb_ink

li_return = ip_1.save(lblb_ink, 0, true)
UPDATEBLOB employee SET backimage = :lbb_ink WHERE emp_id = :gi_id;
IF sqlca.SQLNRows > 0 THEN
   COMMIT;
ELSE
   messagebox("Update failed",sqlca.sqlerrtext)
END IF

The following example saves the image in an InkControl into a GIF file without any ink annotations:

int li_return
string ls_pathname, ls_filename

GetFileSaveName("Save As", ls_pathname, ls_filename, "GIF")
li_return = ip_1.save(ls_pathname, 2, false)

See also

LoadInk

LoadPicture

ResetInk

ResetPicture

SaveInk

Syntax 2: For OLE objects

Description

Saves an OLE object in an OLE control or an OLE storage object.

Syntax

oleobject.Save ( )

Argument

Description

oleobject

The name of an OLE control or an OLE storage variable


Return value

Integer. Returns 0 if it succeeds and one of the following negative values if an error occurs:

-1 -- Control is empty

-9 -- Other error

If oleobject is null, Save returns null.

Usage

When you save an OLE object, PowerBuilder saves it according to the current connection between it and an open storage or file. You establish an initial connection when you call the Open function. When you call SaveAs, the old connection is ended and a new connection is established with another storage or file.

When you call Save for an OLE control, PowerBuilder saves the object in the OLE control to the storage to which it is currently connected. The storage can be a storage object variable or a OLE storage file.

If the data has never been saved in the server application, so that there is no file on disk, the Save function in PowerBuilder returns an error.

When you call Save for a storage object variable, PowerBuilder saves the storage to the file, or substorage within the file, to which it is currently connected. You must have previously established a connection to an OLE storage file on disk, or a substorage within the file, either with Open or SaveAs.

When do you have to save twice?

If you create a storage object variable and then open that object in an OLE control, you need to call Save twice to write changed OLE information to disk: once to save from the object in the control to the storage, and again to save the storage to its associated file.

Examples

This example saves the object in the control ole_1 back to the storage from which it was loaded, either a storage object variable or a file on disk:

integer result
result = ole_1.Save()

This example saves a storage object to its file. Olestor_1 is an instance variable of type olestorage:

integer result
result = olestor_1.Save()

In a window's Open script, this code creates a storage variable ole_stor, which is declared as an instance variable, and associates it with a storage file that contains several Visio drawings. The script then opens one of the drawings into the control ole_draw. After the user activates and edits the object, the script for a Save button saves the object to the storage and then to the storage's file.

The script for the window's Open event includes:

OLEStorage stg_stor
stg_stor = CREATE OLEStorage
stg_stor.Open("myvisio.ole")
ole_draw.Open(ole_stor, "visio_drawing1")

The script for the Save button's Clicked event is:

integer result
result = ole_draw.Save()
IF result = 0 THEN ole_stor.Save()

See also

Close

SaveAs

Syntax 3: For a PDFDocument object

Description

Saves the contents to a PDF document.

Syntax

objectname.Save (string fileName)
objectname.Save (string fileName, PDFStandard standard)

Argument

Description

objectname

The name of the PDFDocument object in which you want to save the contents to a PDF document.

fileName

The name of the PDF document to be saved (including the file path)

standard

The format indicating the level of PDF/A conformance. Values are:

  • PDF_None! (Default)

  • PDFA_1a!

  • PDFA_1b!

  • PDFA_3a!

  • PDFA_3b!

  • PDFA_3u!


Return value

Long.

Returns 1 if the function succeeds and a negative value if an error occurs.

1 -- Success

-1 -- General error

-3 -- Invalid PDFDocument object

-4 -- Invalid PDFPage object

-13 -- The index is out of range

-15 -- Invalid PDFImportContent object

-16 -- The start index is out of range

-17 -- Invalid index range

-19 -- Invalid file name

-22 -- Invalid password. The master password and the user password cannot be empty, and they cannot be the same.

-23 -- Invalid PDFDocumentProperties object

-24 -- Invalid handle of PDFlib

-25 -- An exception occurred while executing the PDFlib operation

-26 -- Failed to open the PDF document

-27 -- Failed to create the PDF document

-32 -- The PDF object does not exist

-33 -- The object already has its owner

-34 -- The ReadOnly object is not allowed to be modified

Usage

When the PDF document to be saved does not meet the rules of password setting (refer to the security in Objects and Controls property), the save fails. This is different from saving PDF output using PDFlib or GhostScript (depending on which one is set as the default method) by which the setting of password permission is ignored and the document is saved successfully.

When saving the contents to a PDF document using PDF/A standard, the security property is not compatible because the properties such as the password and restrictions are not supported in the PDF/A standard.These properties will be ignored and not appear in the PDF output. But there is one special case: if the imported PDF document does not meet the PDF/A standard, the save fails.

The table of compatible PDF/A input levels for various PDF/A output levels is as follows:


Example 1

This example imports all pages of the PDF source document noannotsnoPwd.pdf and saves the contents to a new PDF document called save.pdf.

PDFDocument lpdf_doc
long ll_return,ll_return1

lpdf_doc = Create PDFDocument

ll_return = lpdf_doc.importpdf( "D:\noannotsnoPwd.pdf")
ll_return1 = lpdf_doc.save( "D:\save.pdf")

destroy lpdf_doc

Example 2

This example imports all pages of the PDF source document standard_3a.pdf and saves the contents to a new PDF document called save_3A.pdf using PDFA_3A! standard.

PDFDocument lpdf_doc
long ll_return,ll_return1

lpdf_doc = Create PDFDocument

//refers to compatible PDF/A input levels for various PDF/A output levels
ll_return = lpdf_doc.importpdf( "D:\standard_3a.pdf")
ll_return1 = lpdf_doc.save( "D:\save_3A.pdf",PDFA_3A!)

destroy lpdf_doc

See also

ImportDataWindow

ImportPDF