@embedpdf/engines 1.0.13 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/engine-1ZSXSAtm.cjs +2 -0
- package/dist/engine-1ZSXSAtm.cjs.map +1 -0
- package/dist/{engine-B0ZTENqz.js → engine-O49988D4.js} +303 -174
- package/dist/engine-O49988D4.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -5
- package/dist/index.js.map +1 -1
- package/dist/lib/pdfium/engine.d.ts +79 -29
- package/dist/lib/pdfium/index.cjs +1 -1
- package/dist/lib/pdfium/index.js +2 -2
- package/dist/lib/pdfium/web/direct-engine.cjs +1 -1
- package/dist/lib/pdfium/web/direct-engine.js +1 -1
- package/dist/lib/pdfium/web/worker-engine.cjs +1 -1
- package/dist/lib/pdfium/web/worker-engine.js +1 -1
- package/dist/lib/webworker/engine.cjs +1 -1
- package/dist/lib/webworker/engine.cjs.map +1 -1
- package/dist/lib/webworker/engine.d.ts +1 -2
- package/dist/lib/webworker/engine.js +1 -16
- package/dist/lib/webworker/engine.js.map +1 -1
- package/dist/preact/index.cjs +1 -1
- package/dist/preact/index.js +1 -1
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.js +1 -1
- package/dist/runner-Br_PKNmU.cjs +2 -0
- package/dist/{runner-BBBtCHic.cjs.map → runner-Br_PKNmU.cjs.map} +1 -1
- package/dist/{runner-B-s0R7NN.js → runner-CABEqeFp.js} +2 -5
- package/dist/{runner-B-s0R7NN.js.map → runner-CABEqeFp.js.map} +1 -1
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.js +1 -1
- package/package.json +3 -3
- package/dist/engine-B0ZTENqz.js.map +0 -1
- package/dist/engine-BB5n-Wej.cjs +0 -2
- package/dist/engine-BB5n-Wej.cjs.map +0 -1
- package/dist/runner-BBBtCHic.cjs +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NoopLogger, PdfTaskHelper, PdfErrorCode, Rotation, Task, PdfAnnotationSubtype, stripPdfUnwantedMarkers, PdfAnnotationBorderStyle, dateToPdfDate, PdfAnnotationColorType, PdfAnnotationLineEnding, PdfPageObjectType,
|
|
1
|
+
import { NoopLogger, PdfTaskHelper, PdfErrorCode, Rotation, Task, PdfAnnotationSubtype, stripPdfUnwantedMarkers, PdfAnnotationBorderStyle, dateToPdfDate, PdfAnnotationColorType, PdfAnnotationLineEnding, PdfPageObjectType, pdfColorToWebColor, webColorToPdfColor, pdfAlphaToWebOpacity, webOpacityToPdfAlpha, quadToRect, pdfDateToDate, PdfStandardFont, flagsToNames, namesToFlags, PDF_FORM_FIELD_TYPE, AppearanceMode, toIntRect, transformRect, makeMatrix, toIntSize, transformSize, PdfActionType, PdfZoomMode, MatchFlag, rectToQuad } from "@embedpdf/models";
|
|
2
2
|
function readString(wasmModule, readChars, parseChars, defaultLength = 100) {
|
|
3
3
|
let buffer = wasmModule.wasmExports.malloc(defaultLength);
|
|
4
4
|
for (let i = 0; i < defaultLength; i++) {
|
|
@@ -982,6 +982,9 @@ class PdfiumEngine {
|
|
|
982
982
|
annotation.contents
|
|
983
983
|
);
|
|
984
984
|
break;
|
|
985
|
+
case PdfAnnotationSubtype.FREETEXT:
|
|
986
|
+
isSucceed = this.addFreeTextContent(page, pageCtx.pagePtr, annotationPtr, annotation);
|
|
987
|
+
break;
|
|
985
988
|
case PdfAnnotationSubtype.LINE:
|
|
986
989
|
isSucceed = this.addLineContent(page, pageCtx.pagePtr, annotationPtr, annotation);
|
|
987
990
|
break;
|
|
@@ -1119,6 +1122,11 @@ class PdfiumEngine {
|
|
|
1119
1122
|
);
|
|
1120
1123
|
break;
|
|
1121
1124
|
}
|
|
1125
|
+
/* ── Free text ────────────────────────────────────────────────────────── */
|
|
1126
|
+
case PdfAnnotationSubtype.FREETEXT: {
|
|
1127
|
+
ok = this.addFreeTextContent(page, pageCtx.pagePtr, annotPtr, annotation);
|
|
1128
|
+
break;
|
|
1129
|
+
}
|
|
1122
1130
|
/* ── Shape ───────────────────────────────────────────────────────────── */
|
|
1123
1131
|
case PdfAnnotationSubtype.CIRCLE:
|
|
1124
1132
|
case PdfAnnotationSubtype.SQUARE: {
|
|
@@ -1920,6 +1928,55 @@ class PdfiumEngine {
|
|
|
1920
1928
|
free(ptr) {
|
|
1921
1929
|
this.pdfiumModule.pdfium.wasmExports.free(ptr);
|
|
1922
1930
|
}
|
|
1931
|
+
addFreeTextContent(page, pagePtr, annotationPtr, annotation) {
|
|
1932
|
+
if (!this.setBorderStyle(annotationPtr, PdfAnnotationBorderStyle.SOLID, 0)) {
|
|
1933
|
+
return false;
|
|
1934
|
+
}
|
|
1935
|
+
if (!this.setAnnotString(annotationPtr, "Contents", annotation.contents ?? "")) {
|
|
1936
|
+
return false;
|
|
1937
|
+
}
|
|
1938
|
+
if (!this.setPageAnnoRect(page, pagePtr, annotationPtr, annotation.rect)) {
|
|
1939
|
+
return false;
|
|
1940
|
+
}
|
|
1941
|
+
if (!this.setAnnotString(annotationPtr, "T", annotation.author || "")) {
|
|
1942
|
+
return false;
|
|
1943
|
+
}
|
|
1944
|
+
if (!this.setAnnotString(annotationPtr, "M", dateToPdfDate(annotation.modified))) {
|
|
1945
|
+
return false;
|
|
1946
|
+
}
|
|
1947
|
+
if (!this.setAnnotationOpacity(annotationPtr, annotation.opacity ?? 1)) {
|
|
1948
|
+
return false;
|
|
1949
|
+
}
|
|
1950
|
+
if (!this.setAnnotationTextAlignment(annotationPtr, annotation.textAlign)) {
|
|
1951
|
+
return false;
|
|
1952
|
+
}
|
|
1953
|
+
if (!this.setAnnotationVerticalAlignment(annotationPtr, annotation.verticalAlign)) {
|
|
1954
|
+
return false;
|
|
1955
|
+
}
|
|
1956
|
+
if (!this.setAnnotationDefaultAppearance(
|
|
1957
|
+
annotationPtr,
|
|
1958
|
+
annotation.fontFamily,
|
|
1959
|
+
annotation.fontSize,
|
|
1960
|
+
annotation.fontColor
|
|
1961
|
+
)) {
|
|
1962
|
+
return false;
|
|
1963
|
+
}
|
|
1964
|
+
if (annotation.intent && !this.setAnnotIntent(annotationPtr, annotation.intent)) {
|
|
1965
|
+
return false;
|
|
1966
|
+
}
|
|
1967
|
+
if (!annotation.backgroundColor || annotation.backgroundColor === "transparent") {
|
|
1968
|
+
if (!this.pdfiumModule.EPDFAnnot_ClearColor(annotationPtr, PdfAnnotationColorType.Color)) {
|
|
1969
|
+
return false;
|
|
1970
|
+
}
|
|
1971
|
+
} else if (!this.setAnnotationColor(
|
|
1972
|
+
annotationPtr,
|
|
1973
|
+
annotation.backgroundColor ?? "#FFFFFF",
|
|
1974
|
+
PdfAnnotationColorType.Color
|
|
1975
|
+
)) {
|
|
1976
|
+
return false;
|
|
1977
|
+
}
|
|
1978
|
+
return true;
|
|
1979
|
+
}
|
|
1923
1980
|
/**
|
|
1924
1981
|
* Set the rect of specified annotation
|
|
1925
1982
|
* @param page - page info that the annotation is belonged to
|
|
@@ -1946,12 +2003,12 @@ class PdfiumEngine {
|
|
|
1946
2003
|
if (!this.setAnnotString(annotationPtr, "M", dateToPdfDate(annotation.modified))) {
|
|
1947
2004
|
return false;
|
|
1948
2005
|
}
|
|
2006
|
+
if (!this.setAnnotationOpacity(annotationPtr, annotation.opacity ?? 1)) {
|
|
2007
|
+
return false;
|
|
2008
|
+
}
|
|
1949
2009
|
if (!this.setAnnotationColor(
|
|
1950
2010
|
annotationPtr,
|
|
1951
|
-
|
|
1952
|
-
color: annotation.color ?? "#FFFF00",
|
|
1953
|
-
opacity: annotation.opacity ?? 1
|
|
1954
|
-
},
|
|
2011
|
+
annotation.color ?? "#FFFF00",
|
|
1955
2012
|
PdfAnnotationColorType.Color
|
|
1956
2013
|
)) {
|
|
1957
2014
|
return false;
|
|
@@ -2012,20 +2069,17 @@ class PdfiumEngine {
|
|
|
2012
2069
|
}
|
|
2013
2070
|
} else if (!this.setAnnotationColor(
|
|
2014
2071
|
annotationPtr,
|
|
2015
|
-
|
|
2016
|
-
color: annotation.color ?? "#FFFF00",
|
|
2017
|
-
opacity: annotation.opacity ?? 1
|
|
2018
|
-
},
|
|
2072
|
+
annotation.color ?? "#FFFF00",
|
|
2019
2073
|
PdfAnnotationColorType.InteriorColor
|
|
2020
2074
|
)) {
|
|
2021
2075
|
return false;
|
|
2022
2076
|
}
|
|
2077
|
+
if (!this.setAnnotationOpacity(annotationPtr, annotation.opacity ?? 1)) {
|
|
2078
|
+
return false;
|
|
2079
|
+
}
|
|
2023
2080
|
if (!this.setAnnotationColor(
|
|
2024
2081
|
annotationPtr,
|
|
2025
|
-
|
|
2026
|
-
color: annotation.strokeColor ?? "#FFFF00",
|
|
2027
|
-
opacity: annotation.opacity ?? 1
|
|
2028
|
-
},
|
|
2082
|
+
annotation.strokeColor ?? "#FFFF00",
|
|
2029
2083
|
PdfAnnotationColorType.Color
|
|
2030
2084
|
)) {
|
|
2031
2085
|
return false;
|
|
@@ -2081,20 +2135,17 @@ class PdfiumEngine {
|
|
|
2081
2135
|
}
|
|
2082
2136
|
} else if (!this.setAnnotationColor(
|
|
2083
2137
|
annotationPtr,
|
|
2084
|
-
|
|
2085
|
-
color: annotation.color ?? "#FFFF00",
|
|
2086
|
-
opacity: annotation.opacity ?? 1
|
|
2087
|
-
},
|
|
2138
|
+
annotation.color ?? "#FFFF00",
|
|
2088
2139
|
PdfAnnotationColorType.InteriorColor
|
|
2089
2140
|
)) {
|
|
2090
2141
|
return false;
|
|
2091
2142
|
}
|
|
2143
|
+
if (!this.setAnnotationOpacity(annotationPtr, annotation.opacity ?? 1)) {
|
|
2144
|
+
return false;
|
|
2145
|
+
}
|
|
2092
2146
|
if (!this.setAnnotationColor(
|
|
2093
2147
|
annotationPtr,
|
|
2094
|
-
|
|
2095
|
-
color: annotation.strokeColor ?? "#FFFF00",
|
|
2096
|
-
opacity: annotation.opacity ?? 1
|
|
2097
|
-
},
|
|
2148
|
+
annotation.strokeColor ?? "#FFFF00",
|
|
2098
2149
|
PdfAnnotationColorType.Color
|
|
2099
2150
|
)) {
|
|
2100
2151
|
return false;
|
|
@@ -2139,20 +2190,17 @@ class PdfiumEngine {
|
|
|
2139
2190
|
}
|
|
2140
2191
|
} else if (!this.setAnnotationColor(
|
|
2141
2192
|
annotationPtr,
|
|
2142
|
-
|
|
2143
|
-
color: annotation.color ?? "#FFFF00",
|
|
2144
|
-
opacity: annotation.opacity ?? 1
|
|
2145
|
-
},
|
|
2193
|
+
annotation.color ?? "#FFFF00",
|
|
2146
2194
|
PdfAnnotationColorType.InteriorColor
|
|
2147
2195
|
)) {
|
|
2148
2196
|
return false;
|
|
2149
2197
|
}
|
|
2198
|
+
if (!this.setAnnotationOpacity(annotationPtr, annotation.opacity ?? 1)) {
|
|
2199
|
+
return false;
|
|
2200
|
+
}
|
|
2150
2201
|
if (!this.setAnnotationColor(
|
|
2151
2202
|
annotationPtr,
|
|
2152
|
-
|
|
2153
|
-
color: annotation.strokeColor ?? "#FFFF00",
|
|
2154
|
-
opacity: annotation.opacity ?? 1
|
|
2155
|
-
},
|
|
2203
|
+
annotation.strokeColor ?? "#FFFF00",
|
|
2156
2204
|
PdfAnnotationColorType.Color
|
|
2157
2205
|
)) {
|
|
2158
2206
|
return false;
|
|
@@ -2184,12 +2232,12 @@ class PdfiumEngine {
|
|
|
2184
2232
|
if (!this.setAnnotString(annotationPtr, "M", dateToPdfDate(annotation.modified))) {
|
|
2185
2233
|
return false;
|
|
2186
2234
|
}
|
|
2235
|
+
if (!this.setAnnotationOpacity(annotationPtr, annotation.opacity ?? 1)) {
|
|
2236
|
+
return false;
|
|
2237
|
+
}
|
|
2187
2238
|
if (!this.setAnnotationColor(
|
|
2188
2239
|
annotationPtr,
|
|
2189
|
-
|
|
2190
|
-
color: annotation.color ?? "#FFFF00",
|
|
2191
|
-
opacity: annotation.opacity ?? 1
|
|
2192
|
-
},
|
|
2240
|
+
annotation.color ?? "#FFFF00",
|
|
2193
2241
|
PdfAnnotationColorType.Color
|
|
2194
2242
|
)) {
|
|
2195
2243
|
return false;
|
|
@@ -2953,41 +3001,32 @@ class PdfiumEngine {
|
|
|
2953
3001
|
const rPtr = this.malloc(4);
|
|
2954
3002
|
const gPtr = this.malloc(4);
|
|
2955
3003
|
const bPtr = this.malloc(4);
|
|
2956
|
-
const
|
|
2957
|
-
const ok = this.pdfiumModule.EPDFAnnot_GetColor(
|
|
2958
|
-
annotationPtr,
|
|
2959
|
-
colorType,
|
|
2960
|
-
rPtr,
|
|
2961
|
-
gPtr,
|
|
2962
|
-
bPtr,
|
|
2963
|
-
aPtr
|
|
2964
|
-
);
|
|
3004
|
+
const ok = this.pdfiumModule.EPDFAnnot_GetColor(annotationPtr, colorType, rPtr, gPtr, bPtr);
|
|
2965
3005
|
let colour;
|
|
2966
3006
|
if (ok) {
|
|
2967
3007
|
colour = {
|
|
2968
3008
|
red: this.pdfiumModule.pdfium.getValue(rPtr, "i32") & 255,
|
|
2969
3009
|
green: this.pdfiumModule.pdfium.getValue(gPtr, "i32") & 255,
|
|
2970
|
-
blue: this.pdfiumModule.pdfium.getValue(bPtr, "i32") & 255
|
|
2971
|
-
alpha: this.pdfiumModule.pdfium.getValue(aPtr, "i32") & 255
|
|
2972
|
-
// 0 = transparent, 255 = opaque
|
|
3010
|
+
blue: this.pdfiumModule.pdfium.getValue(bPtr, "i32") & 255
|
|
2973
3011
|
};
|
|
2974
3012
|
}
|
|
2975
3013
|
this.free(rPtr);
|
|
2976
3014
|
this.free(gPtr);
|
|
2977
3015
|
this.free(bPtr);
|
|
2978
|
-
this.free(aPtr);
|
|
2979
3016
|
return colour;
|
|
2980
3017
|
}
|
|
2981
|
-
|
|
2982
|
-
|
|
3018
|
+
/**
|
|
3019
|
+
* Get the fill/stroke colour annotation.
|
|
3020
|
+
*
|
|
3021
|
+
* @param annotationPtr - pointer to the annotation whose colour is being set
|
|
3022
|
+
* @param colorType - which colour to get (0 = fill, 1 = stroke)
|
|
3023
|
+
* @returns WebColor with hex color
|
|
3024
|
+
*
|
|
3025
|
+
* @private
|
|
3026
|
+
*/
|
|
3027
|
+
getAnnotationColor(annotationPtr, colorType = PdfAnnotationColorType.Color) {
|
|
2983
3028
|
const annotationColor = this.readAnnotationColor(annotationPtr, colorType);
|
|
2984
|
-
|
|
2985
|
-
return pdfAlphaColorToWebAlphaColor(annotationColor);
|
|
2986
|
-
}
|
|
2987
|
-
if (fallback !== void 0) {
|
|
2988
|
-
return pdfAlphaColorToWebAlphaColor(fallback);
|
|
2989
|
-
}
|
|
2990
|
-
return void 0;
|
|
3029
|
+
return annotationColor ? pdfColorToWebColor(annotationColor) : void 0;
|
|
2991
3030
|
}
|
|
2992
3031
|
/**
|
|
2993
3032
|
* Set the fill/stroke colour for a **Highlight / Underline / StrikeOut / Squiggly** markup annotation.
|
|
@@ -3000,15 +3039,143 @@ class PdfiumEngine {
|
|
|
3000
3039
|
*
|
|
3001
3040
|
* @private
|
|
3002
3041
|
*/
|
|
3003
|
-
setAnnotationColor(annotationPtr,
|
|
3004
|
-
const
|
|
3042
|
+
setAnnotationColor(annotationPtr, webColor, colorType = PdfAnnotationColorType.Color) {
|
|
3043
|
+
const pdfColor = webColorToPdfColor(webColor);
|
|
3005
3044
|
return this.pdfiumModule.EPDFAnnot_SetColor(
|
|
3006
3045
|
annotationPtr,
|
|
3007
3046
|
colorType,
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3047
|
+
pdfColor.red & 255,
|
|
3048
|
+
pdfColor.green & 255,
|
|
3049
|
+
pdfColor.blue & 255
|
|
3050
|
+
);
|
|
3051
|
+
}
|
|
3052
|
+
/**
|
|
3053
|
+
* Get the opacity of the annotation.
|
|
3054
|
+
*
|
|
3055
|
+
* @param annotationPtr - pointer to the annotation whose opacity is being set
|
|
3056
|
+
* @returns opacity (0-1)
|
|
3057
|
+
*
|
|
3058
|
+
* @private
|
|
3059
|
+
*/
|
|
3060
|
+
getAnnotationOpacity(annotationPtr) {
|
|
3061
|
+
const opacityPtr = this.malloc(4);
|
|
3062
|
+
const ok = this.pdfiumModule.EPDFAnnot_GetOpacity(annotationPtr, opacityPtr);
|
|
3063
|
+
const opacity = ok ? this.pdfiumModule.pdfium.getValue(opacityPtr, "i32") : 255;
|
|
3064
|
+
this.free(opacityPtr);
|
|
3065
|
+
return pdfAlphaToWebOpacity(opacity);
|
|
3066
|
+
}
|
|
3067
|
+
/**
|
|
3068
|
+
* Set the opacity of the annotation.
|
|
3069
|
+
*
|
|
3070
|
+
* @param annotationPtr - pointer to the annotation whose opacity is being set
|
|
3071
|
+
* @param opacity - opacity (0-1)
|
|
3072
|
+
* @returns true on success
|
|
3073
|
+
*
|
|
3074
|
+
* @private
|
|
3075
|
+
*/
|
|
3076
|
+
setAnnotationOpacity(annotationPtr, opacity) {
|
|
3077
|
+
const pdfOpacity = webOpacityToPdfAlpha(opacity);
|
|
3078
|
+
return this.pdfiumModule.EPDFAnnot_SetOpacity(annotationPtr, pdfOpacity & 255);
|
|
3079
|
+
}
|
|
3080
|
+
/**
|
|
3081
|
+
* Fetch the `/Q` text-alignment value from a **FreeText** annotation.
|
|
3082
|
+
*
|
|
3083
|
+
* @param annotationPtr pointer returned by `FPDFPage_GetAnnot`
|
|
3084
|
+
* @returns `PdfTextAlignment`
|
|
3085
|
+
*/
|
|
3086
|
+
getAnnotationTextAlignment(annotationPtr) {
|
|
3087
|
+
return this.pdfiumModule.EPDFAnnot_GetTextAlignment(annotationPtr);
|
|
3088
|
+
}
|
|
3089
|
+
/**
|
|
3090
|
+
* Write the `/Q` text-alignment value into a **FreeText** annotation
|
|
3091
|
+
* and clear the existing appearance stream so it can be regenerated.
|
|
3092
|
+
*
|
|
3093
|
+
* @param annotationPtr pointer returned by `FPDFPage_GetAnnot`
|
|
3094
|
+
* @param alignment `PdfTextAlignment`
|
|
3095
|
+
* @returns `true` on success
|
|
3096
|
+
*/
|
|
3097
|
+
setAnnotationTextAlignment(annotationPtr, alignment) {
|
|
3098
|
+
return !!this.pdfiumModule.EPDFAnnot_SetTextAlignment(annotationPtr, alignment);
|
|
3099
|
+
}
|
|
3100
|
+
/**
|
|
3101
|
+
* Fetch the `/EPDF:VerticalAlignment` vertical-alignment value from a **FreeText** annotation.
|
|
3102
|
+
*
|
|
3103
|
+
* @param annotationPtr pointer returned by `FPDFPage_GetAnnot`
|
|
3104
|
+
* @returns `PdfVerticalAlignment`
|
|
3105
|
+
*/
|
|
3106
|
+
getAnnotationVerticalAlignment(annotationPtr) {
|
|
3107
|
+
return this.pdfiumModule.EPDFAnnot_GetVerticalAlignment(annotationPtr);
|
|
3108
|
+
}
|
|
3109
|
+
/**
|
|
3110
|
+
* Write the `/EPDF:VerticalAlignment` vertical-alignment value into a **FreeText** annotation
|
|
3111
|
+
* and clear the existing appearance stream so it can be regenerated.
|
|
3112
|
+
*
|
|
3113
|
+
* @param annotationPtr pointer returned by `FPDFPage_GetAnnot`
|
|
3114
|
+
* @param alignment `PdfVerticalAlignment`
|
|
3115
|
+
* @returns `true` on success
|
|
3116
|
+
*/
|
|
3117
|
+
setAnnotationVerticalAlignment(annotationPtr, alignment) {
|
|
3118
|
+
return !!this.pdfiumModule.EPDFAnnot_SetVerticalAlignment(annotationPtr, alignment);
|
|
3119
|
+
}
|
|
3120
|
+
/**
|
|
3121
|
+
* Return the **default appearance** (font, size, colour) declared in the
|
|
3122
|
+
* `/DA` string of a **FreeText** annotation.
|
|
3123
|
+
*
|
|
3124
|
+
* @param annotationPtr pointer to `FPDF_ANNOTATION`
|
|
3125
|
+
* @returns `{ font, fontSize, color }` or `undefined` when PDFium returns false
|
|
3126
|
+
*
|
|
3127
|
+
* NOTE – `font` is the raw `FPDF_STANDARD_FONT` enum value that PDFium uses
|
|
3128
|
+
* (same range as the C API: 0 = Courier, 12 = ZapfDingbats, …).
|
|
3129
|
+
*/
|
|
3130
|
+
getAnnotationDefaultAppearance(annotationPtr) {
|
|
3131
|
+
const fontPtr = this.malloc(4);
|
|
3132
|
+
const sizePtr = this.malloc(4);
|
|
3133
|
+
const rPtr = this.malloc(4);
|
|
3134
|
+
const gPtr = this.malloc(4);
|
|
3135
|
+
const bPtr = this.malloc(4);
|
|
3136
|
+
const ok = !!this.pdfiumModule.EPDFAnnot_GetDefaultAppearance(
|
|
3137
|
+
annotationPtr,
|
|
3138
|
+
fontPtr,
|
|
3139
|
+
sizePtr,
|
|
3140
|
+
rPtr,
|
|
3141
|
+
gPtr,
|
|
3142
|
+
bPtr
|
|
3143
|
+
);
|
|
3144
|
+
if (!ok) {
|
|
3145
|
+
[fontPtr, sizePtr, rPtr, gPtr, bPtr].forEach((p) => this.free(p));
|
|
3146
|
+
return;
|
|
3147
|
+
}
|
|
3148
|
+
const pdf = this.pdfiumModule.pdfium;
|
|
3149
|
+
const font = pdf.getValue(fontPtr, "i32");
|
|
3150
|
+
const fontSize = pdf.getValue(sizePtr, "float");
|
|
3151
|
+
const red = pdf.getValue(rPtr, "i32") & 255;
|
|
3152
|
+
const green = pdf.getValue(gPtr, "i32") & 255;
|
|
3153
|
+
const blue = pdf.getValue(bPtr, "i32") & 255;
|
|
3154
|
+
[fontPtr, sizePtr, rPtr, gPtr, bPtr].forEach((p) => this.free(p));
|
|
3155
|
+
return {
|
|
3156
|
+
fontFamily: font,
|
|
3157
|
+
fontSize,
|
|
3158
|
+
fontColor: pdfColorToWebColor({ red, green, blue })
|
|
3159
|
+
};
|
|
3160
|
+
}
|
|
3161
|
+
/**
|
|
3162
|
+
* Write a **default appearance** (`/DA`) into a FreeText annotation.
|
|
3163
|
+
*
|
|
3164
|
+
* @param annotationPtr pointer to `FPDF_ANNOTATION`
|
|
3165
|
+
* @param font `FPDF_STANDARD_FONT` enum value
|
|
3166
|
+
* @param fontSize size in points (≥ 0)
|
|
3167
|
+
* @param color CSS-style `#rrggbb` string (alpha ignored)
|
|
3168
|
+
* @returns `true` on success
|
|
3169
|
+
*/
|
|
3170
|
+
setAnnotationDefaultAppearance(annotationPtr, font, fontSize, color) {
|
|
3171
|
+
const { red, green, blue } = webColorToPdfColor(color);
|
|
3172
|
+
return !!this.pdfiumModule.EPDFAnnot_SetDefaultAppearance(
|
|
3173
|
+
annotationPtr,
|
|
3174
|
+
font,
|
|
3175
|
+
fontSize,
|
|
3176
|
+
red & 255,
|
|
3177
|
+
green & 255,
|
|
3178
|
+
blue & 255
|
|
3012
3179
|
);
|
|
3013
3180
|
}
|
|
3014
3181
|
/**
|
|
@@ -3397,14 +3564,16 @@ class PdfiumEngine {
|
|
|
3397
3564
|
const contents = this.getAnnotString(annotationPtr, "Contents") || "";
|
|
3398
3565
|
const state = this.getAnnotString(annotationPtr, "State");
|
|
3399
3566
|
const stateModel = this.getAnnotString(annotationPtr, "StateModel");
|
|
3400
|
-
const
|
|
3567
|
+
const color = this.getAnnotationColor(annotationPtr);
|
|
3568
|
+
const opacity = this.getAnnotationOpacity(annotationPtr);
|
|
3401
3569
|
const inReplyToId = this.getInReplyToId(pagePtr, annotationPtr);
|
|
3402
3570
|
return {
|
|
3403
3571
|
pageIndex: page.index,
|
|
3404
3572
|
id: index,
|
|
3405
3573
|
type: PdfAnnotationSubtype.TEXT,
|
|
3406
3574
|
contents,
|
|
3407
|
-
|
|
3575
|
+
color: color ?? "#FFFF00",
|
|
3576
|
+
opacity,
|
|
3408
3577
|
rect,
|
|
3409
3578
|
inReplyToId,
|
|
3410
3579
|
author,
|
|
@@ -3429,12 +3598,26 @@ class PdfiumEngine {
|
|
|
3429
3598
|
const contents = this.getAnnotString(annotationPtr, "Contents") || "";
|
|
3430
3599
|
const author = this.getAnnotString(annotationPtr, "T");
|
|
3431
3600
|
const modifiedRaw = this.getAnnotString(annotationPtr, "M");
|
|
3601
|
+
const defaultStyle = this.getAnnotString(annotationPtr, "DS");
|
|
3602
|
+
const da = this.getAnnotationDefaultAppearance(annotationPtr);
|
|
3603
|
+
const backgroundColor = this.getAnnotationColor(annotationPtr);
|
|
3604
|
+
const textAlign = this.getAnnotationTextAlignment(annotationPtr);
|
|
3605
|
+
const verticalAlign = this.getAnnotationVerticalAlignment(annotationPtr);
|
|
3606
|
+
const opacity = this.getAnnotationOpacity(annotationPtr);
|
|
3432
3607
|
const modified = pdfDateToDate(modifiedRaw);
|
|
3433
3608
|
const richContent = this.getAnnotRichContent(annotationPtr);
|
|
3434
3609
|
return {
|
|
3435
3610
|
pageIndex: page.index,
|
|
3436
3611
|
id: index,
|
|
3437
3612
|
type: PdfAnnotationSubtype.FREETEXT,
|
|
3613
|
+
fontFamily: (da == null ? void 0 : da.fontFamily) ?? PdfStandardFont.Unknown,
|
|
3614
|
+
fontSize: (da == null ? void 0 : da.fontSize) ?? 12,
|
|
3615
|
+
fontColor: (da == null ? void 0 : da.fontColor) ?? "#000000",
|
|
3616
|
+
verticalAlign,
|
|
3617
|
+
backgroundColor,
|
|
3618
|
+
opacity,
|
|
3619
|
+
textAlign,
|
|
3620
|
+
defaultStyle,
|
|
3438
3621
|
richContent,
|
|
3439
3622
|
contents,
|
|
3440
3623
|
author,
|
|
@@ -3576,7 +3759,8 @@ class PdfiumEngine {
|
|
|
3576
3759
|
const author = this.getAnnotString(annotationPtr, "T");
|
|
3577
3760
|
const modifiedRaw = this.getAnnotString(annotationPtr, "M");
|
|
3578
3761
|
const modified = pdfDateToDate(modifiedRaw);
|
|
3579
|
-
const
|
|
3762
|
+
const color = this.getAnnotationColor(annotationPtr);
|
|
3763
|
+
const opacity = this.getAnnotationOpacity(annotationPtr);
|
|
3580
3764
|
const { width: strokeWidth } = this.getBorderStyle(annotationPtr);
|
|
3581
3765
|
const inkList = this.getInkList(page, annotationPtr);
|
|
3582
3766
|
const blendMode = this.pdfiumModule.EPDFAnnot_GetBlendMode(annotationPtr);
|
|
@@ -3587,8 +3771,9 @@ class PdfiumEngine {
|
|
|
3587
3771
|
type: PdfAnnotationSubtype.INK,
|
|
3588
3772
|
...intent && { intent },
|
|
3589
3773
|
blendMode,
|
|
3590
|
-
|
|
3591
|
-
|
|
3774
|
+
color: color ?? "#FF0000",
|
|
3775
|
+
opacity,
|
|
3776
|
+
strokeWidth: strokeWidth === 0 ? 1 : strokeWidth,
|
|
3592
3777
|
rect,
|
|
3593
3778
|
inkList,
|
|
3594
3779
|
author,
|
|
@@ -3613,12 +3798,12 @@ class PdfiumEngine {
|
|
|
3613
3798
|
const modified = pdfDateToDate(modifiedRaw);
|
|
3614
3799
|
const vertices = this.readPdfAnnoVertices(page, pagePtr, annotationPtr);
|
|
3615
3800
|
const contents = this.getAnnotString(annotationPtr, "Contents") || "";
|
|
3616
|
-
const strokeColor = this.
|
|
3617
|
-
const interiorColor = this.
|
|
3801
|
+
const strokeColor = this.getAnnotationColor(annotationPtr);
|
|
3802
|
+
const interiorColor = this.getAnnotationColor(
|
|
3618
3803
|
annotationPtr,
|
|
3619
|
-
PdfAnnotationColorType.InteriorColor
|
|
3620
|
-
void 0
|
|
3804
|
+
PdfAnnotationColorType.InteriorColor
|
|
3621
3805
|
);
|
|
3806
|
+
const opacity = this.getAnnotationOpacity(annotationPtr);
|
|
3622
3807
|
let { style: strokeStyle, width: strokeWidth } = this.getBorderStyle(annotationPtr);
|
|
3623
3808
|
let strokeDashArray;
|
|
3624
3809
|
if (strokeStyle === PdfAnnotationBorderStyle.DASHED) {
|
|
@@ -3639,9 +3824,9 @@ class PdfiumEngine {
|
|
|
3639
3824
|
id: index,
|
|
3640
3825
|
type: PdfAnnotationSubtype.POLYGON,
|
|
3641
3826
|
contents,
|
|
3642
|
-
strokeColor: strokeColor
|
|
3643
|
-
color:
|
|
3644
|
-
opacity
|
|
3827
|
+
strokeColor: strokeColor ?? "#FF0000",
|
|
3828
|
+
color: interiorColor ?? "transparent",
|
|
3829
|
+
opacity,
|
|
3645
3830
|
strokeWidth: strokeWidth === 0 ? 1 : strokeWidth,
|
|
3646
3831
|
strokeStyle,
|
|
3647
3832
|
strokeDashArray,
|
|
@@ -3669,12 +3854,12 @@ class PdfiumEngine {
|
|
|
3669
3854
|
const modified = pdfDateToDate(modifiedRaw);
|
|
3670
3855
|
const vertices = this.readPdfAnnoVertices(page, pagePtr, annotationPtr);
|
|
3671
3856
|
const contents = this.getAnnotString(annotationPtr, "Contents") || "";
|
|
3672
|
-
const strokeColor = this.
|
|
3673
|
-
const interiorColor = this.
|
|
3857
|
+
const strokeColor = this.getAnnotationColor(annotationPtr);
|
|
3858
|
+
const interiorColor = this.getAnnotationColor(
|
|
3674
3859
|
annotationPtr,
|
|
3675
|
-
PdfAnnotationColorType.InteriorColor
|
|
3676
|
-
void 0
|
|
3860
|
+
PdfAnnotationColorType.InteriorColor
|
|
3677
3861
|
);
|
|
3862
|
+
const opacity = this.getAnnotationOpacity(annotationPtr);
|
|
3678
3863
|
let { style: strokeStyle, width: strokeWidth } = this.getBorderStyle(annotationPtr);
|
|
3679
3864
|
let strokeDashArray;
|
|
3680
3865
|
if (strokeStyle === PdfAnnotationBorderStyle.DASHED) {
|
|
@@ -3689,9 +3874,9 @@ class PdfiumEngine {
|
|
|
3689
3874
|
id: index,
|
|
3690
3875
|
type: PdfAnnotationSubtype.POLYLINE,
|
|
3691
3876
|
contents,
|
|
3692
|
-
strokeColor: strokeColor
|
|
3693
|
-
color:
|
|
3694
|
-
opacity
|
|
3877
|
+
strokeColor: strokeColor ?? "#FF0000",
|
|
3878
|
+
color: interiorColor ?? "transparent",
|
|
3879
|
+
opacity,
|
|
3695
3880
|
strokeWidth: strokeWidth === 0 ? 1 : strokeWidth,
|
|
3696
3881
|
strokeStyle,
|
|
3697
3882
|
strokeDashArray,
|
|
@@ -3721,12 +3906,12 @@ class PdfiumEngine {
|
|
|
3721
3906
|
const linePoints = this.getLinePoints(annotationPtr, page);
|
|
3722
3907
|
const lineEndings = this.getLineEndings(annotationPtr);
|
|
3723
3908
|
const contents = this.getAnnotString(annotationPtr, "Contents") || "";
|
|
3724
|
-
const strokeColor = this.
|
|
3725
|
-
const interiorColor = this.
|
|
3909
|
+
const strokeColor = this.getAnnotationColor(annotationPtr);
|
|
3910
|
+
const interiorColor = this.getAnnotationColor(
|
|
3726
3911
|
annotationPtr,
|
|
3727
|
-
PdfAnnotationColorType.InteriorColor
|
|
3728
|
-
void 0
|
|
3912
|
+
PdfAnnotationColorType.InteriorColor
|
|
3729
3913
|
);
|
|
3914
|
+
const opacity = this.getAnnotationOpacity(annotationPtr);
|
|
3730
3915
|
let { style: strokeStyle, width: strokeWidth } = this.getBorderStyle(annotationPtr);
|
|
3731
3916
|
let strokeDashArray;
|
|
3732
3917
|
if (strokeStyle === PdfAnnotationBorderStyle.DASHED) {
|
|
@@ -3744,9 +3929,9 @@ class PdfiumEngine {
|
|
|
3744
3929
|
strokeWidth: strokeWidth === 0 ? 1 : strokeWidth,
|
|
3745
3930
|
strokeStyle,
|
|
3746
3931
|
strokeDashArray,
|
|
3747
|
-
strokeColor: strokeColor
|
|
3748
|
-
color:
|
|
3749
|
-
opacity
|
|
3932
|
+
strokeColor: strokeColor ?? "#FF0000",
|
|
3933
|
+
color: interiorColor ?? "transparent",
|
|
3934
|
+
opacity,
|
|
3750
3935
|
linePoints: linePoints || { start: { x: 0, y: 0 }, end: { x: 0, y: 0 } },
|
|
3751
3936
|
lineEndings: lineEndings || {
|
|
3752
3937
|
start: PdfAnnotationLineEnding.None,
|
|
@@ -3770,7 +3955,8 @@ class PdfiumEngine {
|
|
|
3770
3955
|
const pageRect = this.readPageAnnoRect(annotationPtr);
|
|
3771
3956
|
const rect = this.convertPageRectToDeviceRect(page, pagePtr, pageRect);
|
|
3772
3957
|
const segmentRects = this.getQuadPointsAnno(page, annotationPtr);
|
|
3773
|
-
const
|
|
3958
|
+
const color = this.getAnnotationColor(annotationPtr);
|
|
3959
|
+
const opacity = this.getAnnotationOpacity(annotationPtr);
|
|
3774
3960
|
const blendMode = this.pdfiumModule.EPDFAnnot_GetBlendMode(annotationPtr);
|
|
3775
3961
|
const author = this.getAnnotString(annotationPtr, "T");
|
|
3776
3962
|
const modifiedRaw = this.getAnnotString(annotationPtr, "M");
|
|
@@ -3784,7 +3970,8 @@ class PdfiumEngine {
|
|
|
3784
3970
|
rect,
|
|
3785
3971
|
contents,
|
|
3786
3972
|
segmentRects,
|
|
3787
|
-
|
|
3973
|
+
color: color ?? "#FFFF00",
|
|
3974
|
+
opacity,
|
|
3788
3975
|
author,
|
|
3789
3976
|
modified
|
|
3790
3977
|
};
|
|
@@ -3807,7 +3994,8 @@ class PdfiumEngine {
|
|
|
3807
3994
|
const modified = pdfDateToDate(modifiedRaw);
|
|
3808
3995
|
const segmentRects = this.getQuadPointsAnno(page, annotationPtr);
|
|
3809
3996
|
const contents = this.getAnnotString(annotationPtr, "Contents") || "";
|
|
3810
|
-
const
|
|
3997
|
+
const color = this.getAnnotationColor(annotationPtr);
|
|
3998
|
+
const opacity = this.getAnnotationOpacity(annotationPtr);
|
|
3811
3999
|
const blendMode = this.pdfiumModule.EPDFAnnot_GetBlendMode(annotationPtr);
|
|
3812
4000
|
return {
|
|
3813
4001
|
pageIndex: page.index,
|
|
@@ -3817,7 +4005,8 @@ class PdfiumEngine {
|
|
|
3817
4005
|
rect,
|
|
3818
4006
|
contents,
|
|
3819
4007
|
segmentRects,
|
|
3820
|
-
|
|
4008
|
+
color: color ?? "#FF0000",
|
|
4009
|
+
opacity,
|
|
3821
4010
|
author,
|
|
3822
4011
|
modified
|
|
3823
4012
|
};
|
|
@@ -3840,7 +4029,8 @@ class PdfiumEngine {
|
|
|
3840
4029
|
const modified = pdfDateToDate(modifiedRaw);
|
|
3841
4030
|
const segmentRects = this.getQuadPointsAnno(page, annotationPtr);
|
|
3842
4031
|
const contents = this.getAnnotString(annotationPtr, "Contents") || "";
|
|
3843
|
-
const
|
|
4032
|
+
const color = this.getAnnotationColor(annotationPtr);
|
|
4033
|
+
const opacity = this.getAnnotationOpacity(annotationPtr);
|
|
3844
4034
|
const blendMode = this.pdfiumModule.EPDFAnnot_GetBlendMode(annotationPtr);
|
|
3845
4035
|
return {
|
|
3846
4036
|
pageIndex: page.index,
|
|
@@ -3850,7 +4040,8 @@ class PdfiumEngine {
|
|
|
3850
4040
|
rect,
|
|
3851
4041
|
contents,
|
|
3852
4042
|
segmentRects,
|
|
3853
|
-
|
|
4043
|
+
color: color ?? "#FF0000",
|
|
4044
|
+
opacity,
|
|
3854
4045
|
author,
|
|
3855
4046
|
modified
|
|
3856
4047
|
};
|
|
@@ -3873,7 +4064,8 @@ class PdfiumEngine {
|
|
|
3873
4064
|
const modified = pdfDateToDate(modifiedRaw);
|
|
3874
4065
|
const segmentRects = this.getQuadPointsAnno(page, annotationPtr);
|
|
3875
4066
|
const contents = this.getAnnotString(annotationPtr, "Contents") || "";
|
|
3876
|
-
const
|
|
4067
|
+
const color = this.getAnnotationColor(annotationPtr);
|
|
4068
|
+
const opacity = this.getAnnotationOpacity(annotationPtr);
|
|
3877
4069
|
const blendMode = this.pdfiumModule.EPDFAnnot_GetBlendMode(annotationPtr);
|
|
3878
4070
|
return {
|
|
3879
4071
|
pageIndex: page.index,
|
|
@@ -3883,7 +4075,8 @@ class PdfiumEngine {
|
|
|
3883
4075
|
rect,
|
|
3884
4076
|
contents,
|
|
3885
4077
|
segmentRects,
|
|
3886
|
-
|
|
4078
|
+
color: color ?? "#FF0000",
|
|
4079
|
+
opacity,
|
|
3887
4080
|
author,
|
|
3888
4081
|
modified
|
|
3889
4082
|
};
|
|
@@ -4166,12 +4359,12 @@ class PdfiumEngine {
|
|
|
4166
4359
|
const author = this.getAnnotString(annotationPtr, "T");
|
|
4167
4360
|
const modifiedRaw = this.getAnnotString(annotationPtr, "M");
|
|
4168
4361
|
const modified = pdfDateToDate(modifiedRaw);
|
|
4169
|
-
const interiorColor = this.
|
|
4362
|
+
const interiorColor = this.getAnnotationColor(
|
|
4170
4363
|
annotationPtr,
|
|
4171
|
-
PdfAnnotationColorType.InteriorColor
|
|
4172
|
-
void 0
|
|
4364
|
+
PdfAnnotationColorType.InteriorColor
|
|
4173
4365
|
);
|
|
4174
|
-
const
|
|
4366
|
+
const strokeColor = this.getAnnotationColor(annotationPtr);
|
|
4367
|
+
const opacity = this.getAnnotationOpacity(annotationPtr);
|
|
4175
4368
|
let { style: strokeStyle, width: strokeWidth } = this.getBorderStyle(annotationPtr);
|
|
4176
4369
|
let strokeDashArray;
|
|
4177
4370
|
if (strokeStyle === PdfAnnotationBorderStyle.DASHED) {
|
|
@@ -4185,10 +4378,10 @@ class PdfiumEngine {
|
|
|
4185
4378
|
id: index,
|
|
4186
4379
|
type: PdfAnnotationSubtype.CIRCLE,
|
|
4187
4380
|
flags,
|
|
4188
|
-
color:
|
|
4189
|
-
opacity
|
|
4381
|
+
color: interiorColor ?? "transparent",
|
|
4382
|
+
opacity,
|
|
4190
4383
|
strokeWidth,
|
|
4191
|
-
strokeColor,
|
|
4384
|
+
strokeColor: strokeColor ?? "#FF0000",
|
|
4192
4385
|
strokeStyle,
|
|
4193
4386
|
rect,
|
|
4194
4387
|
author,
|
|
@@ -4213,12 +4406,12 @@ class PdfiumEngine {
|
|
|
4213
4406
|
const author = this.getAnnotString(annotationPtr, "T");
|
|
4214
4407
|
const modifiedRaw = this.getAnnotString(annotationPtr, "M");
|
|
4215
4408
|
const modified = pdfDateToDate(modifiedRaw);
|
|
4216
|
-
const interiorColor = this.
|
|
4409
|
+
const interiorColor = this.getAnnotationColor(
|
|
4217
4410
|
annotationPtr,
|
|
4218
|
-
PdfAnnotationColorType.InteriorColor
|
|
4219
|
-
void 0
|
|
4411
|
+
PdfAnnotationColorType.InteriorColor
|
|
4220
4412
|
);
|
|
4221
|
-
const
|
|
4413
|
+
const strokeColor = this.getAnnotationColor(annotationPtr);
|
|
4414
|
+
const opacity = this.getAnnotationOpacity(annotationPtr);
|
|
4222
4415
|
let { style: strokeStyle, width: strokeWidth } = this.getBorderStyle(annotationPtr);
|
|
4223
4416
|
let strokeDashArray;
|
|
4224
4417
|
if (strokeStyle === PdfAnnotationBorderStyle.DASHED) {
|
|
@@ -4232,9 +4425,9 @@ class PdfiumEngine {
|
|
|
4232
4425
|
id: index,
|
|
4233
4426
|
type: PdfAnnotationSubtype.SQUARE,
|
|
4234
4427
|
flags,
|
|
4235
|
-
color:
|
|
4236
|
-
opacity
|
|
4237
|
-
strokeColor,
|
|
4428
|
+
color: interiorColor ?? "transparent",
|
|
4429
|
+
opacity,
|
|
4430
|
+
strokeColor: strokeColor ?? "#FF0000",
|
|
4238
4431
|
strokeWidth,
|
|
4239
4432
|
strokeStyle,
|
|
4240
4433
|
rect,
|
|
@@ -5069,70 +5262,6 @@ class PdfiumEngine {
|
|
|
5069
5262
|
this.free(bufferPtr);
|
|
5070
5263
|
return ap;
|
|
5071
5264
|
}
|
|
5072
|
-
/**
|
|
5073
|
-
* Change the visible colour (and opacity) of an existing annotation.
|
|
5074
|
-
*
|
|
5075
|
-
* For markup annotations (highlight / underline / strikeout / squiggly) we
|
|
5076
|
-
* first clear the AP dictionary entry, otherwise the stored appearance stream
|
|
5077
|
-
* will override the new tint. For all other sub-types we keep the existing
|
|
5078
|
-
* AP so custom artwork isn't lost.
|
|
5079
|
-
*
|
|
5080
|
-
* @param doc logical document object
|
|
5081
|
-
* @param page logical page object
|
|
5082
|
-
* @param annotation the annotation we want to recolour
|
|
5083
|
-
* @param colour RGBA tuple (0-255 per channel)
|
|
5084
|
-
* @param which 0 = stroke/fill colour (PDFium's "colourType" param)
|
|
5085
|
-
*
|
|
5086
|
-
* @returns `true` when the operation succeeded
|
|
5087
|
-
*/
|
|
5088
|
-
updateAnnotationColor(doc, page, annotation, color, which = 0) {
|
|
5089
|
-
this.logger.debug(
|
|
5090
|
-
LOG_SOURCE,
|
|
5091
|
-
LOG_CATEGORY,
|
|
5092
|
-
"setAnnotationColor",
|
|
5093
|
-
doc,
|
|
5094
|
-
page,
|
|
5095
|
-
annotation,
|
|
5096
|
-
color,
|
|
5097
|
-
which
|
|
5098
|
-
);
|
|
5099
|
-
this.logger.perf(LOG_SOURCE, LOG_CATEGORY, "setAnnotationColor", "Begin", doc.id);
|
|
5100
|
-
const task = PdfTaskHelper.create();
|
|
5101
|
-
try {
|
|
5102
|
-
const ctx = this.cache.getContext(doc.id);
|
|
5103
|
-
if (!ctx) {
|
|
5104
|
-
this.logger.perf(LOG_SOURCE, LOG_CATEGORY, "setAnnotationColor", "End", doc.id);
|
|
5105
|
-
this.logger.warn(LOG_SOURCE, LOG_CATEGORY, "setAnnotationColor: doc closed");
|
|
5106
|
-
task.resolve(false);
|
|
5107
|
-
return task;
|
|
5108
|
-
}
|
|
5109
|
-
const pageCtx = ctx.acquirePage(page.index);
|
|
5110
|
-
const annotPtr = this.pdfiumModule.FPDFPage_GetAnnot(pageCtx.pagePtr, annotation.id);
|
|
5111
|
-
if (!annotPtr) {
|
|
5112
|
-
this.logger.perf(LOG_SOURCE, LOG_CATEGORY, "setAnnotationColor", "End", doc.id);
|
|
5113
|
-
this.logger.warn(LOG_SOURCE, LOG_CATEGORY, "setAnnotationColor: annot not found");
|
|
5114
|
-
pageCtx.release();
|
|
5115
|
-
task.resolve(false);
|
|
5116
|
-
return task;
|
|
5117
|
-
}
|
|
5118
|
-
const ok = this.setAnnotationColor(annotPtr, color, which);
|
|
5119
|
-
if (ok) {
|
|
5120
|
-
this.pdfiumModule.FPDFPage_GenerateContent(pageCtx.pagePtr);
|
|
5121
|
-
}
|
|
5122
|
-
this.pdfiumModule.FPDFPage_CloseAnnot(annotPtr);
|
|
5123
|
-
pageCtx.release();
|
|
5124
|
-
this.logger.perf(LOG_SOURCE, LOG_CATEGORY, "setAnnotationColor", "End", doc.id);
|
|
5125
|
-
task.resolve(!!ok);
|
|
5126
|
-
} catch (error) {
|
|
5127
|
-
this.logger.perf(LOG_SOURCE, LOG_CATEGORY, "setAnnotationColor", "End", doc.id);
|
|
5128
|
-
this.logger.error(LOG_SOURCE, LOG_CATEGORY, "setAnnotationColor: error", error);
|
|
5129
|
-
task.reject({
|
|
5130
|
-
code: PdfErrorCode.Unknown,
|
|
5131
|
-
message: `Failed to set annotation color: ${error instanceof Error ? error.message : String(error)}`
|
|
5132
|
-
});
|
|
5133
|
-
}
|
|
5134
|
-
return task;
|
|
5135
|
-
}
|
|
5136
5265
|
/**
|
|
5137
5266
|
* Set the rect of specified annotation
|
|
5138
5267
|
* @param page - page info that the annotation is belonged to
|
|
@@ -5438,4 +5567,4 @@ export {
|
|
|
5438
5567
|
readArrayBuffer as c,
|
|
5439
5568
|
readString as r
|
|
5440
5569
|
};
|
|
5441
|
-
//# sourceMappingURL=engine-
|
|
5570
|
+
//# sourceMappingURL=engine-O49988D4.js.map
|