deps(embedPDF): Bump codebase to embedPDF v2.3.0 and adjust codebase for new features (#5567)

# Description of Changes

<!--
Please provide a summary of the changes, including:

- What was changed
- Why the change was made
- Any challenges encountered

Closes #(issue_number)
-->

---

## Checklist

### General

- [ ] I have read the [Contribution
Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md)
- [ ] I have read the [Stirling-PDF Developer
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md)
(if applicable)
- [ ] I have read the [How to add new languages to
Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md)
(if applicable)
- [ ] I have performed a self-review of my own code
- [ ] My changes generate no new warnings

### Documentation

- [ ] I have updated relevant docs on [Stirling-PDF's doc
repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/)
(if functionality has heavily changed)
- [ ] I have read the section [Add New Translation
Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags)
(for new translation tags only)

### Translations (if applicable)

- [ ] I ran
[`scripts/counter_translation.py`](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/docs/counter_translation.md)

### UI Changes (if applicable)

- [ ] Screenshots or videos demonstrating the UI changes are attached
(e.g., as comments or direct attachments in the PR)

### Testing (if applicable)

- [ ] I have tested my changes locally. Refer to the [Testing
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing)
for more details.

---------

Signed-off-by: Balázs Szücs <[email protected]>
Co-authored-by: Anthony Stirling <[email protected]>
This commit is contained in:
Balázs Szücs
2026-01-28 16:10:43 +00:00
committed by GitHub
co-authored by Anthony Stirling
parent 7fc6ec5fe1
commit 5c7d675960
28 changed files with 1407 additions and 782 deletions
@@ -10,6 +10,7 @@ import type {
} from '@app/components/viewer/viewerTypes';
type NoteIcon = NonNullable<AnnotationToolOptions['icon']>;
type AnnotationDefaults =
| {
type:
@@ -17,13 +18,15 @@ type AnnotationDefaults =
| PdfAnnotationSubtype.UNDERLINE
| PdfAnnotationSubtype.STRIKEOUT
| PdfAnnotationSubtype.SQUIGGLY;
color: string;
strokeColor: string;
color?: string;
opacity: number;
customData?: Record<string, unknown>;
}
| {
type: PdfAnnotationSubtype.INK;
color: string;
strokeColor: string;
color?: string;
opacity?: number;
borderWidth?: number;
strokeWidth?: number;
@@ -37,7 +40,8 @@ type AnnotationDefaults =
fontFamily?: string;
textAlign?: number;
opacity?: number;
backgroundColor?: string;
color?: string;
interiorColor?: string;
borderWidth?: number;
contents?: string;
icon?: PdfAnnotationIcon;
@@ -106,7 +110,7 @@ const DEFAULTS = {
ink: '#1f2933',
inkHighlighter: '#ffd54f',
text: '#111111',
note: '#ffd54f', // match highlight color
note: '#ffd54f',
shapeFill: '#0000ff',
shapeStroke: '#cf5b5b',
shapeOpacity: 0.5,
@@ -124,42 +128,62 @@ const buildStampDefaults: ToolDefaultsBuilder = (options) => ({
...withCustomData(options),
});
const buildInkDefaults = (options?: AnnotationToolOptions, opacityOverride?: number): AnnotationDefaults => ({
type: PdfAnnotationSubtype.INK,
color: options?.color ?? (opacityOverride ? DEFAULTS.inkHighlighter : DEFAULTS.ink),
opacity: options?.opacity ?? opacityOverride ?? 1,
borderWidth: options?.thickness ?? (opacityOverride ? 6 : 2),
strokeWidth: options?.thickness ?? (opacityOverride ? 6 : 2),
lineWidth: options?.thickness ?? (opacityOverride ? 6 : 2),
...withCustomData(options),
});
const buildInkDefaults = (options?: AnnotationToolOptions, opacityOverride?: number): AnnotationDefaults => {
const colorValue = options?.color ?? (opacityOverride ? DEFAULTS.inkHighlighter : DEFAULTS.ink);
return {
type: PdfAnnotationSubtype.INK,
strokeColor: colorValue,
color: colorValue,
opacity: options?.opacity ?? opacityOverride ?? 1,
borderWidth: options?.thickness ?? (opacityOverride ? 6 : 2),
strokeWidth: options?.thickness ?? (opacityOverride ? 6 : 2),
lineWidth: options?.thickness ?? (opacityOverride ? 6 : 2),
...withCustomData(options),
};
};
const TOOL_DEFAULT_BUILDERS: Record<AnnotationToolId, ToolDefaultsBuilder> = {
select: () => null,
highlight: (options) => ({
type: PdfAnnotationSubtype.HIGHLIGHT,
color: options?.color ?? DEFAULTS.highlight,
opacity: options?.opacity ?? 0.6,
...withCustomData(options),
}),
underline: (options) => ({
type: PdfAnnotationSubtype.UNDERLINE,
color: options?.color ?? DEFAULTS.underline,
opacity: options?.opacity ?? 1,
...withCustomData(options),
}),
strikeout: (options) => ({
type: PdfAnnotationSubtype.STRIKEOUT,
color: options?.color ?? DEFAULTS.strikeout,
opacity: options?.opacity ?? 1,
...withCustomData(options),
}),
squiggly: (options) => ({
type: PdfAnnotationSubtype.SQUIGGLY,
color: options?.color ?? DEFAULTS.squiggly,
opacity: options?.opacity ?? 1,
...withCustomData(options),
}),
highlight: (options) => {
const colorValue = options?.color ?? DEFAULTS.highlight;
return {
type: PdfAnnotationSubtype.HIGHLIGHT,
strokeColor: colorValue,
color: colorValue,
opacity: options?.opacity ?? 0.6,
...withCustomData(options),
};
},
underline: (options) => {
const colorValue = options?.color ?? DEFAULTS.underline;
return {
type: PdfAnnotationSubtype.UNDERLINE,
strokeColor: colorValue,
color: colorValue,
opacity: options?.opacity ?? 1,
...withCustomData(options),
};
},
strikeout: (options) => {
const colorValue = options?.color ?? DEFAULTS.strikeout;
return {
type: PdfAnnotationSubtype.STRIKEOUT,
strokeColor: colorValue,
color: colorValue,
opacity: options?.opacity ?? 1,
...withCustomData(options),
};
},
squiggly: (options) => {
const colorValue = options?.color ?? DEFAULTS.squiggly;
return {
type: PdfAnnotationSubtype.SQUIGGLY,
strokeColor: colorValue,
color: colorValue,
opacity: options?.opacity ?? 1,
...withCustomData(options),
};
},
ink: (options) => buildInkDefaults(options),
inkHighlighter: (options) => buildInkDefaults(options, options?.opacity ?? 0.6),
text: (options) => ({
@@ -170,21 +194,21 @@ const TOOL_DEFAULT_BUILDERS: Record<AnnotationToolId, ToolDefaultsBuilder> = {
textAlign: options?.textAlign ?? 0,
opacity: options?.opacity ?? 1,
borderWidth: options?.thickness ?? 1,
...(options?.fillColor ? { backgroundColor: options.fillColor } : {}),
...(options?.fillColor ? { color: options.fillColor, interiorColor: options.fillColor } : {}),
...withCustomData(options),
}),
note: (options) => {
const backgroundColor = options?.fillColor ?? DEFAULTS.note;
const bgColor = options?.fillColor ?? DEFAULTS.note;
const fontColor = options?.color ?? DEFAULTS.text;
return {
type: PdfAnnotationSubtype.FREETEXT,
fontColor,
color: fontColor,
fontFamily: options?.fontFamily ?? 'Helvetica',
textAlign: options?.textAlign ?? 0,
fontSize: options?.fontSize ?? 12,
opacity: options?.opacity ?? 1,
backgroundColor,
color: bgColor,
interiorColor: bgColor,
borderWidth: options?.thickness ?? 0,
contents: options?.contents ?? 'Note',
icon: getIconEnum(options?.icon),
@@ -317,7 +341,11 @@ export const AnnotationAPIBridge = forwardRef<AnnotationAPI>(function Annotation
// `this`/state dependency (e.g. reading `selectedUid` from undefined).
// If that happens, fail gracefully and treat it as "no selection"
// instead of crashing the entire annotations tool.
console.error('[AnnotationAPIBridge] getSelectedAnnotation failed:', error);
// Only log unexpected errors - "No active document" is a common expected state during init
const errorMessage = error instanceof Error ? error.message : String(error);
if (!errorMessage.includes('No active document')) {
console.error('[AnnotationAPIBridge] getSelectedAnnotation failed:', error);
}
return null;
}
},