file2md
Version:
A TypeScript library for converting various document types (PDF, DOCX, XLSX, PPTX, HWP, HWPX) into Markdown with image and layout preservation
190 lines • 4.43 kB
TypeScript
export interface SlideLayout {
slideId: string;
slideNumber: number;
title?: string;
background?: BackgroundInfo;
elements: readonly VisualElement[];
dimensions: SlideDimensions;
}
export interface SlideDimensions {
width: number;
height: number;
units: 'EMU' | 'points' | 'pixels';
}
export interface BackgroundInfo {
type: 'solid' | 'gradient' | 'image' | 'pattern';
color?: string;
colors?: readonly string[];
imagePath?: string;
}
export interface VisualElement {
id: string;
type: 'text' | 'shape' | 'image' | 'chart' | 'table' | 'group';
position: ElementPosition;
size: ElementSize;
content?: unknown;
style?: ElementStyle;
children?: readonly VisualElement[];
}
export interface ElementPosition {
x: number;
y: number;
z: number;
}
export interface ElementSize {
width: number;
height: number;
}
export interface ElementStyle {
fill?: string;
stroke?: string;
strokeWidth?: number;
opacity?: number;
rotation?: number;
font?: FontInfo;
}
export interface FontInfo {
family: string;
size: number;
color: string;
bold: boolean;
italic: boolean;
underline: boolean;
}
export interface TextElement extends VisualElement {
type: 'text';
content: {
text: string;
paragraphs: readonly TextParagraph[];
};
}
export interface TextParagraph {
text: string;
runs: readonly TextRun[];
alignment: 'left' | 'center' | 'right' | 'justify';
level: number;
}
export interface TextRun {
text: string;
font?: FontInfo;
}
export interface ShapeElement extends VisualElement {
type: 'shape';
content: {
shapeType: string;
geometry?: unknown;
};
}
export interface ImageElement extends VisualElement {
type: 'image';
content: {
imagePath: string;
originalSize: ElementSize;
aspectRatio: number;
};
}
export interface ChartElement extends VisualElement {
type: 'chart';
content: {
chartType: string;
data?: unknown;
series?: readonly unknown[];
};
}
export interface TableElement extends VisualElement {
type: 'table';
content: {
rows: readonly TableRow[];
columnWidths: readonly number[];
style?: TableStyle;
};
}
export interface TableRow {
cells: readonly TableCell[];
height?: number;
}
export interface TableCell {
text: string;
colspan?: number;
rowspan?: number;
style?: ElementStyle;
}
export interface TableStyle {
borderStyle?: string;
borderColor?: string;
borderWidth?: number;
headerStyle?: ElementStyle;
}
export declare class PptxVisualParser {
private zip;
private slideCount;
private relationships;
private themes;
/**
* Parse PPTX buffer to extract comprehensive visual information
*/
parseVisualElements(pptxBuffer: Buffer): Promise<readonly SlideLayout[]>;
/**
* Extract slide references from presentation.xml
*/
private extractSlideReferences;
/**
* Load relationships from _rels files
*/
private loadRelationships;
/**
* Load theme information
*/
private loadThemes;
/**
* Parse individual slide
*/
private parseSlide;
/**
* Extract slide dimensions
*/
private extractSlideDimensions;
/**
* Extract slide background information
*/
private extractSlideBackground;
/**
* Extract slide title
*/
private extractSlideTitle;
/**
* Parse all visual elements in a slide
*/
private parseSlideElements;
/**
* Parse a shape element
*/
private parseShape;
/**
* Parse a group element
*/
private parseGroup;
/**
* Parse a picture element
*/
private parsePicture;
/**
* Parse a chart element
*/
private parseChart;
private extractPosition;
private extractSize;
private extractElementStyle;
private extractFontInfo;
private extractTextFromBody;
private extractParagraphsFromBody;
private extractTextFromParagraph;
private extractTextRuns;
private extractAlignment;
private extractShapeType;
private extractShapeGeometry;
private findRelationshipTarget;
private createPlaceholderSlide;
private getXmlContent;
}
//# sourceMappingURL=pptx-visual-parser.d.ts.map