diff options
Diffstat (limited to 'src/main/java/at')
3 files changed, 56 insertions, 4 deletions
diff --git a/src/main/java/at/gv/egiz/pdfas/api/PdfAs.java b/src/main/java/at/gv/egiz/pdfas/api/PdfAs.java index 26bbace..286377b 100644 --- a/src/main/java/at/gv/egiz/pdfas/api/PdfAs.java +++ b/src/main/java/at/gv/egiz/pdfas/api/PdfAs.java @@ -7,7 +7,6 @@ import java.util.List; import at.gv.egiz.pdfas.api.analyze.AnalyzeParameters;
import at.gv.egiz.pdfas.api.analyze.AnalyzeResult;
-import at.gv.egiz.pdfas.api.analyze.NonTextObjectInfo;
import at.gv.egiz.pdfas.api.commons.DynamicSignatureLifetimeEnum;
import at.gv.egiz.pdfas.api.commons.DynamicSignatureProfile;
import at.gv.egiz.pdfas.api.commons.SignatureProfile;
@@ -15,7 +14,6 @@ import at.gv.egiz.pdfas.api.exceptions.PdfAsException; import at.gv.egiz.pdfas.api.sign.SignParameters;
import at.gv.egiz.pdfas.api.sign.SignResult;
import at.gv.egiz.pdfas.api.sign.SignatureDetailInformation;
-import at.gv.egiz.pdfas.api.sign.pos.SignaturePosition;
import at.gv.egiz.pdfas.api.verify.VerifyAfterAnalysisParameters;
import at.gv.egiz.pdfas.api.verify.VerifyAfterReconstructXMLDsigParameters;
import at.gv.egiz.pdfas.api.verify.VerifyParameters;
@@ -24,6 +22,7 @@ import at.gv.egiz.pdfas.api.verify.VerifyResults; import at.gv.egiz.pdfas.api.xmldsig.ReconstructXMLDsigAfterAnalysisParameters;
import at.gv.egiz.pdfas.api.xmldsig.ReconstructXMLDsigParameters;
import at.gv.egiz.pdfas.api.xmldsig.ReconstructXMLDsigResult;
+import at.gv.egiz.pdfas.framework.signator.SignatorInformation;
/**
* The PDF-AS API main interface.
@@ -196,6 +195,7 @@ public interface PdfAs * Create a signature profile dynamically. You have to provide a unique name and have do apply() it for usage. See {@link SignatureProfile}.
* It is recommended to use {@link #createDynamicSignatureProfile(String, DynamicSignatureLifetimeEnum)} that generates
* a unique name on its own.
+ * @see DynamicSignatureProfile
* @param parentProfile a parent profile id to inherit all properties
* @param myUniqueName a unique name for the profile
* @param mode lifetime mode
@@ -210,6 +210,7 @@ public interface PdfAs * existing profile saving you a lot of work.
* @param mode lifetime mode
* @return the created signature profile to work with.
+ * @see DynamicSignatureProfile
*/
public DynamicSignatureProfile createEmptyDynamicSignatureProfile(DynamicSignatureLifetimeEnum mode);
@@ -229,6 +230,7 @@ public interface PdfAs * and it has {@link DynamicSignatureLifetimeEnum#MANUAL}
* @param profileName
* @return the signature profile or <code>null</code> if not found.
+ * @see DynamicSignatureProfile
*/
public DynamicSignatureProfile loadDynamicSignatureProfile(String profileName);
diff --git a/src/main/java/at/gv/egiz/pdfas/api/commons/DynamicSignatureProfile.java b/src/main/java/at/gv/egiz/pdfas/api/commons/DynamicSignatureProfile.java index fbcfaf9..b3875db 100644 --- a/src/main/java/at/gv/egiz/pdfas/api/commons/DynamicSignatureProfile.java +++ b/src/main/java/at/gv/egiz/pdfas/api/commons/DynamicSignatureProfile.java @@ -9,7 +9,41 @@ import at.gv.egiz.pdfas.api.sign.SignParameters; * or {@link #setFieldValue(String, String)}.<br>
* You have to call {@link #apply()} to use the profile. The identifying name (e.g. for {@link SignParameters#setSignatureProfileId(String)}
* can be obtained via {@link #getName()}.<br>
- * Depending on the {@link DynamicSignatureLifetimeEnum} the profile can be alive and usable till you {@link #dispose()} it manually.
+ * Depending on the {@link DynamicSignatureLifetimeEnum} the profile can be alive and usable till you {@link #dispose()} it manually.
+ * <p>
+ * Sample usage:<br>
+ * <pre>
+ SignParameters sp = new SignParameters();
+ . . .
+ sp.setSignatureType(Constants.SIGNATURE_TYPE_TEXTUAL);
+ sp.setSignatureDevice(Constants.SIGNATURE_DEVICE_MOA);
+
+ // create a new dynamic profile based on SIGNATURBLOCK_DE (every property is copied) with manual lifetime
+ DynamicSignatureProfile dsp = pdfAs.createDynamicSignatureProfile("myUniqueName", "SIGNATURBLOCK_DE",
+ DynamicSignatureLifetimeEnum.MANUAL);
+
+ // set something
+ dsp.setPropertyRaw("key.SIG_META", "Statement");
+ dsp.setPropertyRaw("value.SIG_META", "respect to the man in the icecream van ${subject.EMAIL}");
+ dsp.setPropertyRaw("value.SIG_LABEL", "./images/signatur-logo_en.png");
+ dsp.setPropertyRaw("table.main.Style.halign", "right");
+
+ // mandatory: apply the profile, you have to apply again after changes (overriding your previous setting)
+ dsp.apply();
+ sp.setSignatureProfileId(dsp.getName());
+
+ // execute PDF-AS
+ pdfAs.sign(sp);
+
+ . . .
+
+ // your profile is saved and you can obtain it again anytime later:
+ dsp = pdfAs.loadDynamicSignatureProfile("myUniqueName");
+ // use it for another sign.
+ // dont forget to dispose() sometimes because it was manual lifetime
+ System.out.println(dsp.getName());
+ * </pre>
+ * </p>
*
* @author exthex
*
diff --git a/src/main/java/at/gv/egiz/pdfas/api/sign/SignParameters.java b/src/main/java/at/gv/egiz/pdfas/api/sign/SignParameters.java index 9a01c72..8dc928b 100644 --- a/src/main/java/at/gv/egiz/pdfas/api/sign/SignParameters.java +++ b/src/main/java/at/gv/egiz/pdfas/api/sign/SignParameters.java @@ -286,7 +286,23 @@ public class SignParameters /**
* Override user defined values from the used signature profile like "value.SIG_META".
* You cannot override pre defined values like SIG_VALUE, SIG_DATE {@link SignatureTypes#REQUIRED_SIG_KEYS}.
- * The override values are bound to the {@link SignParameters} instance.
+ * The override values are bound to the {@link SignParameters} instance.
+ * <p>
+ * Sample usage:
+ * <pre>
+ SignParameters sp = new SignParameters();
+ . . .
+
+ sp.setSignatureProfileId("SIGNATURBLOCK_DE");
+
+ // expressions do not work on binary signature fields without phlength setting!!
+ sp.setProfileOverrideValue("SIG_META", "It's nice to be important, but it is more important to be nice ${subject.L}");;
+ sp.setProfileOverrideValue("SIG_LABEL", "./images/signatur-logo_en.png");
+
+ // execute sign using the overrides
+ pdfAs.sign(sp);
+ </pre>
+ * </p>
* @param key the name of the setting to override e.g. "SIG_META"
* @param value The new value
*/
|