fix(readme): Update readme documentation: enhance feature summary, update installation instructions and usage examples, remove obsolete config details, and better clarify supported invoice formats.
This commit is contained in:
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@fin.cx/xinvoice',
|
||||
version: '4.1.1',
|
||||
version: '4.1.2',
|
||||
description: 'A TypeScript module for creating, manipulating, and embedding XML data within PDF files specifically tailored for xinvoice packages.'
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { PDFDocument, PDFDict, PDFName, PDFRawStream, PDFArray, PDFString } from 'pdf-lib';
|
||||
import * as pako from 'pako';
|
||||
import { PDFDocument, PDFDict, PDFName, PDFRawStream, PDFArray, PDFString, pako } from '../../../plugins.js';
|
||||
|
||||
/**
|
||||
* Base class for PDF XML extractors with common functionality
|
||||
@ -149,7 +148,7 @@ export abstract class BaseXMLExtractor {
|
||||
try {
|
||||
const decompressedBytes = pako.inflate(compressedBytes);
|
||||
const xmlContent = new TextDecoder('utf-8').decode(decompressedBytes);
|
||||
|
||||
|
||||
if (this.isValidXml(xmlContent)) {
|
||||
console.log(`Successfully extracted decompressed XML from PDF file. File name: ${fileName}`);
|
||||
return xmlContent;
|
||||
@ -158,16 +157,16 @@ export abstract class BaseXMLExtractor {
|
||||
// Decompression failed, try without decompression
|
||||
console.log(`Decompression failed for ${fileName}, trying without decompression...`);
|
||||
}
|
||||
|
||||
|
||||
// Try without decompression
|
||||
const rawBytes = stream.getContents();
|
||||
const rawContent = new TextDecoder('utf-8').decode(rawBytes);
|
||||
|
||||
|
||||
if (this.isValidXml(rawContent)) {
|
||||
console.log(`Successfully extracted uncompressed XML from PDF file. File name: ${fileName}`);
|
||||
return rawContent;
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
} catch (error) {
|
||||
console.error('Error extracting XML from stream:', error);
|
||||
|
51
ts/plugins.ts
Normal file
51
ts/plugins.ts
Normal file
@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Centralized imports for all external npm modules
|
||||
* This file serves as a single point of import for all external dependencies
|
||||
* to make the codebase more maintainable and follow the DRY principle.
|
||||
*/
|
||||
|
||||
// PDF-related imports
|
||||
import {
|
||||
PDFDocument,
|
||||
PDFDict,
|
||||
PDFName,
|
||||
PDFRawStream,
|
||||
PDFArray,
|
||||
PDFString,
|
||||
AFRelationship
|
||||
} from 'pdf-lib';
|
||||
|
||||
// XML-related imports
|
||||
import { DOMParser, XMLSerializer } from 'xmldom';
|
||||
import * as xpath from 'xpath';
|
||||
|
||||
// Compression-related imports
|
||||
import * as pako from 'pako';
|
||||
|
||||
// Business model imports
|
||||
import { business, finance, general } from '@tsclass/tsclass';
|
||||
|
||||
// Re-export all imports
|
||||
export {
|
||||
// PDF-lib exports
|
||||
PDFDocument,
|
||||
PDFDict,
|
||||
PDFName,
|
||||
PDFRawStream,
|
||||
PDFArray,
|
||||
PDFString,
|
||||
AFRelationship,
|
||||
|
||||
// XML-related exports
|
||||
DOMParser,
|
||||
XMLSerializer,
|
||||
xpath,
|
||||
|
||||
// Compression-related exports
|
||||
pako,
|
||||
|
||||
// Business model exports
|
||||
business,
|
||||
finance,
|
||||
general
|
||||
};
|
Reference in New Issue
Block a user