@muhammara/native-core 7.0.0-beta.1 → 7.0.0-beta.3
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/README.md +4 -0
- package/lib/Recipe.js +119 -57
- package/lib/recipe/annotation.js +53 -4
- package/lib/recipe/appendPage.js +22 -9
- package/lib/recipe/graphics-state.js +20 -0
- package/lib/recipe/image.js +4 -0
- package/lib/recipe/info.js +14 -19
- package/lib/recipe/insertPage.js +15 -10
- package/lib/recipe/page.js +808 -11
- package/lib/recipe/parameters.js +2 -0
- package/lib/recipe/replaceText.js +5 -3
- package/lib/recipe/shapes.js +22 -1
- package/lib/recipe/text.helper.js +1 -1
- package/lib/recipe/text.js +106 -8
- package/lib/recipe/vector-polygon.js +11 -0
- package/lib/recipe/vector.helper.js +15 -3
- package/lib/recipe/vector.js +108 -10
- package/lib/recipe-info.js +10 -0
- package/muhammara.d.ts +472 -84
- package/package.json +1 -1
package/muhammara.d.ts
CHANGED
|
@@ -343,6 +343,7 @@ declare namespace muhammara {
|
|
|
343
343
|
export const ePDFPageBoxTrimBox = 3;
|
|
344
344
|
export const ePDFPageBoxArtBox = 4;
|
|
345
345
|
export type PDFPageBoxType = 0 | 1 | 2 | 3 | 4;
|
|
346
|
+
export type PageBox = "media" | "crop" | "bleed" | "trim" | "art";
|
|
346
347
|
|
|
347
348
|
export const eRangeTypeAll = 0;
|
|
348
349
|
export const eRangeTypeSpecific = 1;
|
|
@@ -406,7 +407,7 @@ declare namespace muhammara {
|
|
|
406
407
|
/** The page resource name selected by the most recent Tf operation. */
|
|
407
408
|
fontResource: string;
|
|
408
409
|
fontSize: number;
|
|
409
|
-
/** The active
|
|
410
|
+
/** The text-to-page matrix after applying the active graphics CTM: [a, b, c, d, e, f]. */
|
|
410
411
|
textMatrix: [number, number, number, number, number, number];
|
|
411
412
|
}
|
|
412
413
|
|
|
@@ -796,6 +797,7 @@ declare namespace muhammara {
|
|
|
796
797
|
|
|
797
798
|
export type inInterPagesCallback = () => {};
|
|
798
799
|
|
|
800
|
+
/** Stateful methods require an active writer and throw Error("PDF writer has ended") after cleanup. */
|
|
799
801
|
export interface PDFWriter {
|
|
800
802
|
/**
|
|
801
803
|
* Replace direct references to an object in a page dictionary.
|
|
@@ -807,6 +809,7 @@ declare namespace muhammara {
|
|
|
807
809
|
replacementObjectId: number,
|
|
808
810
|
options?: ObjectReplacementOptions,
|
|
809
811
|
): this;
|
|
812
|
+
/** Finalize once; repeated calls return this writer. A failed finalization also ends the writer. */
|
|
810
813
|
end(): PDFWriter;
|
|
811
814
|
createPage(x: PosX, y: PosY, width: Width, height: Height): PDFPage;
|
|
812
815
|
createPage(): PDFPage;
|
|
@@ -834,11 +837,12 @@ declare namespace muhammara {
|
|
|
834
837
|
): UsedFont;
|
|
835
838
|
attachURLLinktoCurrentPage(
|
|
836
839
|
url: string,
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
840
|
+
left: PosX,
|
|
841
|
+
bottom: PosY,
|
|
842
|
+
right: PosX,
|
|
843
|
+
top: PosY,
|
|
841
844
|
): this;
|
|
845
|
+
/** Save continuation state and retire this writer, including when saving fails. */
|
|
842
846
|
shutdown(outputFilePath: FilePath): this;
|
|
843
847
|
createFormXObjectFromTIFF(
|
|
844
848
|
filePath: FilePath | PDFRStreamForFile,
|
|
@@ -882,7 +886,7 @@ declare namespace muhammara {
|
|
|
882
886
|
): FormXObjectId[];
|
|
883
887
|
createPDFCopyingContextForModifiedFile(): DocumentCopyingContext;
|
|
884
888
|
createPDFTextString(): PDFTextString;
|
|
885
|
-
createPDFDate(): PDFDate;
|
|
889
|
+
createPDFDate(value?: string | Date): PDFDate;
|
|
886
890
|
getImageDimensions(
|
|
887
891
|
inFontFilePath: FilePath | ReadStream,
|
|
888
892
|
): RectangleDimension;
|
|
@@ -909,7 +913,71 @@ declare namespace muhammara {
|
|
|
909
913
|
scope?: "global";
|
|
910
914
|
}
|
|
911
915
|
|
|
916
|
+
export interface RecipePageInfo {
|
|
917
|
+
width: number;
|
|
918
|
+
height: number;
|
|
919
|
+
rotate: number;
|
|
920
|
+
pageNumber: number;
|
|
921
|
+
}
|
|
922
|
+
|
|
912
923
|
namespace Recipe {
|
|
924
|
+
type Color = string | readonly number[];
|
|
925
|
+
type BorderRadius =
|
|
926
|
+
| number
|
|
927
|
+
| readonly [number]
|
|
928
|
+
| readonly [number, number]
|
|
929
|
+
| readonly [number, number, number]
|
|
930
|
+
| readonly [number, number, number, number];
|
|
931
|
+
type DeviceColorspace = "rgb" | "gray" | "cmyk";
|
|
932
|
+
type Colorspace = DeviceColorspace | "separation";
|
|
933
|
+
/**
|
|
934
|
+
* Matches known runtime values case-insensitively without enumerating
|
|
935
|
+
* every per-character capitalization combination — that recursive
|
|
936
|
+
* approach costs 2^N literal types for an N-character word (4096 for
|
|
937
|
+
* "circumcenter" alone). The runtime lowercases the whole value before
|
|
938
|
+
* comparing, so any casing works at runtime; the type instead accepts
|
|
939
|
+
* the three forms callers actually write (lower case, UPPER CASE, and
|
|
940
|
+
* Capitalized).
|
|
941
|
+
*/
|
|
942
|
+
type CaseInsensitive<Value extends string> =
|
|
943
|
+
Lowercase<Value> | Uppercase<Value> | Capitalize<Lowercase<Value>>;
|
|
944
|
+
type TriangleTrait = CaseInsensitive<"sss" | "sas" | "asa" | "vtx">;
|
|
945
|
+
type TriangleMeasurementTrait = CaseInsensitive<"sss" | "sas" | "asa">;
|
|
946
|
+
type TriangleVertexTrait = CaseInsensitive<"vtx">;
|
|
947
|
+
type TrianglePosition = CaseInsensitive<
|
|
948
|
+
"a" | "b" | "c" | "centroid" | "circumcenter" | "incenter"
|
|
949
|
+
>;
|
|
950
|
+
type PermissionName =
|
|
951
|
+
| "print"
|
|
952
|
+
| "modify"
|
|
953
|
+
| "copy"
|
|
954
|
+
| "edit"
|
|
955
|
+
| "fillform"
|
|
956
|
+
| "extract"
|
|
957
|
+
| "assemble"
|
|
958
|
+
| "printbest";
|
|
959
|
+
/** Known permission names with string compatibility for composed lists. */
|
|
960
|
+
type PermissionList = PermissionName | (string & {});
|
|
961
|
+
/**
|
|
962
|
+
* Passes a colorspace argument through when it is valid, and otherwise
|
|
963
|
+
* resolves to the accepted set so the compiler names the valid values
|
|
964
|
+
* instead of reporting the bare `never` the optional parameter would
|
|
965
|
+
* collapse to. A plain `string` stays accepted for runtime-computed values.
|
|
966
|
+
*/
|
|
967
|
+
type ValidColorspace<Value extends string | undefined> = [Value] extends [
|
|
968
|
+
undefined,
|
|
969
|
+
]
|
|
970
|
+
? Value
|
|
971
|
+
: string extends Exclude<Value, undefined>
|
|
972
|
+
? Value
|
|
973
|
+
: Exclude<Value, undefined> extends Colorspace | ""
|
|
974
|
+
? Value
|
|
975
|
+
: Colorspace | "";
|
|
976
|
+
type ExtensionCallback<
|
|
977
|
+
Arguments extends unknown[] = never[],
|
|
978
|
+
Result = unknown,
|
|
979
|
+
> = (this: Recipe, ...args: Arguments) => Result;
|
|
980
|
+
|
|
913
981
|
type CommentOptionsFlag =
|
|
914
982
|
| "invisible"
|
|
915
983
|
| "hidden"
|
|
@@ -972,12 +1040,18 @@ declare namespace muhammara {
|
|
|
972
1040
|
| "Paragraph"
|
|
973
1041
|
| "Insert";
|
|
974
1042
|
|
|
1043
|
+
type RecipeCoordinate = number | "center";
|
|
1044
|
+
|
|
1045
|
+
type RecipeFontStyle =
|
|
1046
|
+
"regular" | "bold" | "italic" | "bold-italic" | "r" | "b" | "i" | "bi";
|
|
1047
|
+
|
|
975
1048
|
interface RecipeOptions {
|
|
976
1049
|
version?: number;
|
|
977
1050
|
author?: string;
|
|
978
1051
|
title?: string;
|
|
979
1052
|
subject?: string;
|
|
980
1053
|
keywords?: string[];
|
|
1054
|
+
colorspace?: Colorspace;
|
|
981
1055
|
}
|
|
982
1056
|
|
|
983
1057
|
interface RecipeMargins {
|
|
@@ -993,6 +1067,8 @@ declare namespace muhammara {
|
|
|
993
1067
|
open?: boolean;
|
|
994
1068
|
richText?: boolean;
|
|
995
1069
|
flag?: CommentOptionsFlag;
|
|
1070
|
+
/** Replies linked to this comment annotation. */
|
|
1071
|
+
replies?: readonly AnnotReply[];
|
|
996
1072
|
}
|
|
997
1073
|
|
|
998
1074
|
interface AnnotOptions {
|
|
@@ -1003,9 +1079,11 @@ declare namespace muhammara {
|
|
|
1003
1079
|
icon?: AnnotOptionsIcon;
|
|
1004
1080
|
width?: number;
|
|
1005
1081
|
height?: number;
|
|
1082
|
+
/** Annotation opacity from 0 (transparent) to 1 (opaque). Defaults to 1. */
|
|
1083
|
+
opacity?: number;
|
|
1006
1084
|
date?: string;
|
|
1007
1085
|
subject?: string;
|
|
1008
|
-
replies?:
|
|
1086
|
+
replies?: readonly AnnotReply[];
|
|
1009
1087
|
}
|
|
1010
1088
|
|
|
1011
1089
|
interface AnnotReply {
|
|
@@ -1014,10 +1092,19 @@ declare namespace muhammara {
|
|
|
1014
1092
|
title?: string;
|
|
1015
1093
|
richText?: boolean;
|
|
1016
1094
|
flag?: AnnotOptionsFlag;
|
|
1095
|
+
opacity?: number;
|
|
1017
1096
|
date?: string;
|
|
1018
1097
|
subject?: string;
|
|
1019
1098
|
}
|
|
1020
1099
|
|
|
1100
|
+
interface TextMarkupOptions extends Pick<
|
|
1101
|
+
AnnotOptions,
|
|
1102
|
+
"opacity" | "replies"
|
|
1103
|
+
> {
|
|
1104
|
+
text?: string;
|
|
1105
|
+
color?: Color;
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1021
1108
|
interface EncryptOptions {
|
|
1022
1109
|
password?: string;
|
|
1023
1110
|
ownerPassword?: string;
|
|
@@ -1026,15 +1113,23 @@ declare namespace muhammara {
|
|
|
1026
1113
|
}
|
|
1027
1114
|
|
|
1028
1115
|
interface ImageOptions {
|
|
1116
|
+
/** Make the rendered image open this URL. */
|
|
1117
|
+
link?: string;
|
|
1029
1118
|
width?: number;
|
|
1030
1119
|
height?: number;
|
|
1031
1120
|
scale?: number;
|
|
1032
1121
|
keepAspectRatio?: boolean;
|
|
1033
1122
|
opacity?: number;
|
|
1034
1123
|
align?: string;
|
|
1124
|
+
rotation?: number;
|
|
1125
|
+
rotationOrigin?: [number, number];
|
|
1126
|
+
skewX?: number;
|
|
1127
|
+
skewY?: number;
|
|
1035
1128
|
}
|
|
1036
1129
|
|
|
1037
1130
|
interface InfoOptions {
|
|
1131
|
+
/** Additional Info dictionary entries; arrays are joined with a comma and space. */
|
|
1132
|
+
[key: string]: string | string[] | undefined;
|
|
1038
1133
|
version?: string;
|
|
1039
1134
|
author?: string;
|
|
1040
1135
|
title?: string;
|
|
@@ -1050,12 +1145,46 @@ declare namespace muhammara {
|
|
|
1050
1145
|
fitHeight?: boolean;
|
|
1051
1146
|
}
|
|
1052
1147
|
|
|
1148
|
+
interface MetadataPage {
|
|
1149
|
+
pageNumber: number;
|
|
1150
|
+
mediaBox: number[];
|
|
1151
|
+
layout: "portrait" | "landscape";
|
|
1152
|
+
rotate: number;
|
|
1153
|
+
width: number;
|
|
1154
|
+
height: number;
|
|
1155
|
+
size?: number[];
|
|
1156
|
+
offsetX?: number;
|
|
1157
|
+
offsetY?: number;
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
interface ReadMetadataPage extends MetadataPage {
|
|
1161
|
+
size: number[];
|
|
1162
|
+
offsetX: number;
|
|
1163
|
+
offsetY: number;
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
interface Metadata {
|
|
1167
|
+
/** Number of pages in a parsed source PDF. */
|
|
1168
|
+
pages?: number;
|
|
1169
|
+
/** Number of pages created in a new PDF. */
|
|
1170
|
+
pageCount?: number;
|
|
1171
|
+
[page: number]: MetadataPage | undefined;
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
interface ReadMetadata extends Metadata {
|
|
1175
|
+
pages: number;
|
|
1176
|
+
pageCount?: never;
|
|
1177
|
+
[page: number]: ReadMetadataPage | undefined;
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1053
1180
|
interface TextBoxStyle {
|
|
1054
1181
|
lineWidth?: number;
|
|
1055
|
-
stroke?:
|
|
1056
|
-
dash?: number[];
|
|
1057
|
-
fill?:
|
|
1182
|
+
stroke?: Color;
|
|
1183
|
+
dash?: readonly number[];
|
|
1184
|
+
fill?: Color;
|
|
1185
|
+
colorspace?: Colorspace;
|
|
1058
1186
|
opacity?: number;
|
|
1187
|
+
borderRadius?: boolean | BorderRadius;
|
|
1059
1188
|
}
|
|
1060
1189
|
|
|
1061
1190
|
interface TextBoxClipResult {
|
|
@@ -1074,34 +1203,54 @@ declare namespace muhammara {
|
|
|
1074
1203
|
width?: number;
|
|
1075
1204
|
height?: number;
|
|
1076
1205
|
minHeight?: number;
|
|
1077
|
-
padding?: number | number[];
|
|
1206
|
+
padding?: number | readonly number[];
|
|
1078
1207
|
lineHeight?: number;
|
|
1208
|
+
wrap?: boolean | "auto" | "clip" | "trim" | "ellipsis";
|
|
1079
1209
|
textAlign?: string;
|
|
1080
1210
|
clipIfExceedsBox?: boolean;
|
|
1081
1211
|
onClip?: (recipe: Recipe, result: TextBoxClipResult) => void;
|
|
1082
1212
|
style?: TextBoxStyle;
|
|
1083
1213
|
}
|
|
1084
1214
|
|
|
1215
|
+
interface TextOverflowInstructions {
|
|
1216
|
+
layout?: number | string;
|
|
1217
|
+
column?: number | readonly [number, number];
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
type TextOverflowCallback = (
|
|
1221
|
+
this: Recipe,
|
|
1222
|
+
recipe: Recipe,
|
|
1223
|
+
) => boolean | TextOverflowInstructions;
|
|
1224
|
+
|
|
1085
1225
|
interface TextOptions {
|
|
1226
|
+
/** Make the rendered text open this URL. */
|
|
1227
|
+
link?: string;
|
|
1086
1228
|
charSpace?: number;
|
|
1087
|
-
color?:
|
|
1229
|
+
color?: Color;
|
|
1230
|
+
colorspace?: Colorspace;
|
|
1088
1231
|
flow?: boolean;
|
|
1089
|
-
overflow?:
|
|
1232
|
+
overflow?: TextOverflowCallback;
|
|
1090
1233
|
layout?: number | string;
|
|
1091
1234
|
opacity?: number;
|
|
1092
1235
|
rotation?: number;
|
|
1093
|
-
rotationOrigin?: [number, number];
|
|
1236
|
+
rotationOrigin?: readonly [number, number];
|
|
1094
1237
|
font?: string;
|
|
1238
|
+
/** Font size in points for text() and textDimensions(); defaults to 14 when both fontSize and size are omitted. */
|
|
1239
|
+
fontSize?: number;
|
|
1240
|
+
/** Font size in points for text() and textDimensions(); defaults to 14. */
|
|
1095
1241
|
size?: number;
|
|
1242
|
+
bold?: boolean;
|
|
1243
|
+
italic?: boolean;
|
|
1096
1244
|
align?: string;
|
|
1097
|
-
highlight?: boolean;
|
|
1098
|
-
underline?: boolean;
|
|
1099
|
-
strikeOut?: boolean;
|
|
1245
|
+
highlight?: boolean | TextMarkupOptions;
|
|
1246
|
+
underline?: boolean | TextMarkupOptions;
|
|
1247
|
+
strikeOut?: boolean | TextMarkupOptions;
|
|
1248
|
+
squiggly?: boolean | TextMarkupOptions;
|
|
1100
1249
|
html?: boolean;
|
|
1101
1250
|
hilite?:
|
|
1102
1251
|
| boolean
|
|
1103
1252
|
| {
|
|
1104
|
-
color?:
|
|
1253
|
+
color?: Color;
|
|
1105
1254
|
opacity?: number;
|
|
1106
1255
|
};
|
|
1107
1256
|
textBox?: TextBox;
|
|
@@ -1114,49 +1263,230 @@ declare namespace muhammara {
|
|
|
1114
1263
|
subject?: string;
|
|
1115
1264
|
}
|
|
1116
1265
|
|
|
1117
|
-
interface
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
lineWidth?: number;
|
|
1122
|
-
opacity?: number;
|
|
1123
|
-
dash?: number[];
|
|
1266
|
+
interface LayoutOptions {
|
|
1267
|
+
columns?: number;
|
|
1268
|
+
gap?: number;
|
|
1269
|
+
reset?: boolean;
|
|
1124
1270
|
}
|
|
1125
1271
|
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1272
|
+
type TableField<RecordType extends object> = RecordType extends unknown
|
|
1273
|
+
? RecordType extends readonly unknown[]
|
|
1274
|
+
? number extends RecordType["length"]
|
|
1275
|
+
? `${number}`
|
|
1276
|
+
: Extract<keyof RecordType, `${number}`>
|
|
1277
|
+
: | Extract<keyof RecordType, string>
|
|
1278
|
+
| `${Extract<keyof RecordType, number>}`
|
|
1279
|
+
: never;
|
|
1280
|
+
type TableColumnField<RecordType extends object> = Exclude<
|
|
1281
|
+
TableField<RecordType>,
|
|
1282
|
+
""
|
|
1283
|
+
>;
|
|
1284
|
+
type TableFieldValue<
|
|
1285
|
+
RecordType extends object,
|
|
1286
|
+
Field extends TableField<RecordType>,
|
|
1287
|
+
> = RecordType extends unknown
|
|
1288
|
+
? Field extends keyof RecordType
|
|
1289
|
+
? RecordType[Field]
|
|
1290
|
+
: Field extends `${infer NumericField extends number}`
|
|
1291
|
+
? NumericField extends keyof RecordType
|
|
1292
|
+
? RecordType[NumericField]
|
|
1293
|
+
: undefined
|
|
1294
|
+
: undefined
|
|
1295
|
+
: never;
|
|
1296
|
+
|
|
1297
|
+
interface TableColumnDefinition<
|
|
1298
|
+
RecordType extends object = Record<string, unknown>,
|
|
1299
|
+
Field extends TableColumnField<RecordType> = TableColumnField<RecordType>,
|
|
1300
|
+
> extends Omit<TextOptions, "textBox"> {
|
|
1301
|
+
name: Field;
|
|
1302
|
+
text?: string;
|
|
1303
|
+
width?: number;
|
|
1304
|
+
cell?: TextBox;
|
|
1305
|
+
header?: boolean | TextOptions;
|
|
1306
|
+
hcell?: TextBox;
|
|
1307
|
+
renderer?: (
|
|
1308
|
+
this: void,
|
|
1309
|
+
text: undefined extends TableFieldValue<RecordType, Field>
|
|
1310
|
+
? Exclude<TableFieldValue<RecordType, Field>, undefined> | ""
|
|
1311
|
+
: TableFieldValue<RecordType, Field>,
|
|
1312
|
+
record: RecordType,
|
|
1313
|
+
field: Field,
|
|
1314
|
+
row: number,
|
|
1315
|
+
) => TextOptions | false | null | "" | 0 | void;
|
|
1131
1316
|
}
|
|
1132
1317
|
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1318
|
+
/**
|
|
1319
|
+
* A distributive map over every field of `RecordType`, so a column's
|
|
1320
|
+
* `renderer` receives the exact value type for its own `name` rather than
|
|
1321
|
+
* the union of all columns' value types. This costs one
|
|
1322
|
+
* `TableColumnDefinition` instantiation per field of `RecordType`; a
|
|
1323
|
+
* plain `TableColumnDefinition<RecordType>` would be cheaper but would
|
|
1324
|
+
* widen every renderer's `text` parameter to the union of all fields.
|
|
1325
|
+
*/
|
|
1326
|
+
type TableColumnOptions<
|
|
1327
|
+
RecordType extends object = Record<string, unknown>,
|
|
1328
|
+
> = {
|
|
1329
|
+
[Field in TableColumnField<RecordType>]: TableColumnDefinition<
|
|
1330
|
+
RecordType,
|
|
1331
|
+
Field
|
|
1332
|
+
>;
|
|
1333
|
+
}[TableColumnField<RecordType>];
|
|
1334
|
+
|
|
1335
|
+
interface TableOptions<
|
|
1336
|
+
RecordType extends object = Record<string, unknown>,
|
|
1337
|
+
> extends Omit<TextOptions, "overflow"> {
|
|
1338
|
+
height?: number;
|
|
1339
|
+
order?:
|
|
1340
|
+
| string
|
|
1341
|
+
| TableField<RecordType>[]
|
|
1342
|
+
| readonly [TableField<RecordType>, ...TableField<RecordType>[]];
|
|
1343
|
+
columns?: readonly TableColumnOptions<RecordType>[];
|
|
1344
|
+
header?:
|
|
1345
|
+
boolean | (TextOptions & { alignToData?: boolean; cell?: TextBox });
|
|
1346
|
+
border?: boolean | PolygonOptions;
|
|
1347
|
+
row?: TextOptions & { nth?: "even" | "odd"; cell?: TextBox };
|
|
1348
|
+
overflow?: (
|
|
1349
|
+
this: Recipe,
|
|
1350
|
+
recipe: Recipe,
|
|
1351
|
+
row: number,
|
|
1352
|
+
) => boolean | { position?: readonly [number, number] };
|
|
1140
1353
|
}
|
|
1141
1354
|
|
|
1142
|
-
interface
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1355
|
+
interface HtmlTextObject {
|
|
1356
|
+
value: string | null;
|
|
1357
|
+
tag: string | undefined;
|
|
1358
|
+
font: string | undefined;
|
|
1359
|
+
isBold: boolean;
|
|
1360
|
+
isItalic: boolean;
|
|
1361
|
+
underline: boolean;
|
|
1362
|
+
strikeOut: boolean;
|
|
1363
|
+
attributes: Array<{ name: string; value: string | null }>;
|
|
1364
|
+
styles: Record<string, string | number | number[]>;
|
|
1365
|
+
needsLineBreaker: boolean;
|
|
1366
|
+
size: number | undefined;
|
|
1367
|
+
sizeRatio: number;
|
|
1368
|
+
sizeRatios: number[];
|
|
1369
|
+
link: string | null;
|
|
1370
|
+
childs: HtmlTextObject[];
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
interface DrawingOptions {
|
|
1374
|
+
color?: Color;
|
|
1375
|
+
stroke?: Color;
|
|
1376
|
+
colorspace?: Colorspace;
|
|
1146
1377
|
lineWidth?: number;
|
|
1378
|
+
width?: number;
|
|
1147
1379
|
opacity?: number;
|
|
1148
|
-
dash?: number[];
|
|
1380
|
+
dash?: readonly number[];
|
|
1381
|
+
dashPhase?: number;
|
|
1149
1382
|
}
|
|
1150
1383
|
|
|
1151
|
-
interface
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1384
|
+
interface PathOptions extends DrawingOptions {
|
|
1385
|
+
lineCap?: "butt" | "round" | "square";
|
|
1386
|
+
lineJoin?: "miter" | "round" | "bevel";
|
|
1387
|
+
miterLimit?: number;
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1390
|
+
interface SkewOptions {
|
|
1391
|
+
skewX?: number;
|
|
1392
|
+
skewY?: number;
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
interface TransformOptions extends SkewOptions {
|
|
1396
|
+
rotation?: number;
|
|
1397
|
+
rotationOrigin?: readonly [number, number];
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
interface TransformedPathOptions extends PathOptions, TransformOptions {}
|
|
1401
|
+
|
|
1402
|
+
type LineToOptions = PathOptions;
|
|
1403
|
+
|
|
1404
|
+
type LineOptions = PathOptions;
|
|
1405
|
+
|
|
1406
|
+
interface LinkFillOptions {
|
|
1407
|
+
link?: string;
|
|
1408
|
+
fill?: Color;
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
interface PolygonOptions extends TransformedPathOptions, LinkFillOptions {}
|
|
1412
|
+
|
|
1413
|
+
interface ShapeOptions extends PolygonOptions {
|
|
1414
|
+
debug?: boolean | number;
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
interface NGonOptions extends ShapeOptions {
|
|
1418
|
+
rotationVertice?: number;
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
interface ArrowOptions extends ShapeOptions {
|
|
1422
|
+
head?:
|
|
1423
|
+
| number
|
|
1424
|
+
| readonly [number]
|
|
1425
|
+
| readonly [number, number]
|
|
1426
|
+
| readonly [number, number, number];
|
|
1427
|
+
shaft?: number | readonly [number] | readonly [number, number];
|
|
1428
|
+
double?: boolean;
|
|
1429
|
+
type?: 0 | 1 | 2 | "triangle" | "dart" | "kite";
|
|
1430
|
+
at?: "head" | "tail";
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
interface TriangleBaseOptions extends ShapeOptions {
|
|
1434
|
+
position?: TrianglePosition;
|
|
1435
|
+
flipX?: boolean;
|
|
1436
|
+
flipY?: boolean;
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
type TriangleMeasurementOptions = TriangleBaseOptions &
|
|
1440
|
+
(
|
|
1441
|
+
| { traitID: TriangleMeasurementTrait; traitsID?: TriangleTrait }
|
|
1442
|
+
| {
|
|
1443
|
+
traitID?: undefined;
|
|
1444
|
+
traitsID?: TriangleMeasurementTrait;
|
|
1445
|
+
}
|
|
1446
|
+
);
|
|
1447
|
+
type TriangleVertexIdentifier =
|
|
1448
|
+
| { traitID: TriangleVertexTrait; traitsID?: TriangleTrait }
|
|
1449
|
+
| { traitID?: undefined; traitsID: TriangleVertexTrait };
|
|
1450
|
+
type TriangleVertexOptions = TriangleBaseOptions & TriangleVertexIdentifier;
|
|
1451
|
+
type TriangleUnpositionedVertexOptions = Omit<
|
|
1452
|
+
TriangleBaseOptions,
|
|
1453
|
+
"position" | "flipX" | "flipY"
|
|
1454
|
+
> & {
|
|
1455
|
+
position?: undefined;
|
|
1456
|
+
flipX?: false;
|
|
1457
|
+
flipY?: false;
|
|
1458
|
+
} & TriangleVertexIdentifier;
|
|
1459
|
+
type TriangleOptions = TriangleMeasurementOptions | TriangleVertexOptions;
|
|
1460
|
+
type TriangleMeasurements = readonly [number, number, number];
|
|
1461
|
+
type TriangleVertices = readonly [
|
|
1462
|
+
readonly [number, number],
|
|
1463
|
+
readonly [number, number],
|
|
1464
|
+
readonly [number, number],
|
|
1465
|
+
];
|
|
1466
|
+
type MutableTriangleVertices = [
|
|
1467
|
+
[number, number],
|
|
1468
|
+
[number, number],
|
|
1469
|
+
[number, number],
|
|
1470
|
+
];
|
|
1471
|
+
|
|
1472
|
+
interface CircleOptions
|
|
1473
|
+
extends DrawingOptions, SkewOptions, LinkFillOptions {}
|
|
1474
|
+
|
|
1475
|
+
interface EllipseOptions extends CircleOptions, TransformOptions {}
|
|
1476
|
+
|
|
1477
|
+
interface RectangleOptions
|
|
1478
|
+
extends DrawingOptions, TransformOptions, LinkFillOptions {
|
|
1479
|
+
borderRadius?: BorderRadius;
|
|
1480
|
+
}
|
|
1481
|
+
|
|
1482
|
+
interface LineStyleOptions {
|
|
1483
|
+
width?: number;
|
|
1155
1484
|
lineWidth?: number;
|
|
1156
|
-
|
|
1485
|
+
cap?: number;
|
|
1486
|
+
join?: number;
|
|
1487
|
+
miterLimit?: number;
|
|
1157
1488
|
dash?: number[];
|
|
1158
|
-
|
|
1159
|
-
rotationOrigin?: number[];
|
|
1489
|
+
dashPhase?: number;
|
|
1160
1490
|
}
|
|
1161
1491
|
|
|
1162
1492
|
type EndPDFCallback1 = () => any;
|
|
@@ -1172,9 +1502,16 @@ declare namespace muhammara {
|
|
|
1172
1502
|
);
|
|
1173
1503
|
|
|
1174
1504
|
readonly position: { x: number; y: number };
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1505
|
+
/** Current document metadata, keyed by one-based page number. */
|
|
1506
|
+
readonly metadata: Recipe.Metadata;
|
|
1507
|
+
read(inSrc?: string | Buffer): Recipe.ReadMetadata;
|
|
1508
|
+
register<Arguments extends unknown[], Result>(
|
|
1509
|
+
key: string,
|
|
1510
|
+
callback: Recipe.ExtensionCallback<Arguments, Result>,
|
|
1511
|
+
): Recipe;
|
|
1512
|
+
register<Arguments extends unknown[], Result>(
|
|
1513
|
+
callback: Recipe.ExtensionCallback<Arguments, Result>,
|
|
1514
|
+
): Recipe;
|
|
1178
1515
|
|
|
1179
1516
|
constructor(
|
|
1180
1517
|
buffer: Buffer,
|
|
@@ -1189,6 +1526,14 @@ declare namespace muhammara {
|
|
|
1189
1526
|
options?: Recipe.CommentOptions,
|
|
1190
1527
|
): Recipe;
|
|
1191
1528
|
|
|
1529
|
+
link(
|
|
1530
|
+
url: string,
|
|
1531
|
+
x: number,
|
|
1532
|
+
y: number,
|
|
1533
|
+
width: number,
|
|
1534
|
+
height: number,
|
|
1535
|
+
): Recipe;
|
|
1536
|
+
|
|
1192
1537
|
annot(
|
|
1193
1538
|
x: number,
|
|
1194
1539
|
y: number,
|
|
@@ -1203,12 +1548,16 @@ declare namespace muhammara {
|
|
|
1203
1548
|
|
|
1204
1549
|
encrypt(options?: Recipe.EncryptOptions): Recipe;
|
|
1205
1550
|
|
|
1206
|
-
registerFont(
|
|
1551
|
+
registerFont(
|
|
1552
|
+
fontName: string,
|
|
1553
|
+
fontSrcPath: string,
|
|
1554
|
+
type?: Recipe.RecipeFontStyle,
|
|
1555
|
+
): Recipe;
|
|
1207
1556
|
|
|
1208
1557
|
image(
|
|
1209
1558
|
imgSrc: string,
|
|
1210
|
-
x:
|
|
1211
|
-
y:
|
|
1559
|
+
x: Recipe.RecipeCoordinate,
|
|
1560
|
+
y: Recipe.RecipeCoordinate,
|
|
1212
1561
|
options?: Recipe.ImageOptions,
|
|
1213
1562
|
): Recipe;
|
|
1214
1563
|
|
|
@@ -1222,6 +1571,7 @@ declare namespace muhammara {
|
|
|
1222
1571
|
srcPageNumber: number,
|
|
1223
1572
|
): Recipe;
|
|
1224
1573
|
|
|
1574
|
+
overlay(pdfSrc: string, options?: Recipe.OverlayOptions): Recipe;
|
|
1225
1575
|
overlay(
|
|
1226
1576
|
pdfSrc: string,
|
|
1227
1577
|
x: number,
|
|
@@ -1239,18 +1589,23 @@ declare namespace muhammara {
|
|
|
1239
1589
|
rotation?: number,
|
|
1240
1590
|
margins?: Recipe.RecipeMargins,
|
|
1241
1591
|
): Recipe;
|
|
1592
|
+
rotate(rotation: number): Recipe;
|
|
1242
1593
|
endPage(): Recipe;
|
|
1594
|
+
setPageBox(
|
|
1595
|
+
box: PDFPageBoxType,
|
|
1596
|
+
left: number,
|
|
1597
|
+
bottom: number,
|
|
1598
|
+
right: number,
|
|
1599
|
+
top: number,
|
|
1600
|
+
): Recipe;
|
|
1243
1601
|
|
|
1244
1602
|
editPage(pageNumber: number): Recipe;
|
|
1603
|
+
deletePage(pageNumbers: number | number[]): Recipe;
|
|
1245
1604
|
|
|
1246
|
-
replaceText(text: string, replacement: string, pageNumber
|
|
1605
|
+
replaceText(text: string, replacement: string, pageNumber: number): Recipe;
|
|
1247
1606
|
|
|
1248
|
-
pageInfo(pageNumber: number):
|
|
1249
|
-
|
|
1250
|
-
height: number;
|
|
1251
|
-
rotate: number;
|
|
1252
|
-
pageNumber: number;
|
|
1253
|
-
};
|
|
1607
|
+
pageInfo(pageNumber: number): RecipePageInfo;
|
|
1608
|
+
getCurrentPageInfo(): RecipePageInfo | null;
|
|
1254
1609
|
|
|
1255
1610
|
margins(): Required<Recipe.RecipeMargins>;
|
|
1256
1611
|
margins(margins: Recipe.RecipeMargins): Recipe;
|
|
@@ -1261,14 +1616,16 @@ declare namespace muhammara {
|
|
|
1261
1616
|
bottom?: number,
|
|
1262
1617
|
): Recipe;
|
|
1263
1618
|
getPageInfo(): InfoDictionary;
|
|
1264
|
-
pauseContext():
|
|
1265
|
-
resumeContext():
|
|
1619
|
+
pauseContext(): Recipe;
|
|
1620
|
+
resumeContext(): Recipe;
|
|
1621
|
+
rotateContent(degrees: number, x?: number, y?: number): Recipe;
|
|
1266
1622
|
split(outputDir?: string, prefix?: string): Recipe;
|
|
1267
1623
|
|
|
1624
|
+
text(text: string, options?: Recipe.TextOptions): Recipe;
|
|
1268
1625
|
text(
|
|
1269
1626
|
text: string,
|
|
1270
|
-
x:
|
|
1271
|
-
y:
|
|
1627
|
+
x: Recipe.RecipeCoordinate,
|
|
1628
|
+
y: Recipe.RecipeCoordinate,
|
|
1272
1629
|
options?: Recipe.TextOptions,
|
|
1273
1630
|
): Recipe;
|
|
1274
1631
|
textDimensions(text: string, options?: Recipe.TextOptions): TextDimension;
|
|
@@ -1281,9 +1638,14 @@ declare namespace muhammara {
|
|
|
1281
1638
|
y?: number,
|
|
1282
1639
|
width?: number,
|
|
1283
1640
|
height?: number,
|
|
1284
|
-
options?:
|
|
1641
|
+
options?: Recipe.LayoutOptions,
|
|
1642
|
+
): Recipe;
|
|
1643
|
+
table<RecordType extends object>(
|
|
1644
|
+
x: number,
|
|
1645
|
+
y: number,
|
|
1646
|
+
contents: readonly RecordType[],
|
|
1647
|
+
options?: Recipe.TableOptions<RecordType>,
|
|
1285
1648
|
): Recipe;
|
|
1286
|
-
table(x: number, y: number, contents: object[], options?: object): Recipe;
|
|
1287
1649
|
|
|
1288
1650
|
moveTo(x: number, y: number): Recipe;
|
|
1289
1651
|
|
|
@@ -1313,7 +1675,7 @@ declare namespace muhammara {
|
|
|
1313
1675
|
cy: number,
|
|
1314
1676
|
rx: number,
|
|
1315
1677
|
ry: number,
|
|
1316
|
-
options?: Recipe.
|
|
1678
|
+
options?: Recipe.EllipseOptions,
|
|
1317
1679
|
): Recipe;
|
|
1318
1680
|
arc(
|
|
1319
1681
|
x: number,
|
|
@@ -1321,41 +1683,67 @@ declare namespace muhammara {
|
|
|
1321
1683
|
radius: number,
|
|
1322
1684
|
startAngle?: number,
|
|
1323
1685
|
endAngle?: number,
|
|
1324
|
-
options?: Recipe.
|
|
1686
|
+
options?: Recipe.EllipseOptions,
|
|
1325
1687
|
): Recipe;
|
|
1688
|
+
pie(
|
|
1689
|
+
x: number,
|
|
1690
|
+
y: number,
|
|
1691
|
+
radius: number,
|
|
1692
|
+
startAngle?: number,
|
|
1693
|
+
endAngle?: number,
|
|
1694
|
+
options?: Recipe.EllipseOptions,
|
|
1695
|
+
): Recipe;
|
|
1696
|
+
lineStyle(options?: Recipe.LineStyleOptions): Recipe;
|
|
1326
1697
|
lineWidth(width: number): Recipe;
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1698
|
+
/** Set fill and stroke opacity from 0 (transparent) to 1 (opaque). */
|
|
1699
|
+
opacity(opacity: number): Recipe;
|
|
1700
|
+
fill(color?: Recipe.Color): Recipe;
|
|
1701
|
+
stroke(color?: Recipe.Color): Recipe;
|
|
1702
|
+
fillAndStroke(fill?: Recipe.Color, stroke?: Recipe.Color): Recipe;
|
|
1331
1703
|
n_gon(
|
|
1332
1704
|
cx: number,
|
|
1333
1705
|
cy: number,
|
|
1334
1706
|
radius: number,
|
|
1335
|
-
sides?: number | Recipe.
|
|
1336
|
-
options?: Recipe.
|
|
1707
|
+
sides?: number | Recipe.NGonOptions,
|
|
1708
|
+
options?: Recipe.NGonOptions,
|
|
1337
1709
|
): Recipe;
|
|
1338
1710
|
star(
|
|
1339
1711
|
cx: number,
|
|
1340
1712
|
cy: number,
|
|
1341
1713
|
radius: number,
|
|
1342
|
-
points?: number | Recipe.
|
|
1343
|
-
options?: Recipe.
|
|
1714
|
+
points?: number | Recipe.ShapeOptions,
|
|
1715
|
+
options?: Recipe.ShapeOptions,
|
|
1344
1716
|
): Recipe;
|
|
1345
1717
|
triangle(
|
|
1346
1718
|
x: number,
|
|
1347
1719
|
y: number,
|
|
1348
|
-
traits:
|
|
1349
|
-
options?: Recipe.
|
|
1720
|
+
traits: Recipe.TriangleMeasurements,
|
|
1721
|
+
options?: Recipe.TriangleMeasurementOptions,
|
|
1722
|
+
): Recipe;
|
|
1723
|
+
triangle(
|
|
1724
|
+
x: number,
|
|
1725
|
+
y: number,
|
|
1726
|
+
traits: Recipe.TriangleVertices,
|
|
1727
|
+
options: Recipe.TriangleUnpositionedVertexOptions,
|
|
1728
|
+
): Recipe;
|
|
1729
|
+
triangle(
|
|
1730
|
+
x: number,
|
|
1731
|
+
y: number,
|
|
1732
|
+
traits: Recipe.MutableTriangleVertices,
|
|
1733
|
+
options: Recipe.TriangleVertexOptions,
|
|
1734
|
+
): Recipe;
|
|
1735
|
+
arrow(x: number, y: number, options?: Recipe.ArrowOptions): Recipe;
|
|
1736
|
+
chroma<ColorspaceValue extends string | undefined = undefined>(
|
|
1737
|
+
name: string,
|
|
1738
|
+
value: Recipe.Color,
|
|
1739
|
+
colorspace?: Recipe.ValidColorspace<ColorspaceValue>,
|
|
1350
1740
|
): Recipe;
|
|
1351
|
-
|
|
1352
|
-
chroma(name: string, value: string | number[], colorspace?: string): Recipe;
|
|
1353
|
-
permission(flags?: string): number;
|
|
1741
|
+
permission(flags?: Recipe.PermissionList): number;
|
|
1354
1742
|
structure(output: string): Recipe;
|
|
1355
1743
|
htmlToTextObjects(
|
|
1356
1744
|
htmlCodes: string,
|
|
1357
1745
|
options?: Recipe.TextOptions,
|
|
1358
|
-
):
|
|
1746
|
+
): Recipe.HtmlTextObject[];
|
|
1359
1747
|
|
|
1360
1748
|
endPDF(): void;
|
|
1361
1749
|
endPDF<T>(callback: (output?: Buffer | string) => T): T;
|