Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/doc_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ export interface IMargin extends IMarginLR {
*/
bot?: number;
}
/**
* An interface that describes the encryption configuration.
*/
export interface IEncryptionSettings {
userPassword: string;
ownerPassword: string;
userPermissions: Array<'print' | 'modify' | 'copy' | 'annot-forms'>;
}
/**
* PDF document configuration. Pass it as the second argument to the `SurveyPDF` constructor:
*
Expand Down Expand Up @@ -226,6 +234,10 @@ export interface IDocOptions {
* Default value: `false` (include all choices)
*/
tagboxSelectedChoicesOnly?: boolean;
/**
* Specifies settings to password protect document.
*/
encryption?: IEncryptionSettings;
}

export class DocOptions implements IDocOptions {
Expand All @@ -249,6 +261,8 @@ export class DocOptions implements IDocOptions {
protected _useLegacyBooleanRendering: boolean
protected _isRTL: boolean;
protected _tagboxSelectedChoicesOnly: boolean;
protected _encryption: IEncryptionSettings;

public constructor(options: IDocOptions) {
if (typeof options.orientation === 'undefined') {
if (typeof options.format === 'undefined' ||
Expand Down Expand Up @@ -311,6 +325,7 @@ export class DocOptions implements IDocOptions {
this._useLegacyBooleanRendering = options.useLegacyBooleanRendering || false;
this._isRTL = options.isRTL || false;
this._tagboxSelectedChoicesOnly = options.tagboxSelectedChoicesOnly || false;
this._encryption = options.encryption;
}
public get leftTopPoint(): IPoint {
return {
Expand Down Expand Up @@ -366,6 +381,9 @@ export class DocOptions implements IDocOptions {
public get tagboxSelectedChoicesOnly(): boolean {
return this._tagboxSelectedChoicesOnly;
}
public get encryption(): IEncryptionSettings {
return this._encryption;
}
}

/**
Expand All @@ -384,7 +402,8 @@ export class DocController extends DocOptions {
orientation: this.orientation,
unit: 'pt',
format: this.format,
compress: this.compress
compress: this.compress,
encryption: this.encryption
};
this._doc = new jsPDF(jspdfOptions);
if (typeof this.base64Normal !== 'undefined' && !SurveyHelper.isFontExist(this, this.fontName)) {
Expand Down