SaveDocumentAsPDF
PowerScript function
Description
Saves the contents in a RichTextEdit control as a PDF
document.
Applies to
RichTextEdit controls
Syntax
|
1 |
rtename.SaveDocumentAsPDF(string filePathName{, string standard{, string userPassword, string masterPassword{, string restrictions}}}) |
|
Argument |
Description |
|---|---|
|
rtename |
The name of the RichTextEdit control in which you want to |
|
filePathName |
A string whose value is the name of the document to be |
|
standard (optional) |
The format indicating the level of PDF conformance. Values
Note: Only the values of “0” and “2” are supported |
|
userPassword (optional) |
A password that enables you to open the generated PDF If userPassword is a non-empty string, you must also set |
|
masterPassword (optional) |
A password that enables you to restrict the permissions of If masterPassword is an empty string, the restrictions |
|
restrictions (optional) |
The permission settings that enable you to restrict You can set the restrictions argument as an empty string.
Note: If standard is set to “2” – PDF/A-1b, the three |
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:
|
1 |
rte.SaveDocument("C: est.pdf", FileTypePDF!) |
|
1 |
rte.SaveDocumentAsPDF("C: est.pdf") |
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:
|
1 2 |
integer li_rtn li_rtn = rte_1.SaveDocumentAsPDF("c:pbtest est.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:
|
1 2 |
integer li_rtn li_rtn = rte_1.SaveDocumentAsPDF("c:pbtest est.pdf","2") |
This example sets the userPassword and the masterPassword, and saves
the contents to a document called test.pdf:
|
1 2 |
integer li_rtn li_rtn = rte_1.SaveDocumentAsPDF("c:pbtest est.pdf","0","test","admini123") |
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:
|
1 2 |
integer li_rtn li_rtn = rte_1.SaveDocumentAsPDF("c:pbtest est.pdf","0","test","admini123","noprint!,nocopy!") |
See also