feat(pdf): suporte a redimensionamento interativo e proporcional do selo de assinatura
This commit is contained in:
+27
-4
@@ -25,7 +25,8 @@ public record PdfSignatureOptions(
|
||||
Integer targetPageNumber,
|
||||
CpfDisplayMode cpfDisplayMode,
|
||||
Boolean includeDateTime,
|
||||
String customExtraInfo
|
||||
String customExtraInfo,
|
||||
Double customSealScale
|
||||
) {
|
||||
|
||||
public PdfSignatureOptions {
|
||||
@@ -51,6 +52,21 @@ public record PdfSignatureOptions(
|
||||
if (includeDateTime == null) {
|
||||
includeDateTime = sealTheme.defaultIncludeDateTime();
|
||||
}
|
||||
if (customSealScale == null || customSealScale <= 0) {
|
||||
customSealScale = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construtor para compatibilidade com assinaturas anteriores a customSealScale.
|
||||
*/
|
||||
public PdfSignatureOptions(String certificateId, char[] pinOrPassword, boolean visibleSeal,
|
||||
PdfSealTheme sealTheme, PdfSealPosition position, PdfSealPageChoice pageChoice,
|
||||
String reason, String location, Float customX, Float customY,
|
||||
Integer targetPageNumber, CpfDisplayMode cpfDisplayMode, Boolean includeDateTime,
|
||||
String customExtraInfo) {
|
||||
this(certificateId, pinOrPassword, visibleSeal, sealTheme, position, pageChoice, reason, location,
|
||||
customX, customY, targetPageNumber, cpfDisplayMode, includeDateTime, customExtraInfo, 1.0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,7 +77,7 @@ public record PdfSignatureOptions(
|
||||
String reason, String location, Float customX, Float customY,
|
||||
Integer targetPageNumber, CpfDisplayMode cpfDisplayMode, Boolean includeDateTime) {
|
||||
this(certificateId, pinOrPassword, visibleSeal, sealTheme, position, pageChoice, reason, location,
|
||||
customX, customY, targetPageNumber, cpfDisplayMode, includeDateTime, null);
|
||||
customX, customY, targetPageNumber, cpfDisplayMode, includeDateTime, null, 1.0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,7 +86,7 @@ public record PdfSignatureOptions(
|
||||
public PdfSignatureOptions(String certificateId, char[] pinOrPassword, boolean visibleSeal,
|
||||
PdfSealTheme sealTheme, PdfSealPosition position, PdfSealPageChoice pageChoice,
|
||||
String reason, String location) {
|
||||
this(certificateId, pinOrPassword, visibleSeal, sealTheme, position, pageChoice, reason, location, null, null, null, null, null, null);
|
||||
this(certificateId, pinOrPassword, visibleSeal, sealTheme, position, pageChoice, reason, location, null, null, null, null, null, null, 1.0);
|
||||
}
|
||||
|
||||
public PdfSignatureOptions(String certificateId, char[] pinOrPassword, boolean visibleSeal,
|
||||
@@ -143,6 +159,7 @@ public record PdfSignatureOptions(
|
||||
}
|
||||
|
||||
private String customExtraInfo;
|
||||
private Double customSealScale = 1.0;
|
||||
|
||||
public Builder includeDateTime(boolean include) {
|
||||
this.includeDateTime = include;
|
||||
@@ -154,6 +171,11 @@ public record PdfSignatureOptions(
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder customSealScale(Double scale) {
|
||||
this.customSealScale = scale;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder customPosition(Float x, Float y, Integer pageNumber) {
|
||||
this.customX = x;
|
||||
this.customY = y;
|
||||
@@ -179,7 +201,8 @@ public record PdfSignatureOptions(
|
||||
targetPageNumber,
|
||||
cpfDisplayMode,
|
||||
includeDateTime,
|
||||
customExtraInfo
|
||||
customExtraInfo,
|
||||
customSealScale
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-2
@@ -235,8 +235,11 @@ public class PdfSigningService {
|
||||
|
||||
PDImageXObject pdImage = PDImageXObject.createFromByteArray(doc, sealPng, "cybercore_seal");
|
||||
|
||||
float sealWidth = theme.width() * 0.72f;
|
||||
float sealHeight = theme.height() * 0.72f;
|
||||
float scale = (options.customSealScale() != null && options.customSealScale() > 0)
|
||||
? options.customSealScale().floatValue()
|
||||
: 1.0f;
|
||||
float sealWidth = (theme.width() * 0.72f) * scale;
|
||||
float sealHeight = (theme.height() * 0.72f) * scale;
|
||||
float margin = 20f;
|
||||
|
||||
// Se coordenadas customizadas foram informadas (clique ou drag & drop na página)
|
||||
|
||||
Reference in New Issue
Block a user