📄 pdfsavedialog.java
字号:
* @return the defined password. The password can be null.
*/
public String getUserPassword()
{
final String txt = txUserPassword.getText();
if (txt.equals(""))
{
return null;
}
return txt;
}
/**
* Defines the user password for the pdf file. The user password limits read-only access
* to the pdf in the PDF-Viewer. The reader/user has to enter the password when opening the file.
*
* @param userPassword the defined password. The password can be null.
*/
public void setUserPassword(final String userPassword)
{
txUserPassword.setText(userPassword);
txConfUserPassword.setText(userPassword);
}
/**
* Returns the owner password for the pdf file. The owner password limits writing access
* to the pdf in the PDF-Editor. The user has to enter the password when opening the file
* to enable editing functionality or to modify the file.
*
* @return the defined password. The password can be null.
*/
public String getOwnerPassword()
{
final String txt = txOwnerPassword.getText();
if (txt.equals(""))
{
return null;
}
return txt;
}
/**
* Defines the owner password for the pdf file. The owner password limits writing access
* to the pdf in the PDF-Editor. The user has to enter the password when opening the file
* to enable editing functionality or to modify the file.
*
* @param ownerPassword the defined password. The password can be null.
*/
public void setOwnerPassword(final String ownerPassword)
{
txOwnerPassword.setText(ownerPassword);
txConfOwnerPassword.setText(ownerPassword);
}
/**
* Returns the selected encoding.
*
* @return The encoding.
*/
public String getEncoding()
{
if (cbEncoding.getSelectedIndex() == -1)
{
return System.getProperty("file.encoding");
}
else
{
return encodingModel.getEncoding(cbEncoding.getSelectedIndex());
}
}
/**
* Sets the encoding.
*
* @param encoding the encoding (name).
*/
public void setEncoding(final String encoding)
{
cbEncoding.setSelectedIndex(encodingModel.indexOf(encoding));
}
/**
* Gets the AllowDegradedPrinting permission for the generated PDF-file.
* @return true if a low quality printing is allowed, false otherwise.
*/
public boolean isAllowDegradedPrinting()
{
return cbAllowPrinting.getSelectedIndex() == CBMODEL_DEGRADED;
}
/**
* Gets the AllowAssembly permission for the generated PDF-file.
*
* @return true, if the generated pdf may be reassembled using an pdf editor.
*/
public boolean isAllowAssembly()
{
return cxAllowAssembly.isSelected();
}
/**
* Defines whether the generated pdf may be reassembled.
*
* @param allowAssembly the flag.
*/
public void setAllowAssembly(final boolean allowAssembly)
{
this.cxAllowAssembly.setSelected(allowAssembly);
}
/**
* Defines whether the generated pdf may accessed using screenreaders. Screenreaders are
* used to make pdf files accessible for disabled people.
*
* @return true, if screenreaders are allowed for accessing this file
*/
public boolean isAllowScreenreaders()
{
return cxAllowScreenReaders.isSelected();
}
/**
* Defines whether the generated pdf may accessed using screenreaders. Screenreaders are
* used to make pdf files accessible for disabled people.
*
* @param allowScreenreaders a flag containing true, if screenreaders are allowed to access the
* content of this file, false otherwise
*/
public void setAllowScreenreaders(final boolean allowScreenreaders)
{
this.cxAllowScreenReaders.setSelected(allowScreenreaders);
}
/**
* Defines whether the contents of form fields may be changed by the user.
*
* @return true, if the user may change the contents of formulars.
*/
public boolean isAllowFillIn()
{
return cxAllowFillIn.isSelected();
}
/**
* Defines whether the contents of form fields may be changed by the user.
*
* @param allowFillIn set to true to allow the change/filling of form fields
*/
public void setAllowFillIn(final boolean allowFillIn)
{
this.cxAllowFillIn.setSelected(allowFillIn);
}
/**
* Defines whether the contents of the file are allowed to be copied.
*
* @return true, if the user is allowed to copy the contents of the file.
*/
public boolean isAllowCopy()
{
return cxAllowCopy.isSelected();
}
/**
* Defines whether the contents of the file are allowed to be copied.
*
* @param allowCopy set to true, if the user is allowed to copy the contents of the file.
*/
public void setAllowCopy(final boolean allowCopy)
{
this.cxAllowCopy.setSelected(allowCopy);
}
/**
* Defines whether the user is allowed to add or modify annotations in this file.
*
* @return true, if this files annotations can be modified, false otherwise
*/
public boolean isAllowModifyAnnotations()
{
return cxAllowModifyAnnotations.isSelected();
}
/**
* Defines whether the user is allowed to add or modify annotations in this file.
*
* @param allowModifyAnnotations the flag.
*/
public void setAllowModifyAnnotations(final boolean allowModifyAnnotations)
{
this.cxAllowModifyAnnotations.setSelected(allowModifyAnnotations);
}
/**
* Defines whether the user is allowed to modify the contents of this file.
*
* @return true, if this files content can be modified, false otherwise
*/
public boolean isAllowModifyContents()
{
return cxAllowModifyContents.isSelected();
}
/**
* Defines whether the user is allowed to modify the contents of this file.
*
* @param allowModifyContents set to true, if this files content can be modified, false otherwise
*/
public void setAllowModifyContents(final boolean allowModifyContents)
{
this.cxAllowModifyContents.setSelected(allowModifyContents);
}
/**
* Defines whether the user is allowed to print the file. If this right is granted, the
* user is also able to print a degraded version of the file, regardless of the
* allowDegradedPrinting property
*
* @return true, if this file can be printed, false otherwise
*/
public boolean isAllowPrinting()
{
return cbAllowPrinting.getSelectedIndex() == CBMODEL_FULL;
}
/**
* Defines whether the user is allowed to print the file. If this right is granted, the
* user is also able to print a degraded version of the file, regardless of the
* <code>allowDegradedPrinting</code< property. If you disabled printing but enabled degraded
* printing, then the user is able to print a low-quality version of the document.
*
* @param allowPrinting set to <code>true</code>, if this file can be printed,
* <code>false</code> otherwise.
* @param degraded set to <code>true</code>, to allow degraded printing, and <code>false</code>
* otherwise.
*/
public void setPrintLevel(final boolean allowPrinting, final boolean degraded)
{
if (allowPrinting == true)
{
this.cbAllowPrinting.setSelectedIndex(CBMODEL_FULL);
}
else
{
if (degraded)
{
this.cbAllowPrinting.setSelectedIndex(CBMODEL_DEGRADED);
}
else
{
this.cbAllowPrinting.setSelectedIndex(CBMODEL_NOPRINTING);
}
}
}
/**
* Defines the filename of the pdf file.
*
* @return the name of the file where to save the pdf file.
*/
public String getFilename()
{
return txFilename.getText();
}
/**
* Defines the filename of the pdf file.
*
* @param filename the filename of the pdf file
*/
public void setFilename(final String filename)
{
this.txFilename.setText(filename);
}
/**
* Defines the title of the pdf file.
*
* @return the title
*/
public String getPDFTitle()
{
return txTitle.getText();
}
/**
* Defines the title of the pdf file.
*
* @param title the title
*/
public void setPDFTitle(final String title)
{
this.txTitle.setText(title);
}
/**
* Gets the author of this report.
*
* @return the name of the author of this report.
*/
public String getAuthor()
{
return txAuthor.getText();
}
/**
* Defines the Author of the report. Any freeform text is valid. This defaults to the value of
* the systemProperty "user.name".
*
* @param author the name of the author.
*/
public void setAuthor(final String author)
{
this.txAuthor.setText(author);
}
/**
* Queries the currently selected encryption. If an encryption is selected this method returns
* either Boolean.TRUE or Boolean.FALSE, when no encryption is set, <code>null</code> is
* returned. If no encryption is set, the security properties have no defined state.
*
* @return the selection state for the encryption. If no encryption is set, this method returns
* null, if 40-bit encryption is set, the method returns Boolean.FALSE and on 128-Bit-encryption,
* Boolean.TRUE is returned.
*/
public String getEncryptionValue()
{
if (rbSecurity40Bit.isSelected())
{
return PDFOutputTarget.SECURITY_ENCRYPTION_40BIT;
}
if (rbSecurity128Bit.isSelected())
{
return PDFOutputTarget.SECURITY_ENCRYPTION_128BIT;
}
return PDFOutputTarget.SECURITY_ENCRYPTION_NONE;
}
/**
* Defines the currently selected encryption.
*
* @param b the new encryption state, one of null, Boolean.TRUE or Boolean.FALSE
*/
public void setEncryptionValue(final String b)
{
if (b != null)
{
if (b.equals(PDFOutputTarget.SECURITY_ENCRYPTION_128BIT))
{
rbSecurity128Bit.setSelected(true);
updateSecurityPanelEnabled();
return;
}
else if (b.equals(PDFOutputTarget.SECURITY_ENCRYPTION_40BIT))
{
rbSecurity40Bit.setSelected(true);
updateSecurityPanelEnabled();
return;
}
else
{
Log.warn ("Invalid encryption value entered.");
}
}
rbSecurityNone.setSelected(true);
updateSecurityPanelEnabled();
}
/**
* Gets the confirmation state of the dialog. A confirmed dialog has no invalid
* settings and the user confirmed any resource conflicts.
*
* @return true, if the dialog has been confirmed and the pdf should be saved, false otherwise.
*/
public boolean isConfirmed()
{
return confirmed;
}
/**
* Defines whether this dialog has been finished using the 'OK' or the 'Cancel' option.
*
* @param confirmed set to true, if OK was pressed, false otherwise
*/
protected void setConfirmed(final boolean confirmed)
{
this.confirmed = confirmed;
}
/**
* Clears all selections, input fields and set the selected encryption level to none.
*/
public void clear()
{
txAuthor.setText(System.getProperty("user.name"));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -