@ironsoftware/ironpdf 2024.12.9 → 2025.2.1

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.
Files changed (131) hide show
  1. package/package.json +6 -3
  2. package/src/internal/IronPdfEngine.ProtoFiles/chrome_render.proto +1 -0
  3. package/src/internal/IronPdfEngine.ProtoFiles/iron_pdf_service.proto +2 -0
  4. package/src/internal/IronPdfEngine.ProtoFiles/pdfium_annotation.proto +9 -14
  5. package/src/internal/IronPdfEngine.ProtoFiles/pdfium_page.proto +13 -0
  6. package/src/internal/IronPdfEngine.ProtoFiles/pdfium_pdf_document.proto +13 -0
  7. package/src/internal/access.d.ts +2 -3
  8. package/src/internal/access.d.ts.map +1 -1
  9. package/src/internal/access.ts +0 -2
  10. package/src/internal/generated_proto/iron_pdf_service.d.ts +3 -0
  11. package/src/internal/generated_proto/iron_pdf_service.d.ts.map +1 -1
  12. package/src/internal/generated_proto/iron_pdf_service.ts +3 -0
  13. package/src/internal/generated_proto/ironpdfengineproto/ChromePdfRenderOptionsP.d.ts +3 -0
  14. package/src/internal/generated_proto/ironpdfengineproto/ChromePdfRenderOptionsP.d.ts.map +1 -1
  15. package/src/internal/generated_proto/ironpdfengineproto/ChromePdfRenderOptionsP.ts +3 -0
  16. package/src/internal/generated_proto/ironpdfengineproto/IronPdfService.d.ts +23 -0
  17. package/src/internal/generated_proto/ironpdfengineproto/IronPdfService.d.ts.map +1 -1
  18. package/src/internal/generated_proto/ironpdfengineproto/IronPdfService.ts +27 -0
  19. package/src/internal/generated_proto/ironpdfengineproto/PdfiumAddLinkAnnotationRequestP.d.ts +9 -8
  20. package/src/internal/generated_proto/ironpdfengineproto/PdfiumAddLinkAnnotationRequestP.d.ts.map +1 -1
  21. package/src/internal/generated_proto/ironpdfengineproto/PdfiumAddLinkAnnotationRequestP.ts +9 -8
  22. package/src/internal/generated_proto/ironpdfengineproto/PdfiumAddPageRequestP.d.ts +12 -0
  23. package/src/internal/generated_proto/ironpdfengineproto/PdfiumAddPageRequestP.d.ts.map +1 -0
  24. package/src/internal/generated_proto/ironpdfengineproto/PdfiumAddPageRequestP.js +4 -0
  25. package/src/internal/generated_proto/ironpdfengineproto/PdfiumAddPageRequestP.js.map +1 -0
  26. package/src/internal/generated_proto/ironpdfengineproto/PdfiumAddPageRequestP.ts +15 -0
  27. package/src/internal/generated_proto/ironpdfengineproto/PdfiumAddPageResultP.d.ts +11 -0
  28. package/src/internal/generated_proto/ironpdfengineproto/PdfiumAddPageResultP.d.ts.map +1 -0
  29. package/src/internal/generated_proto/ironpdfengineproto/PdfiumAddPageResultP.js +4 -0
  30. package/src/internal/generated_proto/ironpdfengineproto/PdfiumAddPageResultP.js.map +1 -0
  31. package/src/internal/generated_proto/ironpdfengineproto/PdfiumAddPageResultP.ts +14 -0
  32. package/src/internal/generated_proto/ironpdfengineproto/PdfiumConvertToPdfUAForScreenReaderRequestP.d.ts +12 -0
  33. package/src/internal/generated_proto/ironpdfengineproto/PdfiumConvertToPdfUAForScreenReaderRequestP.d.ts.map +1 -0
  34. package/src/internal/generated_proto/ironpdfengineproto/PdfiumConvertToPdfUAForScreenReaderRequestP.js +4 -0
  35. package/src/internal/generated_proto/ironpdfengineproto/PdfiumConvertToPdfUAForScreenReaderRequestP.js.map +1 -0
  36. package/src/internal/generated_proto/ironpdfengineproto/PdfiumConvertToPdfUAForScreenReaderRequestP.ts +15 -0
  37. package/src/internal/generated_proto/ironpdfengineproto/PdfiumEmbedFileToPdfARequestStreamP.d.ts +14 -0
  38. package/src/internal/generated_proto/ironpdfengineproto/PdfiumEmbedFileToPdfARequestStreamP.d.ts.map +1 -1
  39. package/src/internal/generated_proto/ironpdfengineproto/PdfiumEmbedFileToPdfARequestStreamP.ts +14 -0
  40. package/src/internal/generated_proto/ironpdfengineproto/PdfiumPdfAnnotationP.d.ts +9 -8
  41. package/src/internal/generated_proto/ironpdfengineproto/PdfiumPdfAnnotationP.d.ts.map +1 -1
  42. package/src/internal/generated_proto/ironpdfengineproto/PdfiumPdfAnnotationP.ts +9 -8
  43. package/src/internal/generated_proto/ironpdfengineproto/PdfiumTextAnnotationP.d.ts +4 -12
  44. package/src/internal/generated_proto/ironpdfengineproto/PdfiumTextAnnotationP.d.ts.map +1 -1
  45. package/src/internal/generated_proto/ironpdfengineproto/PdfiumTextAnnotationP.ts +4 -12
  46. package/src/internal/grpc_layer/chrome/converter.d.ts +23 -23
  47. package/src/internal/grpc_layer/chrome/converter.d.ts.map +1 -1
  48. package/src/internal/grpc_layer/chrome/converter.js +93 -102
  49. package/src/internal/grpc_layer/chrome/converter.js.map +1 -1
  50. package/src/internal/grpc_layer/chrome/converter.ts +140 -145
  51. package/src/internal/grpc_layer/chrome/render.d.ts +5 -5
  52. package/src/internal/grpc_layer/chrome/render.d.ts.map +1 -1
  53. package/src/internal/grpc_layer/chrome/render.js.map +1 -1
  54. package/src/internal/grpc_layer/chrome/render.ts +7 -7
  55. package/src/internal/grpc_layer/chrome/stamp.d.ts +16 -16
  56. package/src/internal/grpc_layer/chrome/stamp.d.ts.map +1 -1
  57. package/src/internal/grpc_layer/chrome/stamp.js.map +1 -1
  58. package/src/internal/grpc_layer/chrome/stamp.ts +16 -16
  59. package/src/internal/grpc_layer/handshake.js +1 -1
  60. package/src/internal/grpc_layer/handshake.js.map +1 -1
  61. package/src/internal/grpc_layer/handshake.ts +1 -1
  62. package/src/internal/grpc_layer/pdfium/converter.d.ts.map +1 -1
  63. package/src/internal/grpc_layer/pdfium/converter.js +3 -4
  64. package/src/internal/grpc_layer/pdfium/converter.js.map +1 -1
  65. package/src/internal/grpc_layer/pdfium/converter.ts +3 -4
  66. package/src/internal/grpc_layer/pdfium/headerFooter.d.ts.map +1 -1
  67. package/src/internal/grpc_layer/pdfium/headerFooter.js.map +1 -1
  68. package/src/internal/grpc_layer/pdfium/headerFooter.ts +0 -2
  69. package/src/internal/grpc_layer/pdfium/image.d.ts.map +1 -1
  70. package/src/internal/grpc_layer/pdfium/image.js +8 -5
  71. package/src/internal/grpc_layer/pdfium/image.js.map +1 -1
  72. package/src/internal/grpc_layer/pdfium/image.ts +9 -8
  73. package/src/internal/grpc_layer/pdfium/io.d.ts +5 -5
  74. package/src/internal/grpc_layer/pdfium/io.d.ts.map +1 -1
  75. package/src/internal/grpc_layer/pdfium/io.js +6 -5
  76. package/src/internal/grpc_layer/pdfium/io.js.map +1 -1
  77. package/src/internal/grpc_layer/pdfium/io.ts +5 -5
  78. package/src/internal/grpc_layer/pdfium/page.d.ts.map +1 -1
  79. package/src/internal/grpc_layer/pdfium/page.js +27 -21
  80. package/src/internal/grpc_layer/pdfium/page.js.map +1 -1
  81. package/src/internal/grpc_layer/pdfium/page.ts +32 -27
  82. package/src/internal/grpc_layer/pdfium/pdfa.d.ts.map +1 -1
  83. package/src/internal/grpc_layer/pdfium/pdfa.js.map +1 -1
  84. package/src/internal/grpc_layer/pdfium/pdfa.ts +0 -2
  85. package/src/internal/grpc_layer/pdfium/security.d.ts.map +1 -1
  86. package/src/internal/grpc_layer/pdfium/security.js +9 -6
  87. package/src/internal/grpc_layer/pdfium/security.js.map +1 -1
  88. package/src/internal/grpc_layer/pdfium/security.ts +6 -7
  89. package/src/internal/grpc_layer/pdfium/signing.js +15 -15
  90. package/src/internal/grpc_layer/pdfium/signing.js.map +1 -1
  91. package/src/internal/grpc_layer/pdfium/signing.ts +4 -4
  92. package/src/internal/grpc_layer/pdfium/text.d.ts.map +1 -1
  93. package/src/internal/grpc_layer/pdfium/text.js.map +1 -1
  94. package/src/internal/grpc_layer/pdfium/text.ts +0 -2
  95. package/src/internal/grpc_layer/util.d.ts +6 -6
  96. package/src/internal/grpc_layer/util.d.ts.map +1 -1
  97. package/src/internal/grpc_layer/util.js +25 -14
  98. package/src/internal/grpc_layer/util.js.map +1 -1
  99. package/src/internal/grpc_layer/util.ts +35 -17
  100. package/src/internal/zod/ironpdfglobalconfigSchema.d.ts.map +1 -1
  101. package/src/internal/zod/ironpdfglobalconfigSchema.ts +1 -1
  102. package/src/internal/zod/stampSchema.d.ts +6 -6
  103. package/src/public/affix.d.ts +11 -11
  104. package/src/public/affix.d.ts.map +1 -1
  105. package/src/public/affix.ts +12 -12
  106. package/src/public/ironpdfglobalconfig.d.ts +9 -9
  107. package/src/public/ironpdfglobalconfig.d.ts.map +1 -1
  108. package/src/public/ironpdfglobalconfig.ts +9 -9
  109. package/src/public/pdfDocument.d.ts +52 -52
  110. package/src/public/pdfDocument.d.ts.map +1 -1
  111. package/src/public/pdfDocument.js +21 -17
  112. package/src/public/pdfDocument.js.map +1 -1
  113. package/src/public/pdfDocument.ts +134 -138
  114. package/src/public/pdfGenerator.d.ts +1 -1
  115. package/src/public/pdfGenerator.d.ts.map +1 -1
  116. package/src/public/pdfGenerator.ts +1 -1
  117. package/src/public/render.d.ts +33 -33
  118. package/src/public/render.d.ts.map +1 -1
  119. package/src/public/render.ts +37 -37
  120. package/src/public/security.d.ts +10 -10
  121. package/src/public/security.d.ts.map +1 -1
  122. package/src/public/security.ts +10 -10
  123. package/src/public/signature.d.ts +12 -12
  124. package/src/public/signature.d.ts.map +1 -1
  125. package/src/public/signature.ts +12 -12
  126. package/src/public/stamp.d.ts +26 -26
  127. package/src/public/stamp.d.ts.map +1 -1
  128. package/src/public/stamp.ts +27 -27
  129. package/src/public/types.d.ts +15 -15
  130. package/src/public/types.d.ts.map +1 -1
  131. package/src/public/types.ts +14 -14
@@ -54,7 +54,7 @@ import {pdfPaperSizeSchema} from "../internal/zod/paperSchema";
54
54
  import {pageRotationSchema} from "../internal/zod/pageSchema";
55
55
  import {chromePdfRenderOptionsSchema, httpLoginCredentialsSchema} from "../internal/zod/renderSchema";
56
56
  import {
57
- getFileNames,
57
+ getFileName,
58
58
  getImageExtType,
59
59
  separateImageBufferOrImagePathInput,
60
60
  separatePdfInput
@@ -111,34 +111,34 @@ export class PdfDocument{
111
111
  * required for open a protected PDF file
112
112
  * @default undefined
113
113
  */
114
- password?: PdfPassword;
114
+ password?: PdfPassword | undefined;
115
115
  /**
116
116
  * Apply renderOptions if PdfInput is a {@link HtmlString} or {@link HtmlFilePath} or {@link ZipFilePath} or {@link Url}}
117
117
  * @default undefined
118
118
  */
119
- renderOptions?: ChromePdfRenderOptions;
119
+ renderOptions?: ChromePdfRenderOptions | undefined;
120
120
  /**
121
121
  * Apply httpLoginCredentials if PdfInput is a {@link HtmlString} or {@link HtmlFilePath} or {@link ZipFilePath} or {@link Url}}
122
122
  * @default undefined
123
123
  */
124
- httpLoginCredentials?: HttpLoginCredentials;
124
+ httpLoginCredentials?: HttpLoginCredentials | undefined;
125
125
  /**
126
126
  * Apply mainHtmlFile if PdfInput is {@link ZipFilePath}
127
127
  * @default index.html
128
128
  */
129
- mainHtmlFile?: string;
129
+ mainHtmlFile?: string | undefined;
130
130
  /**
131
131
  * Optionally track changes to the document (for use with incremental saves)
132
132
  * @default {@link ChangeTrackingModes.AutoChangeTracking}
133
133
  */
134
- trackChanges?: ChangeTrackingModes;
134
+ trackChanges?: ChangeTrackingModes | undefined;
135
135
  // /**
136
136
  // * Apply baseUrl if
137
137
  // * The HTML base URL for which references to external CSS, Javascript and Image files will be relative.
138
138
  // * @default undefined
139
139
  // */
140
- // baseUrl?: string; //not supported
141
- }
140
+ // baseUrl ?: string | undefined; //not supported
141
+ } | undefined
142
142
  ): Promise<PdfDocument> {
143
143
  return z.function()
144
144
  .args(
@@ -162,7 +162,7 @@ export class PdfDocument{
162
162
  * @param Optionally track changes to the document (for use with incremental saves)
163
163
  */
164
164
  public static async fromFile(
165
- pdfFilePath: string, trackChanges?: ChangeTrackingModes
165
+ pdfFilePath: string, trackChanges?: ChangeTrackingModes | undefined
166
166
  ): Promise<PdfDocument> {
167
167
  return z.function()
168
168
  .args(
@@ -186,8 +186,8 @@ export class PdfDocument{
186
186
  * Apply renderOptions if PdfInput is a {@link HtmlString} or {@link HtmlFilePath} or {@link ZipFilePath} or {@link Url}}
187
187
  * @default undefined
188
188
  */
189
- renderOptions?: ChromePdfRenderOptions;
190
- }
189
+ renderOptions?: ChromePdfRenderOptions | undefined;
190
+ } | undefined
191
191
  ): Promise<PdfDocument> {
192
192
  return z.function()
193
193
  .args(
@@ -222,12 +222,12 @@ export class PdfDocument{
222
222
  * Apply renderOptions if PdfInput is a {@link HtmlString} or {@link HtmlFilePath} or {@link ZipFilePath} or {@link Url}}
223
223
  * @default undefined
224
224
  */
225
- renderOptions?: ChromePdfRenderOptions;
225
+ renderOptions?: ChromePdfRenderOptions | undefined;
226
226
  /**
227
227
  * a main .html file default: `index.html`
228
228
  */
229
- mainHtmlFile?: string;
230
- }
229
+ mainHtmlFile?: string | undefined;
230
+ } | undefined
231
231
  ): Promise<PdfDocument> {
232
232
  return z.function()
233
233
  .args(
@@ -254,8 +254,8 @@ export class PdfDocument{
254
254
  * Apply renderOptions if PdfInput is a {@link HtmlString} or {@link HtmlFilePath} or {@link ZipFilePath} or {@link Url}}
255
255
  * @default undefined
256
256
  */
257
- renderOptions?: ChromePdfRenderOptions;
258
- }
257
+ renderOptions?: ChromePdfRenderOptions | undefined;
258
+ } | undefined
259
259
  ): Promise<PdfDocument> {
260
260
  return z.function()
261
261
  .args(
@@ -283,7 +283,7 @@ export class PdfDocument{
283
283
  * Apply renderOptions if PdfInput is a {@link HtmlString} or {@link HtmlFilePath} or {@link ZipFilePath} or {@link Url}}
284
284
  * @default undefined
285
285
  */
286
- imageToPdfOptions?: ImageToPdfOptions;
286
+ imageToPdfOptions?: ImageToPdfOptions | undefined;
287
287
  }
288
288
  ): Promise<PdfDocument> {
289
289
  return z.function()
@@ -318,7 +318,7 @@ export class PdfDocument{
318
318
  * @param filePath Target file path
319
319
  * @param saveOptions see {@link SaveOptions}
320
320
  */
321
- public saveAs(filePath: string, saveOptions?: SaveOptions): Promise<void> {
321
+ public saveAs(filePath: string, saveOptions?: SaveOptions | undefined): Promise<void> {
322
322
  return z.function()
323
323
  .args(
324
324
  stringSchema,
@@ -333,7 +333,7 @@ export class PdfDocument{
333
333
  * Saves the PdfDocument to a binary (Buffer)
334
334
  * @param saveOptions see {@link SaveOptions}
335
335
  */
336
- public async saveAsBuffer(saveOptions?: SaveOptions): Promise<Buffer> {
336
+ public async saveAsBuffer(saveOptions?: SaveOptions | undefined): Promise<Buffer> {
337
337
  return z.function()
338
338
  .args(
339
339
  saveOptionsSchema.optional()
@@ -402,8 +402,8 @@ export class PdfDocument{
402
402
  /**
403
403
  * @default "all"
404
404
  */
405
- pdfPageSelection?: PdfPageSelection;
406
- }
405
+ pdfPageSelection?: PdfPageSelection | undefined;
406
+ } | undefined
407
407
  ) {
408
408
  return z.function()
409
409
  .args(
@@ -426,8 +426,8 @@ export class PdfDocument{
426
426
  /**
427
427
  * @default "all"
428
428
  */
429
- pdfPageSelection?: PdfPageSelection;
430
- }
429
+ pdfPageSelection?: PdfPageSelection | undefined;
430
+ } | undefined
431
431
  ): Promise<void> {
432
432
  return z.function()
433
433
  .args(
@@ -522,7 +522,7 @@ export class PdfDocument{
522
522
  * @default "all"
523
523
  */
524
524
  fromPages?: PdfPageSelection;
525
- }): Promise<Buffer[]> {
525
+ } | undefined): Promise<Buffer[]> {
526
526
  return z.function()
527
527
  .args(
528
528
  z.object({fromPages: pdfPageSelectionSchema.optional()}).optional()
@@ -544,12 +544,12 @@ export class PdfDocument{
544
544
  /**
545
545
  * @default "all"
546
546
  */
547
- fromPages?: PdfPageSelection;
547
+ fromPages?: PdfPageSelection | undefined;
548
548
  /**
549
549
  * @default {@link ImageType.PNG}
550
550
  */
551
- imageType?: ImageType;
552
- }): Promise<Buffer[]> {
551
+ imageType?: ImageType | undefined;
552
+ } | undefined): Promise<Buffer[]> {
553
553
  return z.function()
554
554
  .args(
555
555
  z.object({
@@ -577,12 +577,12 @@ export class PdfDocument{
577
577
  /**
578
578
  * @default "all"
579
579
  */
580
- fromPages?: PdfPageSelection;
580
+ fromPages?: PdfPageSelection | undefined;
581
581
  /**
582
582
  * @default {@link ImageType.PNG}
583
583
  */
584
- type?: ImageType;
585
- }
584
+ type?: ImageType | undefined;
585
+ } | undefined
586
586
  ): Promise<string[]> {
587
587
  return z.function()
588
588
  .args(
@@ -609,7 +609,7 @@ export class PdfDocument{
609
609
  public async replaceText(
610
610
  oldText: string,
611
611
  newText: string,
612
- onPages?: PdfPageSelection
612
+ onPages?: PdfPageSelection | undefined
613
613
  ): Promise<void> {
614
614
  return z.function()
615
615
  .args(
@@ -622,7 +622,7 @@ export class PdfDocument{
622
622
  }
623
623
 
624
624
  public async extractText(
625
- onPages?: PdfPageSelection
625
+ onPages?: PdfPageSelection | undefined
626
626
  ): Promise<string> {
627
627
  return z.function()
628
628
  .args(pdfPageSelectionSchema.optional())
@@ -638,7 +638,7 @@ export class PdfDocument{
638
638
  * Convert the current document into the specified PDF-A standard format
639
639
  * @param customICC (Optional) Custom color profile file path
640
640
  */
641
- public async convertToPdfA(customICC?: string): Promise<void> {
641
+ public async convertToPdfA(customICC?: string | undefined): Promise<void> {
642
642
  return z.function()
643
643
  .args(z.string({description: "customICC: string"}).optional())
644
644
  .returns(z.promise(z.void()))
@@ -748,7 +748,7 @@ export class PdfDocument{
748
748
  */
749
749
  public async addTextHeader(
750
750
  header: TextAffix,
751
- toPages?: PdfPageSelection
751
+ toPages?: PdfPageSelection | undefined
752
752
  ): Promise<void> {
753
753
  return z.function()
754
754
  .args(textAffixSchema, pdfPageSelectionSchema.optional())
@@ -764,7 +764,7 @@ export class PdfDocument{
764
764
  */
765
765
  public async addTextFooter(
766
766
  footer: TextAffix,
767
- toPages?: PdfPageSelection
767
+ toPages?: PdfPageSelection | undefined
768
768
  ): Promise<void> {
769
769
  return z.function()
770
770
  .args(textAffixSchema, pdfPageSelectionSchema.optional())
@@ -780,7 +780,7 @@ export class PdfDocument{
780
780
  */
781
781
  public async addHtmlHeader(
782
782
  header: HtmlAffix,
783
- toPages?: PdfPageSelection
783
+ toPages?: PdfPageSelection | undefined
784
784
  ): Promise<void> {
785
785
  return z.function()
786
786
  .args(htmlAffixSchema, pdfPageSelectionSchema.optional())
@@ -796,7 +796,7 @@ export class PdfDocument{
796
796
  */
797
797
  public async addHtmlFooter(
798
798
  footer: HtmlAffix,
799
- toPages?: PdfPageSelection
799
+ toPages?: PdfPageSelection | undefined
800
800
  ): Promise<void> {
801
801
  return z.function()
802
802
  .args(htmlAffixSchema, pdfPageSelectionSchema.optional())
@@ -816,9 +816,9 @@ export class PdfDocument{
816
816
  public async stampHtml(
817
817
  htmlStringOrHtmlFilePath: HtmlFilePath | HtmlString,
818
818
  options?: {
819
- htmlStampOptions?: HtmlStampOptions;
820
- toPages?: PdfPageSelection;
821
- }
819
+ htmlStampOptions?: HtmlStampOptions | undefined;
820
+ toPages?: PdfPageSelection | undefined;
821
+ } | undefined
822
822
  ) {
823
823
  return z.function()
824
824
  .args(z.union([htmlFilePathSchema, htmlStringSchema]), z.object({
@@ -838,9 +838,9 @@ export class PdfDocument{
838
838
  public async stampImage(
839
839
  image: ImageFilePath | ImageBuffer,
840
840
  options?: {
841
- imageStampOptions?: ImageStampOptions;
842
- toPages?: PdfPageSelection;
843
- }
841
+ imageStampOptions?: ImageStampOptions | undefined;
842
+ toPages?: PdfPageSelection | undefined;
843
+ } | undefined
844
844
  ) {
845
845
  return z.function()
846
846
  .args(z.union([imageFilePathSchema, imageBufferSchema]), z.object({
@@ -860,9 +860,9 @@ export class PdfDocument{
860
860
  public async stampText(
861
861
  text: string,
862
862
  options?: {
863
- textStampOptions?: TextStampOptions;
864
- toPages?: PdfPageSelection;
865
- }
863
+ textStampOptions?: TextStampOptions | undefined;
864
+ toPages?: PdfPageSelection | undefined;
865
+ } | undefined
866
866
  ) {
867
867
  return z.function()
868
868
  .args(stringSchema, z.object({
@@ -883,9 +883,9 @@ export class PdfDocument{
883
883
  barcodeValue: string,
884
884
  options?: {
885
885
  barcodeEncoding: BarcodeType;
886
- barcodeStampOptions?: BarcodeStampOptions;
887
- toPages?: PdfPageSelection;
888
- }
886
+ barcodeStampOptions?: BarcodeStampOptions | undefined;
887
+ toPages?: PdfPageSelection | undefined;
888
+ } | undefined
889
889
  ) {
890
890
  return z.function()
891
891
  .args(stringSchema, z.object({
@@ -912,7 +912,7 @@ export class PdfDocument{
912
912
  public async addBackgroundFromAnotherPdf(
913
913
  fromPdf: PdfDocument,
914
914
  sourcePageIndex = 0,
915
- applyToPages?: PdfPageSelection
915
+ applyToPages?: PdfPageSelection | undefined
916
916
  ): Promise<void> {
917
917
  return z.function()
918
918
  .args(pdfDocumentSchema, numberSchema, pdfPageSelectionSchema.optional())
@@ -932,7 +932,7 @@ export class PdfDocument{
932
932
  public async addForegroundFromAnotherPdf(
933
933
  fromPdf: PdfDocument,
934
934
  sourcePageIndex = 0,
935
- applyToPages?: PdfPageSelection
935
+ applyToPages?: PdfPageSelection | undefined
936
936
  ): Promise<void> {
937
937
  return z.function()
938
938
  .args(pdfDocumentSchema, numberSchema, pdfPageSelectionSchema.optional())
@@ -1033,25 +1033,25 @@ export class PdfDocument{
1033
1033
  * Internal PDF document ID
1034
1034
  * @private
1035
1035
  */
1036
- private pdfDocumentId?: string;
1036
+ private pdfDocumentId?: string | undefined;
1037
1037
  /**
1038
1038
  * @private
1039
1039
  */
1040
- private readonly promiseDocumentId?: Promise<string>;
1040
+ private readonly promiseDocumentId?: Promise<string> | undefined;
1041
1041
  /**
1042
1042
  * @private
1043
1043
  */
1044
- private pdfPassword?: PdfPassword;
1044
+ private pdfPassword?: PdfPassword | undefined;
1045
1045
 
1046
1046
  /**
1047
1047
  * Create a PdfDocument object from a {@link PdfInput}
1048
1048
  * For more specific way to create/open PdfDocument see {@link fromUrl} {@link fromZip} {@link fromHtml} {@link fromImage} {@link open}
1049
1049
  *
1050
- * @param pdfInput see {@link PdfInput} (required)
1051
- * @param password a password to open the PDF required if PDF file was private (pdfInput is {@link PdfFilePath} or {@link Buffer})
1050
+ * @param pdfInput see {@link PdfInput} (required) (pdfInput is {@link PdfFilePath} or {@link Buffer})
1051
+ * @param password a password to open the PDF required if PDF file was private.
1052
1052
  * @param trackChanges Optionally track changes to the document (for use with incremental saves)
1053
1053
  */
1054
- constructor(pdfInput?: PdfInput, password?: PdfPassword, trackChanges?: ChangeTrackingModes) {
1054
+ constructor(pdfInput?: PdfInput | undefined, password?: PdfPassword | undefined, trackChanges?: ChangeTrackingModes | undefined) {
1055
1055
  if (pdfInput) {
1056
1056
  this.pdfDocumentId = undefined;
1057
1057
  const input = separatePdfInput(pdfInput);
@@ -1071,14 +1071,14 @@ export class PdfDocument{
1071
1071
  case "buffer":
1072
1072
  this.promiseDocumentId = openPdfFileBuffer(
1073
1073
  input.buffer,
1074
- password
1074
+ {userPassword: password?.userPassword, ownerPassword: password?.ownerPassword, trackChanges: trackChanges}
1075
1075
  );
1076
1076
  break;
1077
1077
  case "pdfFile":
1078
1078
  this.pdfPassword = password;
1079
1079
  this.promiseDocumentId = openPdfFileBuffer(
1080
1080
  fs.readFileSync(input.pdfFile),
1081
- password
1081
+ {userPassword: password?.userPassword, ownerPassword: password?.ownerPassword, trackChanges: trackChanges}
1082
1082
  );
1083
1083
  break;
1084
1084
  case "url":
@@ -1136,34 +1136,34 @@ export class PdfDocument{
1136
1136
  * required for open a private PDF file
1137
1137
  * @default undefined
1138
1138
  */
1139
- password?: PdfPassword;
1139
+ password?: PdfPassword | undefined;
1140
1140
  /**
1141
1141
  * Apply renderOptions if PdfInput is a {@link HtmlString} or {@link HtmlFilePath} or {@link ZipFilePath} or {@link Url}}
1142
1142
  * @default undefined
1143
1143
  */
1144
- renderOptions?: ChromePdfRenderOptions;
1144
+ renderOptions?: ChromePdfRenderOptions | undefined;
1145
1145
  /**
1146
1146
  * Apply httpLoginCredentials if PdfInput is a {@link HtmlString} or {@link HtmlFilePath} or {@link ZipFilePath} or {@link Url}}
1147
1147
  * @default undefined
1148
1148
  */
1149
- httpLoginCredentials?: HttpLoginCredentials;
1149
+ httpLoginCredentials?: HttpLoginCredentials | undefined;
1150
1150
  /**
1151
1151
  * Apply mainHtmlFile if PdfInput is {@link ZipFilePath}
1152
1152
  * @default index.html
1153
1153
  */
1154
- mainHtmlFile?: string;
1154
+ mainHtmlFile?: string | undefined;
1155
1155
  /**
1156
1156
  * Optionally track changes to the document (for use with incremental saves)
1157
1157
  * @default {@link ChangeTrackingModes.AutoChangeTracking}
1158
1158
  */
1159
- trackChanges?: ChangeTrackingModes;
1159
+ trackChanges?: ChangeTrackingModes | undefined;
1160
1160
  // /**
1161
1161
  // * Apply baseUrl if
1162
1162
  // * The HTML base URL for which references to external CSS, Javascript and Image files will be relative.
1163
1163
  // * @default undefined
1164
1164
  // */
1165
- // baseUrl?: string; //not supported
1166
- }
1165
+ // baseUrl ?: string | undefined; //not supported
1166
+ } | undefined
1167
1167
  ): Promise<PdfDocument> {
1168
1168
  if (pdfInput) {
1169
1169
  const input = separatePdfInput(pdfInput);
@@ -1242,7 +1242,8 @@ export class PdfDocument{
1242
1242
  * @param Optionally track changes to the document (for use with incremental saves)
1243
1243
  */
1244
1244
  private static async internal_fromFile(
1245
- pdfFilePath: string, trackChanges?: ChangeTrackingModes
1245
+ pdfFilePath: string,
1246
+ trackChanges?: ChangeTrackingModes | undefined
1246
1247
  ): Promise<PdfDocument> {
1247
1248
  return this.internal_open(pdfFilePath, {trackChanges: trackChanges});
1248
1249
  }
@@ -1259,8 +1260,8 @@ export class PdfDocument{
1259
1260
  * Apply renderOptions if PdfInput is a {@link HtmlString} or {@link HtmlFilePath} or {@link ZipFilePath} or {@link Url}}
1260
1261
  * @default undefined
1261
1262
  */
1262
- renderOptions?: ChromePdfRenderOptions;
1263
- }
1263
+ renderOptions?: ChromePdfRenderOptions | undefined;
1264
+ } | undefined
1264
1265
  ): Promise<PdfDocument> {
1265
1266
  return this.internal_open(url, options);
1266
1267
  }
@@ -1286,12 +1287,12 @@ export class PdfDocument{
1286
1287
  * Apply renderOptions if PdfInput is a {@link HtmlString} or {@link HtmlFilePath} or {@link ZipFilePath} or {@link Url}}
1287
1288
  * @default undefined
1288
1289
  */
1289
- renderOptions?: ChromePdfRenderOptions;
1290
+ renderOptions?: ChromePdfRenderOptions | undefined;
1290
1291
  /**
1291
1292
  * a main .html file default: `index.html`
1292
1293
  */
1293
- mainHtmlFile?: string;
1294
- }
1294
+ mainHtmlFile?: string | undefined;
1295
+ } | undefined
1295
1296
  ): Promise<PdfDocument> {
1296
1297
  return this.internal_open(zipFilePath, options);
1297
1298
  }
@@ -1308,8 +1309,8 @@ export class PdfDocument{
1308
1309
  * Apply renderOptions if PdfInput is a {@link HtmlString} or {@link HtmlFilePath} or {@link ZipFilePath} or {@link Url}}
1309
1310
  * @default undefined
1310
1311
  */
1311
- renderOptions?: ChromePdfRenderOptions;
1312
- }
1312
+ renderOptions?: ChromePdfRenderOptions | undefined;
1313
+ } | undefined
1313
1314
  ): Promise<PdfDocument> {
1314
1315
  return this.internal_open(htmlStringOrHtmlFilePath, options);
1315
1316
  }
@@ -1328,33 +1329,33 @@ export class PdfDocument{
1328
1329
  * Apply renderOptions if PdfInput is a {@link HtmlString} or {@link HtmlFilePath} or {@link ZipFilePath} or {@link Url}}
1329
1330
  * @default undefined
1330
1331
  */
1331
- imageToPdfOptions?: ImageToPdfOptions;
1332
- }
1332
+ imageToPdfOptions?: ImageToPdfOptions | undefined;
1333
+ } | undefined
1333
1334
  ): Promise<PdfDocument> {
1334
1335
  let temp: Promise<string>;
1335
1336
 
1336
1337
  if (Array.isArray(images)) {
1337
1338
  // const imageArray = images as Array<any>;
1338
- if (images.length == 0) {
1339
+ if(images[0]){
1340
+ const t = separateImageBufferOrImagePathInput(images[0]);
1341
+
1342
+ switch (t.type) {
1343
+ case "imageBuffer":
1344
+ temp = renderImagesBufferToPdf(
1345
+ images as Buffer[],
1346
+ options?.imageToPdfOptions
1347
+ );
1348
+ break;
1349
+ case "imageFilePath":
1350
+ temp = renderImagesFilesToPdf(
1351
+ images as string[],
1352
+ options?.imageToPdfOptions
1353
+ );
1354
+ break;
1355
+ }
1356
+ }else{
1339
1357
  throw new Error("imageToPdf input Array is Empty");
1340
1358
  }
1341
-
1342
- const t = separateImageBufferOrImagePathInput(images[0]);
1343
-
1344
- switch (t.type) {
1345
- case "imageBuffer":
1346
- temp = renderImagesBufferToPdf(
1347
- images as Buffer[],
1348
- options?.imageToPdfOptions
1349
- );
1350
- break;
1351
- case "imageFilePath":
1352
- temp = renderImagesFilesToPdf(
1353
- images as string[],
1354
- options?.imageToPdfOptions
1355
- );
1356
- break;
1357
- }
1358
1359
  } else {
1359
1360
  const image = separateImageBufferOrImagePathInput(images);
1360
1361
  switch (image.type) {
@@ -1402,7 +1403,7 @@ export class PdfDocument{
1402
1403
  * @param filePath Target file path
1403
1404
  * @param saveOptions see {@link SaveOptions}
1404
1405
  */
1405
- private async internal_saveAs(filePath: string, saveOptions?: SaveOptions): Promise<void> {
1406
+ private async internal_saveAs(filePath: string, saveOptions?: SaveOptions | undefined): Promise<void> {
1406
1407
  return this.internal_saveAsBuffer(saveOptions).then((pdfFileBuffer) => {
1407
1408
  fs.writeFile(filePath, pdfFileBuffer, "binary", (err) => {
1408
1409
  if (err) throw err;
@@ -1414,7 +1415,7 @@ export class PdfDocument{
1414
1415
  * Saves the PdfDocument to a binary (Buffer)
1415
1416
  * @param saveOptions see {@link SaveOptions}
1416
1417
  */
1417
- private async internal_saveAsBuffer(saveOptions?: SaveOptions): Promise<Buffer> {
1418
+ private async internal_saveAsBuffer(saveOptions?: SaveOptions | undefined): Promise<Buffer> {
1418
1419
  return getBinaryData(await this.internal_getId(), saveOptions);
1419
1420
  }
1420
1421
 
@@ -1478,8 +1479,8 @@ export class PdfDocument{
1478
1479
  /**
1479
1480
  * @default "all"
1480
1481
  */
1481
- pdfPageSelection?: PdfPageSelection;
1482
- }
1482
+ pdfPageSelection?: PdfPageSelection | undefined;
1483
+ } | undefined
1483
1484
  ) {
1484
1485
  return await setPageRotation(await this.internal_getId(), pageRotation, options);
1485
1486
  }
@@ -1495,8 +1496,8 @@ export class PdfDocument{
1495
1496
  /**
1496
1497
  * @default "all"
1497
1498
  */
1498
- pdfPageSelection?: PdfPageSelection;
1499
- }
1499
+ pdfPageSelection?: PdfPageSelection | undefined;
1500
+ } | undefined
1500
1501
  ): Promise<void> {
1501
1502
  return await resizePage(await this.internal_getId(), newSize, options);
1502
1503
  }
@@ -1574,8 +1575,8 @@ export class PdfDocument{
1574
1575
  /**
1575
1576
  * @default "all"
1576
1577
  */
1577
- fromPages?: PdfPageSelection;
1578
- }): Promise<Buffer[]> {
1578
+ fromPages?: PdfPageSelection | undefined;
1579
+ } | undefined): Promise<Buffer[]> {
1579
1580
  return extractRawImages(
1580
1581
  await this.internal_getId(),
1581
1582
  options?.fromPages ?? "all"
@@ -1594,11 +1595,11 @@ export class PdfDocument{
1594
1595
  /**
1595
1596
  * @default "all"
1596
1597
  */
1597
- fromPages?: PdfPageSelection;
1598
+ fromPages?: PdfPageSelection | undefined;
1598
1599
  /**
1599
1600
  * @default {@link ImageType.PNG}
1600
1601
  */
1601
- imageType?: ImageType;
1602
+ imageType?: ImageType | undefined;
1602
1603
  }): Promise<Buffer[]> {
1603
1604
  const images = await rasterizeToImageBuffers(
1604
1605
  await this.internal_getId(),
@@ -1640,29 +1641,24 @@ export class PdfDocument{
1640
1641
  /**
1641
1642
  * @default "all"
1642
1643
  */
1643
- fromPages?: PdfPageSelection;
1644
+ fromPages?: PdfPageSelection | undefined;
1644
1645
  /**
1645
1646
  * @default {@link ImageType.PNG}
1646
1647
  */
1647
- type?: ImageType;
1648
- }
1648
+ type?: ImageType | undefined;
1649
+ } | undefined
1649
1650
  ): Promise<string[]> {
1650
1651
  const images = await rasterizeToImageBuffers(
1651
1652
  await this.internal_getId(),
1652
1653
  options?.fromPages ?? "all"
1653
1654
  );
1654
- const filesName = getFileNames(
1655
- filePath,
1656
- images.length,
1657
- getImageExtType(options?.type),
1658
- "image"
1659
- );
1660
1655
 
1661
1656
  const promises = images.map(async (imageBuffer, index) => {
1662
- await Jimp.read(imageBuffer).then((value) =>
1663
- value.write(filesName[index])
1664
- );
1665
- return filesName[index];
1657
+ const outputFileName = getFileName(filePath,index.toString(),getImageExtType(options?.type),"image");
1658
+ await Jimp.read(imageBuffer).then((value) => {
1659
+ return value.write(outputFileName);
1660
+ });
1661
+ return outputFileName;
1666
1662
  });
1667
1663
 
1668
1664
  return await Promise.all(promises);
@@ -1680,13 +1676,13 @@ export class PdfDocument{
1680
1676
  private async internal_replaceText(
1681
1677
  oldText: string,
1682
1678
  newText: string,
1683
- onPages?: PdfPageSelection
1679
+ onPages?: PdfPageSelection | undefined
1684
1680
  ): Promise<void> {
1685
1681
  return replaceText(await this.internal_getId(), oldText, newText, onPages);
1686
1682
  }
1687
1683
 
1688
1684
  private async internal_extractText(
1689
- onPages?: PdfPageSelection
1685
+ onPages?: PdfPageSelection | undefined
1690
1686
  ): Promise<string> {
1691
1687
  return extractAllText(await this.internal_getId(), onPages);
1692
1688
  }
@@ -1698,7 +1694,7 @@ export class PdfDocument{
1698
1694
  * Convert the current document into the specified PDF-A standard format
1699
1695
  * @param customICC (Optional) Custom color profile file path
1700
1696
  */
1701
- private async internal_convertToPdfA(customICC?: string): Promise<void> {
1697
+ private async internal_convertToPdfA(customICC?: string | undefined): Promise<void> {
1702
1698
  return await toPdfA(await this.internal_getId(), customICC);
1703
1699
  }
1704
1700
 
@@ -1790,7 +1786,7 @@ export class PdfDocument{
1790
1786
  */
1791
1787
  private async internal_addTextHeader(
1792
1788
  header: TextAffix,
1793
- toPages?: PdfPageSelection
1789
+ toPages?: PdfPageSelection | undefined
1794
1790
  ): Promise<void> {
1795
1791
  await addTextAffix(await this.internal_getId(), toPages, header, true);
1796
1792
  }
@@ -1802,7 +1798,7 @@ export class PdfDocument{
1802
1798
  */
1803
1799
  private async internal_addTextFooter(
1804
1800
  footer: TextAffix,
1805
- toPages?: PdfPageSelection
1801
+ toPages?: PdfPageSelection | undefined
1806
1802
  ): Promise<void> {
1807
1803
  await addTextAffix(await this.internal_getId(), toPages, footer, false);
1808
1804
  }
@@ -1814,7 +1810,7 @@ export class PdfDocument{
1814
1810
  */
1815
1811
  private async internal_addHtmlHeader(
1816
1812
  header: HtmlAffix,
1817
- toPages?: PdfPageSelection
1813
+ toPages?: PdfPageSelection | undefined
1818
1814
  ): Promise<void> {
1819
1815
  await addHtmlAffix(await this.internal_getId(), toPages, header, true);
1820
1816
  }
@@ -1826,7 +1822,7 @@ export class PdfDocument{
1826
1822
  */
1827
1823
  private async internal_addHtmlFooter(
1828
1824
  footer: HtmlAffix,
1829
- toPages?: PdfPageSelection
1825
+ toPages?: PdfPageSelection | undefined
1830
1826
  ): Promise<void> {
1831
1827
  await addHtmlAffix(await this.internal_getId(), toPages, footer, false);
1832
1828
  }
@@ -1842,9 +1838,9 @@ export class PdfDocument{
1842
1838
  private async internal_stampHtml(
1843
1839
  htmlStringOrHtmlFilePath: HtmlFilePath | HtmlString,
1844
1840
  options?: {
1845
- htmlStampOptions?: HtmlStampOptions;
1846
- toPages?: PdfPageSelection;
1847
- }
1841
+ htmlStampOptions?: HtmlStampOptions | undefined;
1842
+ toPages?: PdfPageSelection | undefined;
1843
+ } | undefined
1848
1844
  ) {
1849
1845
  const html =
1850
1846
  htmlStringOrHtmlFilePath.endsWith(".html") ||
@@ -1867,9 +1863,9 @@ export class PdfDocument{
1867
1863
  private async internal_stampImage(
1868
1864
  image: ImageFilePath | ImageBuffer,
1869
1865
  options?: {
1870
- imageStampOptions?: ImageStampOptions;
1871
- toPages?: PdfPageSelection;
1872
- }
1866
+ imageStampOptions?: ImageStampOptions | undefined;
1867
+ toPages?: PdfPageSelection | undefined;
1868
+ } | undefined
1873
1869
  ) {
1874
1870
  const imageBuffer =
1875
1871
  image instanceof Buffer ? image : fs.readFileSync(image);
@@ -1889,9 +1885,9 @@ export class PdfDocument{
1889
1885
  private async internal_stampText(
1890
1886
  text: string,
1891
1887
  options?: {
1892
- textStampOptions?: TextStampOptions;
1893
- toPages?: PdfPageSelection;
1894
- }
1888
+ textStampOptions?: TextStampOptions | undefined;
1889
+ toPages?: PdfPageSelection | undefined;
1890
+ } | undefined
1895
1891
  ) {
1896
1892
  await stampText(await this.internal_getId(), text, {
1897
1893
  password: this.pdfPassword,
@@ -1909,9 +1905,9 @@ export class PdfDocument{
1909
1905
  barcodeValue: string,
1910
1906
  options?: {
1911
1907
  barcodeEncoding: BarcodeType;
1912
- barcodeStampOptions?: BarcodeStampOptions;
1913
- toPages?: PdfPageSelection;
1914
- }
1908
+ barcodeStampOptions?: BarcodeStampOptions | undefined;
1909
+ toPages?: PdfPageSelection | undefined;
1910
+ } | undefined
1915
1911
  ) {
1916
1912
  await stampBarcode(
1917
1913
  await this.internal_getId(),
@@ -1938,7 +1934,7 @@ export class PdfDocument{
1938
1934
  private async internal_addBackgroundFromAnotherPdf(
1939
1935
  fromPdf: PdfDocument,
1940
1936
  sourcePageIndex = 0,
1941
- applyToPages?: PdfPageSelection
1937
+ applyToPages?: PdfPageSelection | undefined
1942
1938
  ): Promise<void> {
1943
1939
  return await addBackgroundForeground(
1944
1940
  await this.internal_getId(),
@@ -1960,7 +1956,7 @@ export class PdfDocument{
1960
1956
  private async internal_addForegroundFromAnotherPdf(
1961
1957
  fromPdf: PdfDocument,
1962
1958
  sourcePageIndex = 0,
1963
- applyToPages?: PdfPageSelection
1959
+ applyToPages?: PdfPageSelection | undefined
1964
1960
  ): Promise<void> {
1965
1961
  return await addBackgroundForeground(
1966
1962
  await this.internal_getId(),