@signiphi/page-assembly 0.2.0-beta.8 → 0.2.0-beta.9

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/index.d.mts CHANGED
@@ -187,6 +187,26 @@ declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAtt
187
187
  declare function pdfToImages(pdfBytes: Uint8Array, options?: {
188
188
  hideFormFields?: boolean;
189
189
  }): Promise<PageImage[]>;
190
+ /**
191
+ * Last-resort rebuild for encrypted PDFs whose structure pdf-lib cannot
192
+ * parse even with `ignoreEncryption`: render every page with PDF.js (which
193
+ * has full decryption support) and re-emit them as an image-based PDF.
194
+ *
195
+ * @param pdfBytes - The source PDF as a Uint8Array
196
+ * @returns Promise resolving to rebuilt (unencrypted, image-based) PDF bytes
197
+ */
198
+ declare function rasterizePdfToPdf(pdfBytes: Uint8Array): Promise<Uint8Array>;
199
+ /**
200
+ * Prepares uploaded PDF bytes for the pdf-lib based assembly pipeline.
201
+ * Regular PDFs pass through untouched. Encrypted PDFs (typically
202
+ * permission-restricted documents that open without a password) are
203
+ * decrypted once here so every downstream `PDFDocument.load` — assembly,
204
+ * field extraction — sees a normal document. When structural decryption is
205
+ * impossible the document is rebuilt from rendered pages as a last resort.
206
+ *
207
+ * @throws {PdfPasswordRequiredError} when the PDF needs a real password
208
+ */
209
+ declare function normalizeUploadedPdfBytes(pdfBytes: Uint8Array): Promise<Uint8Array>;
190
210
  /**
191
211
  * Converts an image file to a PDF document with a single page
192
212
  *
@@ -226,6 +246,31 @@ declare function createPdfBlobUrl(pdfBytes: Uint8Array): string;
226
246
  */
227
247
  declare function downloadPdf(pdfBytes: Uint8Array, filename: string): void;
228
248
 
249
+ declare class PdfPasswordRequiredError extends Error {
250
+ code: string;
251
+ recoverable: boolean;
252
+ userMessage: string;
253
+ constructor();
254
+ }
255
+ declare class UnsupportedPdfEncryptionError extends Error {
256
+ constructor(detail: string);
257
+ }
258
+ /**
259
+ * Decrypt an encrypted PDF that opens with an empty user password.
260
+ * Returns re-saved, fully decrypted bytes with `/Encrypt` removed.
261
+ *
262
+ * @throws {PdfPasswordRequiredError} when a non-empty password is required
263
+ * @throws {UnsupportedPdfEncryptionError} for non-standard security handlers
264
+ */
265
+ declare function decryptPdf(pdfBytes: Uint8Array): Promise<Uint8Array>;
266
+ declare function isEncryptedPdfError(error: unknown): boolean;
267
+ /**
268
+ * Ingestion gate: returns the bytes untouched for regular PDFs, and a
269
+ * decrypted re-save for encrypted ones so every downstream `PDFDocument.load`
270
+ * (page assembly, field extraction) sees a normal document.
271
+ */
272
+ declare function normalizePdfEncryption(pdfBytes: Uint8Array): Promise<Uint8Array>;
273
+
229
274
  /**
230
275
  * PDF Field Extraction Utilities
231
276
  * Extract form fields from PDFs with metadata support for preserving field properties
@@ -354,4 +399,4 @@ declare function mapFieldPositionsAfterAssembly<T extends {
354
399
  position: FormFieldPosition;
355
400
  }>(fields: T[], pageMapping: Map<string, number>): T[];
356
401
 
357
- export { type AssembleOptions, Button, type ExtractedField, type FileExtractedFields, type FileInfo, type FormFieldForPdf, type FormFieldPosition, FormFieldType, PageAssembler, type PageAssemblerHandle, type PageAssemblerProps, type PageAssemblerState, type PageImage, type PageInfo, type TrackedFormField, addFormFieldsToPdf, createPdfBlobUrl, downloadPdf, extractFieldsFromPdf, getSigniphiMetadata, imageToPdf, mapFieldPositionsAfterAssembly, pdfToImages, setSigniphiMetadata };
402
+ export { type AssembleOptions, Button, type ExtractedField, type FileExtractedFields, type FileInfo, type FormFieldForPdf, type FormFieldPosition, FormFieldType, PageAssembler, type PageAssemblerHandle, type PageAssemblerProps, type PageAssemblerState, type PageImage, type PageInfo, PdfPasswordRequiredError, type TrackedFormField, UnsupportedPdfEncryptionError, addFormFieldsToPdf, createPdfBlobUrl, decryptPdf, downloadPdf, extractFieldsFromPdf, getSigniphiMetadata, imageToPdf, isEncryptedPdfError, mapFieldPositionsAfterAssembly, normalizePdfEncryption, normalizeUploadedPdfBytes, pdfToImages, rasterizePdfToPdf, setSigniphiMetadata };
package/dist/index.d.ts CHANGED
@@ -187,6 +187,26 @@ declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAtt
187
187
  declare function pdfToImages(pdfBytes: Uint8Array, options?: {
188
188
  hideFormFields?: boolean;
189
189
  }): Promise<PageImage[]>;
190
+ /**
191
+ * Last-resort rebuild for encrypted PDFs whose structure pdf-lib cannot
192
+ * parse even with `ignoreEncryption`: render every page with PDF.js (which
193
+ * has full decryption support) and re-emit them as an image-based PDF.
194
+ *
195
+ * @param pdfBytes - The source PDF as a Uint8Array
196
+ * @returns Promise resolving to rebuilt (unencrypted, image-based) PDF bytes
197
+ */
198
+ declare function rasterizePdfToPdf(pdfBytes: Uint8Array): Promise<Uint8Array>;
199
+ /**
200
+ * Prepares uploaded PDF bytes for the pdf-lib based assembly pipeline.
201
+ * Regular PDFs pass through untouched. Encrypted PDFs (typically
202
+ * permission-restricted documents that open without a password) are
203
+ * decrypted once here so every downstream `PDFDocument.load` — assembly,
204
+ * field extraction — sees a normal document. When structural decryption is
205
+ * impossible the document is rebuilt from rendered pages as a last resort.
206
+ *
207
+ * @throws {PdfPasswordRequiredError} when the PDF needs a real password
208
+ */
209
+ declare function normalizeUploadedPdfBytes(pdfBytes: Uint8Array): Promise<Uint8Array>;
190
210
  /**
191
211
  * Converts an image file to a PDF document with a single page
192
212
  *
@@ -226,6 +246,31 @@ declare function createPdfBlobUrl(pdfBytes: Uint8Array): string;
226
246
  */
227
247
  declare function downloadPdf(pdfBytes: Uint8Array, filename: string): void;
228
248
 
249
+ declare class PdfPasswordRequiredError extends Error {
250
+ code: string;
251
+ recoverable: boolean;
252
+ userMessage: string;
253
+ constructor();
254
+ }
255
+ declare class UnsupportedPdfEncryptionError extends Error {
256
+ constructor(detail: string);
257
+ }
258
+ /**
259
+ * Decrypt an encrypted PDF that opens with an empty user password.
260
+ * Returns re-saved, fully decrypted bytes with `/Encrypt` removed.
261
+ *
262
+ * @throws {PdfPasswordRequiredError} when a non-empty password is required
263
+ * @throws {UnsupportedPdfEncryptionError} for non-standard security handlers
264
+ */
265
+ declare function decryptPdf(pdfBytes: Uint8Array): Promise<Uint8Array>;
266
+ declare function isEncryptedPdfError(error: unknown): boolean;
267
+ /**
268
+ * Ingestion gate: returns the bytes untouched for regular PDFs, and a
269
+ * decrypted re-save for encrypted ones so every downstream `PDFDocument.load`
270
+ * (page assembly, field extraction) sees a normal document.
271
+ */
272
+ declare function normalizePdfEncryption(pdfBytes: Uint8Array): Promise<Uint8Array>;
273
+
229
274
  /**
230
275
  * PDF Field Extraction Utilities
231
276
  * Extract form fields from PDFs with metadata support for preserving field properties
@@ -354,4 +399,4 @@ declare function mapFieldPositionsAfterAssembly<T extends {
354
399
  position: FormFieldPosition;
355
400
  }>(fields: T[], pageMapping: Map<string, number>): T[];
356
401
 
357
- export { type AssembleOptions, Button, type ExtractedField, type FileExtractedFields, type FileInfo, type FormFieldForPdf, type FormFieldPosition, FormFieldType, PageAssembler, type PageAssemblerHandle, type PageAssemblerProps, type PageAssemblerState, type PageImage, type PageInfo, type TrackedFormField, addFormFieldsToPdf, createPdfBlobUrl, downloadPdf, extractFieldsFromPdf, getSigniphiMetadata, imageToPdf, mapFieldPositionsAfterAssembly, pdfToImages, setSigniphiMetadata };
402
+ export { type AssembleOptions, Button, type ExtractedField, type FileExtractedFields, type FileInfo, type FormFieldForPdf, type FormFieldPosition, FormFieldType, PageAssembler, type PageAssemblerHandle, type PageAssemblerProps, type PageAssemblerState, type PageImage, type PageInfo, PdfPasswordRequiredError, type TrackedFormField, UnsupportedPdfEncryptionError, addFormFieldsToPdf, createPdfBlobUrl, decryptPdf, downloadPdf, extractFieldsFromPdf, getSigniphiMetadata, imageToPdf, isEncryptedPdfError, mapFieldPositionsAfterAssembly, normalizePdfEncryption, normalizeUploadedPdfBytes, pdfToImages, rasterizePdfToPdf, setSigniphiMetadata };