@fin.cx/einvoice
Version:
A TypeScript module for creating, manipulating, and embedding XML data within PDF files specifically tailored for electronic invoice (einvoice) packages.
46 lines (45 loc) • 1.66 kB
TypeScript
import { BaseXMLExtractor } from './base.extractor.js';
/**
* Text-based XML extractor for PDF documents
* Extracts XML by searching for XML patterns in the PDF text
* Used as a fallback when other extraction methods fail
*/
export declare class TextXMLExtractor extends BaseXMLExtractor {
private readonly CHUNK_SIZE;
private readonly MAX_CHUNKS;
private readonly XML_PATTERNS;
/**
* Extract XML from a PDF buffer by searching for XML patterns in the text
* Uses a chunked approach to handle large files efficiently
* @param pdfBuffer PDF buffer
* @returns XML content or null if not found
*/
extractXml(pdfBuffer: Uint8Array | Buffer): Promise<string | null>;
/**
* Extract XML from buffer using a chunked approach
* This helps avoid memory issues with large PDFs
* @param buffer Buffer to search in
* @returns XML content or null if not found
*/
private extractXmlFromBufferChunked;
/**
* Process a single chunk of the PDF buffer
* @param chunk Chunk buffer to process
* @param chunkOffset Offset position of the chunk in the original buffer
* @returns XML content or null if not found
*/
private processChunk;
/**
* Safely decode a buffer to string using the specified encoding
* @param buffer Buffer to decode
* @param encoding Encoding to use ('utf-8' or 'latin1')
* @returns Decoded string
*/
private decodeBufferToString;
/**
* Search for XML patterns in a string
* @param content String to search in
* @returns XML content or null if not found
*/
private searchForXmlInString;
}