@libpdf/core 0.0.1-beta.12 → 0.0.1-beta.13
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 +146 -23
- package/dist/index.mjs +444 -146
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -2696,6 +2696,40 @@ declare class EmbeddedFont extends PdfFont {
|
|
|
2696
2696
|
* type any character at runtime).
|
|
2697
2697
|
*/
|
|
2698
2698
|
canSubset(): boolean;
|
|
2699
|
+
/**
|
|
2700
|
+
* Get width of text in points at a given font size.
|
|
2701
|
+
*
|
|
2702
|
+
* Alias for getTextWidth() to match Standard14Font API.
|
|
2703
|
+
*
|
|
2704
|
+
* @param text - The text to measure
|
|
2705
|
+
* @param size - Font size in points
|
|
2706
|
+
* @returns Width in points
|
|
2707
|
+
*/
|
|
2708
|
+
widthOfTextAtSize(text: string, size: number): number;
|
|
2709
|
+
/**
|
|
2710
|
+
* Get the height of the font at a given size.
|
|
2711
|
+
*
|
|
2712
|
+
* This returns the full height from descender to ascender.
|
|
2713
|
+
*
|
|
2714
|
+
* @param size - Font size in points
|
|
2715
|
+
* @returns Height in points
|
|
2716
|
+
*/
|
|
2717
|
+
heightAtSize(size: number): number;
|
|
2718
|
+
/**
|
|
2719
|
+
* Calculate font size needed to achieve a specific text height.
|
|
2720
|
+
*
|
|
2721
|
+
* @param height - Desired height in points
|
|
2722
|
+
* @returns Font size in points
|
|
2723
|
+
*/
|
|
2724
|
+
sizeAtHeight(height: number): number;
|
|
2725
|
+
/**
|
|
2726
|
+
* Calculate font size needed for text to fit a specific width.
|
|
2727
|
+
*
|
|
2728
|
+
* @param text - The text to measure
|
|
2729
|
+
* @param width - Desired width in points
|
|
2730
|
+
* @returns Font size in points
|
|
2731
|
+
*/
|
|
2732
|
+
sizeAtWidth(text: string, width: number): number;
|
|
2699
2733
|
/**
|
|
2700
2734
|
* Build a FontDescriptor from the font program.
|
|
2701
2735
|
*/
|
|
@@ -3753,17 +3787,30 @@ type LineCap = "butt" | "round" | "square";
|
|
|
3753
3787
|
* - "bevel": Beveled corner (2)
|
|
3754
3788
|
*/
|
|
3755
3789
|
type LineJoin = "miter" | "round" | "bevel";
|
|
3790
|
+
/**
|
|
3791
|
+
* Named rotation origin positions.
|
|
3792
|
+
* These are relative to the bounding box of the object being rotated.
|
|
3793
|
+
*/
|
|
3794
|
+
type RotationOriginName = "top-left" | "top-center" | "top-right" | "center-left" | "center" | "center-right" | "bottom-left" | "bottom-center" | "bottom-right";
|
|
3795
|
+
/**
|
|
3796
|
+
* Rotation origin - either explicit coordinates or a named position.
|
|
3797
|
+
*/
|
|
3798
|
+
type RotationOrigin = {
|
|
3799
|
+
x: number;
|
|
3800
|
+
y: number;
|
|
3801
|
+
} | RotationOriginName;
|
|
3756
3802
|
/**
|
|
3757
3803
|
* Rotation specification.
|
|
3758
3804
|
*/
|
|
3759
3805
|
interface Rotation {
|
|
3760
3806
|
/** Rotation angle in degrees (counter-clockwise) */
|
|
3761
3807
|
angle: number;
|
|
3762
|
-
/**
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3808
|
+
/**
|
|
3809
|
+
* Rotation center point.
|
|
3810
|
+
* Can be explicit coordinates `{ x, y }` or a named position like "center", "top-left", etc.
|
|
3811
|
+
* Default varies by object type (usually center for shapes, bottom-left for text).
|
|
3812
|
+
*/
|
|
3813
|
+
origin?: RotationOrigin;
|
|
3767
3814
|
}
|
|
3768
3815
|
/**
|
|
3769
3816
|
* Font type - either a Standard 14 font name or an embedded font.
|
|
@@ -8727,35 +8774,50 @@ declare class GoogleKmsSigner implements Signer {
|
|
|
8727
8774
|
*/
|
|
8728
8775
|
static create(options: GoogleKmsSignerOptions): Promise<GoogleKmsSigner>;
|
|
8729
8776
|
/**
|
|
8730
|
-
*
|
|
8777
|
+
* Loads a signing certificate from Google Secret Manager for use with KMS-based signing.
|
|
8778
|
+
*
|
|
8779
|
+
* This helper retrieves certificate material securely stored in Secret Manager, supporting
|
|
8780
|
+
* both PEM and DER formats:
|
|
8781
|
+
* - If the secret contains PEM-encoded data, all certificates will be parsed.
|
|
8782
|
+
* The first is used as the signing cert (`cert`), and the remainder returned as
|
|
8783
|
+
* the optional `chain` (intermediates).
|
|
8784
|
+
* - If the secret contains raw DER data, it is returned as the signing cert (`cert`).
|
|
8731
8785
|
*
|
|
8732
|
-
*
|
|
8733
|
-
* convert to DER before storing in Secret Manager.
|
|
8786
|
+
* Supports cross-project use: the secret may be in a different GCP project than the KMS key.
|
|
8734
8787
|
*
|
|
8735
|
-
*
|
|
8736
|
-
*
|
|
8788
|
+
* - The secret should contain the certificate in binary DER (recommended) or PEM format.
|
|
8789
|
+
* - Private keys must never be stored in Secret Manager.
|
|
8737
8790
|
*
|
|
8738
|
-
* @param secretVersionName
|
|
8739
|
-
* "projects/my-project/secrets/my-cert/versions/latest"
|
|
8740
|
-
* @param options
|
|
8741
|
-
* @
|
|
8791
|
+
* @param secretVersionName Full resource name for the secret version,
|
|
8792
|
+
* e.g. "projects/my-project/secrets/my-cert/versions/latest"
|
|
8793
|
+
* @param options Optional client configuration, including a SecretManagerServiceClient instance.
|
|
8794
|
+
* @returns An object with `cert` (main certificate bytes) and optional `chain` (intermediates).
|
|
8795
|
+
* @throws {KmsSignerError} if @google-cloud/secret-manager is not installed or retrieval fails.
|
|
8742
8796
|
*
|
|
8743
8797
|
* @example
|
|
8744
|
-
*
|
|
8745
|
-
*
|
|
8746
|
-
* const cert = await GoogleKmsSigner.getCertificateFromSecretManager(
|
|
8798
|
+
* // Load a certificate from the same project
|
|
8799
|
+
* const { cert } = await GoogleKmsSigner.getCertificateFromSecretManager(
|
|
8747
8800
|
* "projects/my-project/secrets/signing-cert/versions/latest"
|
|
8748
8801
|
* );
|
|
8749
8802
|
*
|
|
8750
|
-
* //
|
|
8751
|
-
* const cert = await GoogleKmsSigner.getCertificateFromSecretManager(
|
|
8752
|
-
* "projects/shared-certs-project/secrets/
|
|
8803
|
+
* // Load from a different project (cross-project access)
|
|
8804
|
+
* const { cert, chain } = await GoogleKmsSigner.getCertificateFromSecretManager(
|
|
8805
|
+
* "projects/shared-certs-project/secrets/org-ca-cert/versions/1"
|
|
8753
8806
|
* );
|
|
8754
|
-
*
|
|
8807
|
+
*
|
|
8808
|
+
* // Use the result with KMS-based signing
|
|
8809
|
+
* const signer = await GoogleKmsSigner.create({
|
|
8810
|
+
* keyVersionName: "...",
|
|
8811
|
+
* certificate: cert,
|
|
8812
|
+
* chain,
|
|
8813
|
+
* });
|
|
8755
8814
|
*/
|
|
8756
8815
|
static getCertificateFromSecretManager(secretVersionName: string, options?: {
|
|
8757
8816
|
client?: SecretManagerServiceClient;
|
|
8758
|
-
}): Promise<
|
|
8817
|
+
}): Promise<{
|
|
8818
|
+
cert: Uint8Array;
|
|
8819
|
+
chain?: Uint8Array[];
|
|
8820
|
+
}>;
|
|
8759
8821
|
/**
|
|
8760
8822
|
* Sign data using the KMS key.
|
|
8761
8823
|
*
|
|
@@ -8968,6 +9030,67 @@ declare class HttpTimestampAuthority implements TimestampAuthority {
|
|
|
8968
9030
|
private parseTimestampResponse;
|
|
8969
9031
|
}
|
|
8970
9032
|
//#endregion
|
|
9033
|
+
//#region src/fonts/standard-14-font.d.ts
|
|
9034
|
+
/**
|
|
9035
|
+
* A wrapper class for Standard 14 fonts that provides measurement methods.
|
|
9036
|
+
*
|
|
9037
|
+
* Standard 14 fonts don't need to be embedded - they're built into PDF readers.
|
|
9038
|
+
* This class provides the same measurement API as EmbeddedFont.
|
|
9039
|
+
*/
|
|
9040
|
+
declare class Standard14Font {
|
|
9041
|
+
/** The Standard 14 font name */
|
|
9042
|
+
readonly name: Standard14FontName;
|
|
9043
|
+
/** Cached metrics */
|
|
9044
|
+
private readonly metrics;
|
|
9045
|
+
private constructor();
|
|
9046
|
+
/**
|
|
9047
|
+
* Create a Standard14Font instance.
|
|
9048
|
+
*
|
|
9049
|
+
* @param name - The Standard 14 font name (e.g., "Helvetica", "Times-Bold")
|
|
9050
|
+
* @returns Standard14Font instance
|
|
9051
|
+
* @throws {Error} if name is not a valid Standard 14 font
|
|
9052
|
+
*
|
|
9053
|
+
* @example
|
|
9054
|
+
* ```typescript
|
|
9055
|
+
* const helvetica = Standard14Font.of("Helvetica");
|
|
9056
|
+
* const timesBold = Standard14Font.of("Times-Bold");
|
|
9057
|
+
* ```
|
|
9058
|
+
*/
|
|
9059
|
+
static of(name: Standard14FontName): Standard14Font;
|
|
9060
|
+
/**
|
|
9061
|
+
* Get width of text in points at a given font size.
|
|
9062
|
+
*
|
|
9063
|
+
* @param text - The text to measure
|
|
9064
|
+
* @param size - Font size in points
|
|
9065
|
+
* @returns Width in points
|
|
9066
|
+
*/
|
|
9067
|
+
widthOfTextAtSize(text: string, size: number): number;
|
|
9068
|
+
/**
|
|
9069
|
+
* Get the height of the font at a given size.
|
|
9070
|
+
*
|
|
9071
|
+
* This returns the full height from descender to ascender.
|
|
9072
|
+
*
|
|
9073
|
+
* @param size - Font size in points
|
|
9074
|
+
* @returns Height in points
|
|
9075
|
+
*/
|
|
9076
|
+
heightAtSize(size: number): number;
|
|
9077
|
+
/**
|
|
9078
|
+
* Calculate font size needed to achieve a specific text height.
|
|
9079
|
+
*
|
|
9080
|
+
* @param height - Desired height in points
|
|
9081
|
+
* @returns Font size in points
|
|
9082
|
+
*/
|
|
9083
|
+
sizeAtHeight(height: number): number;
|
|
9084
|
+
/**
|
|
9085
|
+
* Calculate font size needed for text to fit a specific width.
|
|
9086
|
+
*
|
|
9087
|
+
* @param text - The text to measure
|
|
9088
|
+
* @param width - Desired width in points
|
|
9089
|
+
* @returns Font size in points
|
|
9090
|
+
*/
|
|
9091
|
+
sizeAtWidth(text: string, width: number): number;
|
|
9092
|
+
}
|
|
9093
|
+
//#endregion
|
|
8971
9094
|
//#region src/api/drawing/text-layout.d.ts
|
|
8972
9095
|
/**
|
|
8973
9096
|
* A single line of laid out text.
|
|
@@ -9095,5 +9218,5 @@ declare function isWidgetAnnotation(dict: PdfDict): boolean;
|
|
|
9095
9218
|
*/
|
|
9096
9219
|
declare function isPopupAnnotation(dict: PdfDict): boolean;
|
|
9097
9220
|
//#endregion
|
|
9098
|
-
export { AnnotationFlags, type AnnotationSubtype, type AuthenticationResult, type BorderStyle, type BorderStyleType, type ButtonField, type CMYK, type CaretAnnotationOptions, type CaretSymbol, CertificateChainError, type CheckboxField, type CheckboxOptions, type CheckboxSymbol, type CircleAnnotationOptions, type Color, type CopyPagesOptions, CryptoKeySigner, type Degrees, type DestinationType, type DigestAlgorithm, type DocumentMetadata, type DrawCircleOptions, type DrawEllipseOptions, type DrawFieldOptions, type DrawImageOptions, type DrawLineOptions, type DrawPageOptions, type DrawRectangleOptions, type DrawTextOptions, type DropdownField, type DropdownOptions, type EmbedFontOptions, type EmbeddedFont, type EncryptionAlgorithmOption, type ExtractPagesOptions, type FieldOptions, type FieldType, type FieldValue, type FileAttachmentIcon, type FlattenAllOptions, type FlattenAllResult, type FlattenAnnotationsOptions, type FlattenLayersResult, type FlattenOptions, type FontInput, type FormField, type FormProperties, type FreeTextAnnotationOptions, type FreeTextJustification, GoogleKmsSigner, type Grayscale, type HighlightMode, HttpTimestampAuthority, type HttpTimestampAuthorityOptions, type InkAnnotationOptions, type KeyType, KmsSignerError, type LayerInfo, type LayoutResult, type LineAnnotationOptions, type LineCap, type LineEndingStyle, type LineJoin, type LinkAction, type LinkAnnotationOptions, type LinkDestination, type ListBoxField, type ListboxOptions, type LoadOptions, type MergeOptions, P12Signer, type PAdESLevel, PDF, PDFAnnotation, PDFCaretAnnotation, PDFCircleAnnotation, PDFEmbeddedPage, PDFFileAttachmentAnnotation, PDFForm, PDFFreeTextAnnotation, PDFHighlightAnnotation, PDFImage, PDFInkAnnotation, PDFLineAnnotation, PDFLinkAnnotation, PDFMarkupAnnotation, PDFPage, PDFPolygonAnnotation, PDFPolylineAnnotation, PDFPopupAnnotation, PDFSquareAnnotation, PDFSquigglyAnnotation, PDFStampAnnotation, PDFStrikeOutAnnotation, PDFTextAnnotation, PDFTextMarkupAnnotation, PDFUnderlineAnnotation, PDFUnknownAnnotation, PathBuilder, type PathOptions, PdfArray, PdfBool, PdfDict, PdfName, PdfNull, PdfNumber, type PdfObject, PdfRef, PdfStream, PdfString, type PemBlock, PermissionDeniedError, type PermissionOptions, type Permissions, PlaceholderError, type Point, type PolygonAnnotationOptions, type PolylineAnnotationOptions, type PopupOptions, type PositionedWord, type ProtectionOptions, type RGB, type RadioField, type RadioGroupOptions, type RadioSymbol, type Rect, type Rectangle, type RemoveAnnotationsOptions, RevocationError, type RevocationProvider, type Rotation, STANDARD_STAMPS, type SaveOptions, SecurityError, type SecurityInfo, type SetTitleOptions, type SignOptions, type SignResult, type SignWarning, type SignatureAlgorithm, SignatureError, type SignatureField, type SignatureFieldOptions, type Signer, SignerError, type SquareAnnotationOptions, type StampAnnotationOptions, type StampName, type Standard14FontName, StandardFonts, type SubFilter, TextAlignment, type TextAnnotationIcon, type TextAnnotationOptions, type TextAnnotationState, type TextAnnotationStateModel, type TextField, type TextFieldOptions, type TextLine, type TextMarkupAnnotationOptions, type TimestampAuthority, TimestampError, type TrappedStatus, black, blue, cmyk, createAnnotation, degrees, grayscale, green, isPopupAnnotation, isWidgetAnnotation, layoutJustifiedLine, layoutText, lineCapToNumber, lineJoinToNumber, measureText, parsePem, rectToQuadPoints, rectsToQuadPoints, red, rgb, version, white };
|
|
9221
|
+
export { AnnotationFlags, type AnnotationSubtype, type AuthenticationResult, type BorderStyle, type BorderStyleType, type ButtonField, type CMYK, type CaretAnnotationOptions, type CaretSymbol, CertificateChainError, type CheckboxField, type CheckboxOptions, type CheckboxSymbol, type CircleAnnotationOptions, type Color, type CopyPagesOptions, CryptoKeySigner, type Degrees, type DestinationType, type DigestAlgorithm, type DocumentMetadata, type DrawCircleOptions, type DrawEllipseOptions, type DrawFieldOptions, type DrawImageOptions, type DrawLineOptions, type DrawPageOptions, type DrawRectangleOptions, type DrawTextOptions, type DropdownField, type DropdownOptions, type EmbedFontOptions, type EmbeddedFont, type EncryptionAlgorithmOption, type ExtractPagesOptions, type FieldOptions, type FieldType, type FieldValue, type FileAttachmentIcon, type FlattenAllOptions, type FlattenAllResult, type FlattenAnnotationsOptions, type FlattenLayersResult, type FlattenOptions, type FontInput, type FormField, type FormProperties, type FreeTextAnnotationOptions, type FreeTextJustification, GoogleKmsSigner, type Grayscale, type HighlightMode, HttpTimestampAuthority, type HttpTimestampAuthorityOptions, type InkAnnotationOptions, type KeyType, KmsSignerError, type LayerInfo, type LayoutResult, type LineAnnotationOptions, type LineCap, type LineEndingStyle, type LineJoin, type LinkAction, type LinkAnnotationOptions, type LinkDestination, type ListBoxField, type ListboxOptions, type LoadOptions, type MergeOptions, P12Signer, type PAdESLevel, PDF, PDFAnnotation, PDFCaretAnnotation, PDFCircleAnnotation, PDFEmbeddedPage, PDFFileAttachmentAnnotation, PDFForm, PDFFreeTextAnnotation, PDFHighlightAnnotation, PDFImage, PDFInkAnnotation, PDFLineAnnotation, PDFLinkAnnotation, PDFMarkupAnnotation, PDFPage, PDFPolygonAnnotation, PDFPolylineAnnotation, PDFPopupAnnotation, PDFSquareAnnotation, PDFSquigglyAnnotation, PDFStampAnnotation, PDFStrikeOutAnnotation, PDFTextAnnotation, PDFTextMarkupAnnotation, PDFUnderlineAnnotation, PDFUnknownAnnotation, PathBuilder, type PathOptions, PdfArray, PdfBool, PdfDict, PdfName, PdfNull, PdfNumber, type PdfObject, PdfRef, PdfStream, PdfString, type PemBlock, PermissionDeniedError, type PermissionOptions, type Permissions, PlaceholderError, type Point, type PolygonAnnotationOptions, type PolylineAnnotationOptions, type PopupOptions, type PositionedWord, type ProtectionOptions, type RGB, type RadioField, type RadioGroupOptions, type RadioSymbol, type Rect, type Rectangle, type RemoveAnnotationsOptions, RevocationError, type RevocationProvider, type Rotation, type RotationOrigin, type RotationOriginName, STANDARD_STAMPS, type SaveOptions, SecurityError, type SecurityInfo, type SetTitleOptions, type SignOptions, type SignResult, type SignWarning, type SignatureAlgorithm, SignatureError, type SignatureField, type SignatureFieldOptions, type Signer, SignerError, type SquareAnnotationOptions, type StampAnnotationOptions, type StampName, Standard14Font, type Standard14FontName, StandardFonts, type SubFilter, TextAlignment, type TextAnnotationIcon, type TextAnnotationOptions, type TextAnnotationState, type TextAnnotationStateModel, type TextField, type TextFieldOptions, type TextLine, type TextMarkupAnnotationOptions, type TimestampAuthority, TimestampError, type TrappedStatus, black, blue, cmyk, createAnnotation, degrees, grayscale, green, isPopupAnnotation, isWidgetAnnotation, layoutJustifiedLine, layoutText, lineCapToNumber, lineJoinToNumber, measureText, parsePem, rectToQuadPoints, rectsToQuadPoints, red, rgb, version, white };
|
|
9099
9222
|
//# sourceMappingURL=index.d.mts.map
|