From 683f42f194a30e70d4d09f4bac779d15526e1436 Mon Sep 17 00:00:00 2001 From: Tobias Kellner Date: Fri, 12 Dec 2014 13:48:28 +0100 Subject: Make PDF/A compatibility configurable --- .../composites/AdvancedConfigurationComposite.java | 47 +++++++++++++++++++--- .../gui/composites/ConfigurationComposite.java | 17 +++++--- .../composites/SimpleConfigurationComposite.java | 45 ++++++++------------- 3 files changed, 68 insertions(+), 41 deletions(-) (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites') diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java index 548d5767..8ca12de1 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java @@ -73,6 +73,7 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite { private Group grpSignatur; Button btnAutomatischePositionierung; + Button btnPdfACompat; private Label lblTransparenz; private Label lblTransparenzLinks; private Label lblTransparenzRechts; @@ -162,10 +163,36 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite { } }); + this.btnPdfACompat = new Button(this.grpSignatur, SWT.CHECK); + FormData fd_btnPdfACompat = new FormData(); + fd_btnPdfACompat.right = new FormAttachment(100, -5); + fd_btnPdfACompat.top = new FormAttachment( + this.btnAutomatischePositionierung, 5); + fd_btnPdfACompat.left = new FormAttachment(0, 5); + this.btnPdfACompat + .setLayoutData(fd_btnPdfACompat); + + FontData[] fD_btnPdfACompat = this.btnPdfACompat + .getFont().getFontData(); + fD_btnPdfACompat[0] + .setHeight(Constants.TEXT_SIZE_BUTTON); + this.btnPdfACompat.setFont(new Font(Display + .getCurrent(), fD_btnPdfACompat[0])); + + this.btnPdfACompat + .addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + AdvancedConfigurationComposite.this + .performPdfACompatSelection(AdvancedConfigurationComposite.this.btnPdfACompat + .getSelection()); + } + }); + this.lblTransparenz = new Label(this.grpSignatur, SWT.HORIZONTAL); FormData fd_lblTransparenz = new FormData(); fd_lblTransparenz.top = new FormAttachment( - this.btnAutomatischePositionierung, 5); + this.btnPdfACompat, 5); fd_lblTransparenz.left = new FormAttachment(0, 5); this.lblTransparenz.setLayoutData(fd_lblTransparenz); @@ -775,6 +802,11 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite { this.btnAutomatischePositionierung.setSelection(automatic); } + void performPdfACompatSelection(boolean compat) { + this.configurationContainer.setSignaturePdfACompat(compat); + this.btnPdfACompat.setSelection(compat); + } + void performPlaceholderTransparency(int transparency) { this.configurationContainer.setPlaceholderTransparency(transparency); } @@ -890,19 +922,20 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite { @Override public void loadConfiguration() { // load advanced settings - this.performBKUSelectionChanged(this.configurationContainer + performBKUSelectionChanged(this.configurationContainer .getDefaultBKU()); String outputFolder = this.configurationContainer.getOutputFolder(); if (outputFolder != null) { - this.performOutputFolderChanged(outputFolder); + performOutputFolderChanged(outputFolder); } SignaturePosition pos = this.configurationContainer .getDefaultSignaturePosition(); - this.performPositionSelection(pos != null && pos.useAutoPositioning()); + performPositionSelection(pos != null && pos.useAutoPositioning()); this.sclTransparenz.setSelection(this.configurationContainer .getPlaceholderTransparency()); - this.performLocaleSelectionChanged(this.configurationContainer.getLocale()); - this.performUpdateCheckSelection(this.configurationContainer.getUpdateCheck()); + performLocaleSelectionChanged(this.configurationContainer.getLocale()); + performPdfACompatSelection(this.configurationContainer.getSignaturePdfACompat()); + performUpdateCheckSelection(this.configurationContainer.getUpdateCheck()); int port = this.configurationContainer.getProxyPort(); if (port > 0) { @@ -972,6 +1005,8 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite { .getString("advanced_config.Signature_Title")); //$NON-NLS-1$ this.btnAutomatischePositionierung.setText(Messages .getString("advanced_config.AutoPosition")); //$NON-NLS-1$ + this.btnPdfACompat.setText(Messages + .getString("advanced_config.PdfACompat")); //$NON-NLS-1$ this.btnAutomatischePositionierung.setToolTipText(Messages .getString("advanced_config.AutoPosition_ToolTip")); //$NON-NLS-1$ this.lblTransparenz.setText(Messages diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java index 2f8abadb..407b493b 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java @@ -288,11 +288,13 @@ public class ConfigurationComposite extends StateComposite { this.configurationContainer.setSignatureNote( this.configProvider.getSignatureNote()); - + this.configurationContainer.setLocale(this.configProvider.getLocale()); - - this.configurationContainer.setSignLocale(this.configProvider.getSignLocale()); - + + this.configurationContainer.setSignatureLocale(this.configProvider.getSignatureLocale()); + + this.configurationContainer.setSignaturePdfACompat(this.configProvider.getSignaturePdfACompat()); + this.configurationContainer.setDefaultBKU(this.configProvider .getDefaultBKUPersistent()); try { @@ -410,8 +412,11 @@ public class ConfigurationComposite extends StateComposite { .setDefaultSignaturePosition(this.configurationContainer.getDefaultSignaturePosition()); this.configManipulator.setLocale(this.configurationContainer.getLocale()); - this.configManipulator.setSignLocale(this.configurationContainer.getSignLocale()); - + + this.configManipulator.setSignatureLocale(this.configurationContainer.getSignatureLocale()); + + this.configManipulator.setSignaturePdfACompat(this.configurationContainer.getSignaturePdfACompat()); + this.configManipulator .setPlaceholderTransparency(this.configurationContainer .getPlaceholderTransparency()); diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java index a5e0461e..9f1f53a5 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java @@ -420,7 +420,7 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite { @Override public void widgetSelected(SelectionEvent e) { Locale currentLocale = SimpleConfigurationComposite.this.configurationContainer - .getSignLocale(); + .getSignatureLocale(); Locale selectedLocale = Constants. SUPPORTED_LOCALES[SimpleConfigurationComposite.this.cmbSignatureLang .getSelectionIndex()]; @@ -512,7 +512,7 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite { public void widgetSelected(SelectionEvent e) { SimpleConfigurationComposite.this.txtSignatureNote.setText( Messages.getString("simple_config.Note_Default", //$NON-NLS-1$ - SimpleConfigurationComposite.this.configurationContainer.getSignLocale())); + SimpleConfigurationComposite.this.configurationContainer.getSignatureLocale())); } }); @@ -663,34 +663,21 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite { ImageData logo = null; try { - - if (image == null || image.trim().isEmpty()) { - if (this.signer != null) { - SignatureParameter param = this.signer.getPDFSigner() - .newParameter(); - if(this.configurationContainer.getSignatureNote() != null && !this.configurationContainer.getSignatureNote().isEmpty()) { - param.setProperty("SIG_NOTE", this.configurationContainer.getSignatureNote()); //$NON-NLS-1$ - } - - param.setSignatureLanguage(this.configurationContainer.getSignLocale().getLanguage()); - - img = SignaturePlaceholderCache.getSWTPlaceholder(param); + if (this.signer != null) { + SignatureParameter param = this.signer.getPDFSigner() + .newParameter(); + if(this.configurationContainer.getSignatureNote() != null && !this.configurationContainer.getSignatureNote().isEmpty()) { + param.setProperty("SIG_NOTE", this.configurationContainer.getSignatureNote()); //$NON-NLS-1$ } - } else { - if (this.signer != null) { - SignatureParameter param = this.signer.getPDFSigner() - .newParameter(); - if(this.configurationContainer.getSignatureNote() != null && !this.configurationContainer.getSignatureNote().isEmpty()) { - param.setProperty("SIG_NOTE", this.configurationContainer.getSignatureNote()); //$NON-NLS-1$ - } - - param.setSignatureLanguage(this.configurationContainer.getSignLocale().getLanguage()); + + param.setSignatureLanguage(this.configurationContainer.getSignatureLocale().getLanguage()); + param.setSignaturePdfACompat(this.configurationContainer.getSignaturePdfACompat()); + if (image != null && !image.trim().isEmpty()) { + logo = new ImageData(image); param.setEmblem(new FileNameEmblem(image)); - img = SignaturePlaceholderCache.getSWTPlaceholder(param); - } else { - img = new ImageData(image); } - logo = new ImageData(image); + + img = SignaturePlaceholderCache.getSWTPlaceholder(param); } } catch (Exception e) { log.error("Failed to load image for display...", e); //$NON-NLS-1$ @@ -751,7 +738,7 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite { void performSignatureLangSelectionChanged(Locale selected) { log.debug("Selected Sign Locale: " + selected); //$NON-NLS-1$ - this.configurationContainer.setSignLocale(selected); + this.configurationContainer.setSignatureLocale(selected); this.cmbSignatureLang.select(this.getLocaleElementIndex(selected)); } @@ -850,7 +837,7 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite { this.setVisibleImage(); - this.performSignatureLangSelectionChanged(this.configurationContainer.getSignLocale()); + this.performSignatureLangSelectionChanged(this.configurationContainer.getSignatureLocale()); } /* -- cgit v1.2.3