Connection Information

To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host.

Connection Type

SaveDocumentAsPDF – PB Docs 2022 – PowerBuilder Library

SaveDocumentAsPDF – PB Docs 2022

SaveDocumentAsPDF

PowerScript function

Description

Saves the contents in a RichTextEdit control as a PDF
document.

Applies to

RichTextEdit controls

Syntax

Argument

Description

rtename

The name of the RichTextEdit control in which you want to
save the contents as a PDF document.

filePathName

A string whose value is the name of the document to be
saved (including the file path). Make sure you have write
permission to the directory specified by the filePathName
argument. Otherwise, the document will fail to be saved or be
saved in %LocalAppData%VirtualStore (the behavior of
OS).

standard

(optional)

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

  • “0” — PDF (default)

  • “1” — PDF/A-1a (not supported yet)

  • “2” — PDF/A-1b

  • “3” — PDF/A-3a (not supported yet)

  • “4” — PDF/A-3b (not supported yet)

  • “5” — PDF/A-3u (not supported yet)

Note: Only the values of “0” and “2” are supported
now.

userPassword (optional)

A password that enables you to open the generated PDF
document. The userPassword argument can be set as an empty
string, so you can open the document without any
password.

If userPassword is a non-empty string, you must also set
masterPassword as a non-empty string. The user password and the
master password cannot be the same, otherwise this function will
fail.

masterPassword (optional)

A password that enables you to restrict the permissions of
the generated PDF document. You can set the permissions by the
restrictions argument.

If masterPassword is an empty string, the restrictions
argument will be ignored and no actions (copy/print/edit/etc.)
will be restricted.

restrictions (optional)

The permission settings that enable you to restrict
certain actions (such as copying/printing/editing) of a PDF
document. One or more of the following string values can be
contained (multiple strings are separated by “,”).

You can set the restrictions argument as an empty string.
In this case, if masterPassword is valid, all permissions will
be restricted, and if the masterPassword is invalid, the
permissions will not be restricted.

  • noprint! — Acrobat will prevent printing the
    file.

  • nohiresprint! — Acrobat will prevent high-resolution
    printing. If noprint is not set, printing is restricted to
    the print as image feature which prints a low-resolution
    rendition of the page.

  • nomodify! — Acrobat will prevent editing or cropping
    pages and creating or changing form fields.

  • noassemble! — Acrobat will prevent inserting,
    deleting, or rotating pages and creating bookmarks and
    thumbnails.

  • noannots! — Acrobat will prevent creating or changing
    annotations and form fields.

  • noforms! — Acrobat will prevent form field filling.
    (implies nomodify and noannots)

  • nocopy! — Acrobat will prevent copying and extracting
    text or graphics; the accessibility interface will be
    controlled by noaccessible.

  • noaccessible! — (Obsolete in PDF 2.0; not allowed in
    PDF/UA-1) Acrobat will prevent extracting text or graphics
    for accessibility

Note: If standard is set to “2” – PDF/A-1b, the three
arguments (userPassword,
masterPassword,
restrictions) will be ignored. The PDF
document will be saved using PDF/A-1b standard and will be
opened without any password.

Return value

Integer.

Returns 1 for success and the following values for failure. If any
argument’s value is null, returns null.

-1 — Failed for unknown reasons

-2 — The standard argument is not compatible with the PDF/A
conformance

-3 — The userPassword argument is set while the masterPassword
argument is not

-4 — Both userPassword and masterPassword are non-null values but
the same

Usage

The SaveDocument function
supports exporting data to PDF documents in PDF standard, but does not
support setting the passwords and restrictions of the PDF document;
however, the SaveDocumentAsPDF function supports exporting data to PDF
documents in both PDF and PDF/A standards, and supports setting the
passwords and restrictions.

The following two lines of code are equivalent:

To have a deep understanding of the SaveDocumentAsPDF function, you
can refer to the following properties in DataWindow objects.

Export.PDF.NativePDF.UserPassword

Export.PDF.NativePDF.MasterPassword

Export.PDF.NativePDF.Restrictions

The basic rules do not change a lot, except for one difference. If
the userPassword argument is set while the masterPassword argument is not,
the PDF document will be saved successfully by using the SaveAs function
in DataWindow and all passwords will be ignored. However, if you use the
SaveDocumentAsPDF function, the PDF document will fail to be saved.

Examples

This example saves the contents of the RichTextEdit rte_1 to a PDF
document called test.pdf:

This example exports PDF using PDF/A-1b standard, and saves the
contents of the RichTextEdit rte_1 to a document called test.pdf:

This example sets the userPassword and the masterPassword, and saves
the contents to a document called test.pdf:

This example prevents the PDF document being printed and copied,
sets the userPassword and the masterPassword, and saves the contents to a
document called test.pdf:

See also

SaveDocument


Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x