724 lines
16 KiB
TypeScript
724 lines
16 KiB
TypeScript
export interface PDFOperator {
|
|
name: string;
|
|
keyword: string | null;
|
|
description: string;
|
|
numArgs?: number;
|
|
variableArgs?: boolean;
|
|
class: string;
|
|
}
|
|
|
|
export class OperatorList {
|
|
fnArray: [];
|
|
argsArray: [];
|
|
rangeArray: [];
|
|
constructor(fnArray: [], argsArray: [], rangeArray: []) {
|
|
this.fnArray = fnArray;
|
|
this.argsArray = argsArray;
|
|
this.rangeArray = rangeArray;
|
|
}
|
|
|
|
public static formatOperatorToMarkdown(operatorId: keyof typeof opLookup): string {
|
|
const operator = opLookup[operatorId] as PDFOperator;
|
|
if (!operator) {
|
|
return `Unknown operator: ${operatorId}`;
|
|
}
|
|
|
|
const keyword = operator.keyword ? `\`${operator.keyword}\`` : 'N/A';
|
|
const args = operator.numArgs !== undefined ?
|
|
`Arguments: ${operator.numArgs}${operator.variableArgs ? ' (variable)' : ''}` :
|
|
'No arguments';
|
|
|
|
return `**${operator.name}** (${keyword}) ` +
|
|
`${operator.description} ` +
|
|
`${args}`;
|
|
}
|
|
}
|
|
|
|
export const opLookup = {
|
|
'1': {
|
|
name: 'dependency',
|
|
keyword: "Do",
|
|
description: 'Marks a resource dependency',
|
|
numArgs: 0,
|
|
variableArgs: false,
|
|
class: 'operator'
|
|
},
|
|
'2': {
|
|
name: 'setLineWidth',
|
|
keyword: 'w',
|
|
description: 'Sets the line width in the graphics state',
|
|
numArgs: 1,
|
|
variableArgs: false,
|
|
class: 'operator'
|
|
},
|
|
'3': {
|
|
name: 'setLineCap',
|
|
keyword: 'J',
|
|
description: 'Sets the line cap style in the graphics state (0=butt, 1=round, 2=square)',
|
|
numArgs: 1,
|
|
variableArgs: false,
|
|
class: 'operator'
|
|
},
|
|
'4': {
|
|
name: 'setLineJoin',
|
|
keyword: 'j',
|
|
description: 'Sets the line join style in the graphics state (0=miter, 1=round, 2=bevel)',
|
|
numArgs: 1,
|
|
variableArgs: false,
|
|
class: 'operator'
|
|
},
|
|
'5': {
|
|
name: 'setMiterLimit',
|
|
keyword: 'M',
|
|
description: 'Sets the miter limit in the graphics state',
|
|
numArgs: 1,
|
|
variableArgs: false,
|
|
class: 'operator'
|
|
},
|
|
'6': {
|
|
name: 'setDash',
|
|
keyword: 'd',
|
|
description: 'Sets the line dash pattern in the graphics state',
|
|
numArgs: 2,
|
|
variableArgs: false,
|
|
class: 'operator'
|
|
},
|
|
'7': {
|
|
name: 'setRenderingIntent',
|
|
keyword: 'ri',
|
|
description: 'Sets the color rendering intent in the graphics state',
|
|
numArgs: 1,
|
|
variableArgs: false,
|
|
class: 'operator'
|
|
},
|
|
'8': {
|
|
name: 'setFlatness',
|
|
keyword: 'i',
|
|
description: 'Sets the flatness tolerance in the graphics state',
|
|
numArgs: 1,
|
|
variableArgs: false,
|
|
class: 'operator'
|
|
},
|
|
'9': {
|
|
name: 'setGState',
|
|
keyword: 'gs',
|
|
description: 'Sets the specified parameters in the graphics state',
|
|
numArgs: 1,
|
|
variableArgs: false,
|
|
class: 'operator'
|
|
},
|
|
'10': {
|
|
name: 'save',
|
|
keyword: 'q',
|
|
description: 'Pushes a copy of the current graphics state onto the graphics state stack',
|
|
numArgs: 0,
|
|
variableArgs: false,
|
|
class: 'operator'
|
|
},
|
|
'11': {
|
|
name: 'restore',
|
|
keyword: 'Q',
|
|
description: 'Restores the graphics state by popping it from the stack',
|
|
numArgs: 0,
|
|
variableArgs: false,
|
|
class: 'operator'
|
|
},
|
|
'12': {
|
|
name: 'transform',
|
|
keyword: 'cm',
|
|
description: 'Modifies the current transformation matrix (CTM)',
|
|
numArgs: 6,
|
|
variableArgs: false,
|
|
class: 'matrix'
|
|
},
|
|
'13': {
|
|
name: 'moveTo',
|
|
keyword: 'm',
|
|
description: 'Begins a new subpath by moving to coordinates (x, y)',
|
|
numArgs: 2,
|
|
variableArgs: false,
|
|
class: 'path-construct'
|
|
},
|
|
'14': {
|
|
name: 'lineTo',
|
|
keyword: 'l',
|
|
description: 'Adds a straight line segment to the current path',
|
|
numArgs: 2,
|
|
variableArgs: false,
|
|
class: 'path-construct'
|
|
},
|
|
'15': {
|
|
name: 'curveTo',
|
|
keyword: 'c',
|
|
description: 'Adds a Bézier curve segment to the current path using two control points',
|
|
numArgs: 6,
|
|
variableArgs: false,
|
|
class: 'path-construct'
|
|
},
|
|
'16': {
|
|
name: 'curveTo2',
|
|
keyword: 'v',
|
|
description: 'Adds a Bézier curve segment to the current path using one control point',
|
|
numArgs: 4,
|
|
variableArgs: false,
|
|
class: 'path-construct'
|
|
},
|
|
'17': {
|
|
name: 'curveTo3',
|
|
keyword: 'y',
|
|
description: 'Adds a Bézier curve segment to the current path using one control point',
|
|
numArgs: 4,
|
|
variableArgs: false,
|
|
class: 'path-construct'
|
|
},
|
|
'18': {
|
|
name: 'closePath',
|
|
keyword: 'h',
|
|
description: 'Closes the current subpath',
|
|
numArgs: 0,
|
|
variableArgs: false,
|
|
class: 'path-construct'
|
|
},
|
|
'19': {
|
|
name: 'rectangle',
|
|
keyword: 're',
|
|
description: 'Adds a rectangle to the current path',
|
|
numArgs: 4,
|
|
variableArgs: false,
|
|
class: 'path-construct'
|
|
},
|
|
'20': {
|
|
name: 'stroke',
|
|
keyword: 'S',
|
|
description: 'Strokes the current path',
|
|
numArgs: 0,
|
|
variableArgs: false,
|
|
class: 'path-paint'
|
|
},
|
|
'21': {
|
|
name: 'closeStroke',
|
|
keyword: 's',
|
|
description: 'Closes and strokes the current path',
|
|
numArgs: 0,
|
|
variableArgs: false,
|
|
class: 'path-paint'
|
|
},
|
|
'22': {
|
|
name: 'fill',
|
|
keyword: 'f',
|
|
description: 'Fills the current path using nonzero winding number rule',
|
|
numArgs: 0,
|
|
variableArgs: false,
|
|
class: 'path-paint'
|
|
},
|
|
'23': {
|
|
name: 'eoFill',
|
|
keyword: 'f*',
|
|
description: 'Fills the current path using even-odd rule',
|
|
numArgs: 0,
|
|
variableArgs: false,
|
|
class: 'path-paint'
|
|
},
|
|
'24': {
|
|
name: 'fillStroke',
|
|
keyword: 'B',
|
|
description: 'Fills and strokes the current path using nonzero winding number rule',
|
|
numArgs: 0,
|
|
variableArgs: false,
|
|
class: 'path-paint'
|
|
},
|
|
'25': {
|
|
name: 'eoFillStroke',
|
|
keyword: 'B*',
|
|
description: 'Fills and strokes the current path using even-odd rule',
|
|
numArgs: 0,
|
|
variableArgs: false,
|
|
class: 'path-paint'
|
|
},
|
|
'26': {
|
|
name: 'closeFillStroke',
|
|
keyword: 'b',
|
|
description: 'Closes, fills, and strokes the current path using nonzero winding number rule',
|
|
numArgs: 0,
|
|
variableArgs: false,
|
|
class: 'path-paint'
|
|
},
|
|
'27': {
|
|
name: 'closeEOFillStroke',
|
|
keyword: 'b*',
|
|
description: 'Closes, fills, and strokes the current path using even-odd rule',
|
|
numArgs: 0,
|
|
variableArgs: false,
|
|
class: 'path-paint'
|
|
},
|
|
'28': {
|
|
name: 'endPath',
|
|
keyword: 'n',
|
|
description: 'Ends the current path without filling or stroking',
|
|
numArgs: 0,
|
|
variableArgs: false,
|
|
class: 'path-paint'
|
|
},
|
|
'29': {
|
|
name: 'clip',
|
|
keyword: 'W',
|
|
description: 'Sets the current path as the clipping path using nonzero winding number rule',
|
|
numArgs: 0,
|
|
variableArgs: false,
|
|
class: 'path-paint'
|
|
},
|
|
'30': {
|
|
name: 'eoClip',
|
|
keyword: 'W*',
|
|
description: 'Sets the current path as the clipping path using even-odd rule',
|
|
numArgs: 0,
|
|
variableArgs: false,
|
|
class: 'path-paint'
|
|
},
|
|
'31': {
|
|
name: 'beginText',
|
|
keyword: 'BT',
|
|
description: 'Begins a text object',
|
|
numArgs: 0,
|
|
variableArgs: false,
|
|
class: 'text-render'
|
|
},
|
|
'32': {
|
|
name: 'endText',
|
|
keyword: 'ET',
|
|
description: 'Ends a text object',
|
|
numArgs: 0,
|
|
variableArgs: false,
|
|
class: 'text-render'
|
|
},
|
|
'33': {
|
|
name: 'setCharSpacing',
|
|
keyword: 'Tc',
|
|
description: 'Sets the character spacing',
|
|
numArgs: 1,
|
|
variableArgs: false,
|
|
class: 'text-state'
|
|
},
|
|
'34': {
|
|
name: 'setWordSpacing',
|
|
keyword: 'Tw',
|
|
description: 'Sets the word spacing',
|
|
numArgs: 1,
|
|
variableArgs: false,
|
|
class: 'text-state'
|
|
},
|
|
'35': {
|
|
name: 'setHScale',
|
|
keyword: 'Tz',
|
|
description: 'Sets the horizontal scaling',
|
|
numArgs: 1,
|
|
variableArgs: false,
|
|
class: 'text-state'
|
|
},
|
|
'36': {
|
|
name: 'setLeading',
|
|
keyword: 'TL',
|
|
description: 'Sets the text leading',
|
|
numArgs: 1,
|
|
variableArgs: false,
|
|
class: 'text-state'
|
|
},
|
|
'37': {
|
|
name: 'setFont',
|
|
keyword: 'Tf',
|
|
description: 'Sets the text font and size',
|
|
numArgs: 2,
|
|
variableArgs: false,
|
|
class: 'text-state'
|
|
},
|
|
'38': {
|
|
name: 'setTextRenderingMode',
|
|
keyword: 'Tr',
|
|
description: 'Sets the text rendering mode',
|
|
numArgs: 1,
|
|
variableArgs: false,
|
|
class: 'text-state'
|
|
},
|
|
'39': {
|
|
name: 'setTextRise',
|
|
keyword: 'Ts',
|
|
description: 'Sets the text rise',
|
|
numArgs: 1,
|
|
variableArgs: false,
|
|
class: 'text-state'
|
|
},
|
|
'40': {
|
|
name: 'moveText',
|
|
keyword: 'Td',
|
|
description: 'Moves to the start of the next line using offset coordinates',
|
|
numArgs: 2,
|
|
variableArgs: false,
|
|
class: 'text-positioning'
|
|
},
|
|
'41': {
|
|
name: 'setLeadingMoveText',
|
|
keyword: 'TD',
|
|
description: 'Sets the text leading and moves to the next line',
|
|
numArgs: 2,
|
|
variableArgs: false,
|
|
class: 'text-positioning'
|
|
},
|
|
'42': {
|
|
name: 'setTextMatrix',
|
|
keyword: 'Tm',
|
|
description: 'Sets the text matrix and text line matrix',
|
|
numArgs: 6,
|
|
variableArgs: false,
|
|
class: 'matrix'
|
|
},
|
|
'43': {
|
|
name: 'nextLine',
|
|
keyword: 'T*',
|
|
description: 'Moves to the start of the next line',
|
|
numArgs: 0,
|
|
variableArgs: false,
|
|
class: 'text-positioning'
|
|
},
|
|
'44': {
|
|
name: 'showText',
|
|
keyword: 'Tj',
|
|
description: 'Shows a text string',
|
|
numArgs: 1,
|
|
variableArgs: false,
|
|
class: 'text-render'
|
|
},
|
|
'45': {
|
|
name: 'showSpacedText',
|
|
keyword: 'TJ',
|
|
description: 'Shows a text string with individual glyph positioning',
|
|
numArgs: 1,
|
|
variableArgs: false,
|
|
class: 'text-render'
|
|
},
|
|
'46': {
|
|
name: 'nextLineShowText',
|
|
keyword: '\'',
|
|
description: 'Moves to the next line and shows a text string',
|
|
numArgs: 1,
|
|
variableArgs: false,
|
|
class: 'text-render'
|
|
},
|
|
'47': {
|
|
name: 'nextLineSetSpacingShowText',
|
|
keyword: '"',
|
|
description: 'Sets word and character spacing, moves to next line, and shows text',
|
|
numArgs: 3,
|
|
variableArgs: false,
|
|
class: 'text-render'
|
|
},
|
|
'48': {
|
|
name: 'setCharWidth',
|
|
keyword: 'd0',
|
|
description: 'Sets the character width information for Type 3 fonts',
|
|
numArgs: 2,
|
|
variableArgs: false,
|
|
class: 'text-state'
|
|
},
|
|
'49': {
|
|
name: 'setCharWidthAndBounds',
|
|
keyword: 'd1',
|
|
description: 'Sets the character width and bounding box for Type 3 fonts',
|
|
numArgs: 6,
|
|
variableArgs: false,
|
|
class: 'text-state'
|
|
},
|
|
'50': {
|
|
name: 'setStrokeColorSpace',
|
|
keyword: 'CS',
|
|
description: 'Sets the color space for stroking operations',
|
|
numArgs: 1,
|
|
variableArgs: false,
|
|
class: 'color-operator'
|
|
},
|
|
'51': {
|
|
name: 'setFillColorSpace',
|
|
keyword: 'cs',
|
|
description: 'Sets the color space for nonstroking operations',
|
|
numArgs: 1,
|
|
variableArgs: false,
|
|
class: 'color-operator'
|
|
},
|
|
'52': {
|
|
name: 'setStrokeColor',
|
|
keyword: 'SC',
|
|
description: 'Sets the color for stroking operations',
|
|
numArgs: 4,
|
|
variableArgs: true,
|
|
class: 'color-operator'
|
|
},
|
|
'53': {
|
|
name: 'setStrokeColorN',
|
|
keyword: 'SCN',
|
|
description: 'Sets the color for stroking operations (ICCBased and special color spaces)',
|
|
numArgs: 33,
|
|
variableArgs: true,
|
|
class: 'color-operator'
|
|
},
|
|
'54': {
|
|
name: 'setFillColor',
|
|
keyword: 'sc',
|
|
description: 'Sets the color for nonstroking operations',
|
|
numArgs: 4,
|
|
variableArgs: true,
|
|
class: 'color-operator'
|
|
},
|
|
'55': {
|
|
name: 'setFillColorN',
|
|
keyword: 'scn',
|
|
description: 'Sets the color for nonstroking operations (ICCBased and special color spaces)',
|
|
numArgs: 33,
|
|
variableArgs: true,
|
|
class: 'color-operator'
|
|
},
|
|
'56': {
|
|
name: 'setStrokeGray',
|
|
keyword: 'G',
|
|
description: 'Sets the gray level for stroking operations',
|
|
numArgs: 1,
|
|
variableArgs: false,
|
|
class: 'color-operator'
|
|
},
|
|
'57': {
|
|
name: 'setFillGray',
|
|
keyword: 'g',
|
|
description: 'Sets the gray level for nonstroking operations',
|
|
numArgs: 1,
|
|
variableArgs: false,
|
|
class: 'color-operator'
|
|
},
|
|
'58': {
|
|
name: 'setStrokeRGBColor',
|
|
keyword: 'RG',
|
|
description: 'Sets the RGB color for stroking operations',
|
|
numArgs: 3,
|
|
variableArgs: false,
|
|
class: 'color-operator'
|
|
},
|
|
'59': {
|
|
name: 'setFillRGBColor',
|
|
keyword: 'rg',
|
|
description: 'Sets the RGB color for nonstroking operations',
|
|
numArgs: 3,
|
|
variableArgs: false,
|
|
class: 'color-operator'
|
|
},
|
|
'60': {
|
|
name: 'setStrokeCMYKColor',
|
|
keyword: 'K',
|
|
description: 'Sets the CMYK color for stroking operations',
|
|
numArgs: 4,
|
|
variableArgs: false,
|
|
class: 'color-operator'
|
|
},
|
|
'61': {
|
|
name: 'setFillCMYKColor',
|
|
keyword: 'k',
|
|
description: 'Sets the CMYK color for nonstroking operations',
|
|
numArgs: 4,
|
|
variableArgs: false,
|
|
class: 'color-operator'
|
|
},
|
|
'62': {
|
|
name: 'shadingFill',
|
|
keyword: 'sh',
|
|
description: 'Fills the current path using a shading pattern',
|
|
numArgs: 1,
|
|
variableArgs: false,
|
|
class: 'path-paint'
|
|
},
|
|
'63': {
|
|
name: 'beginInlineImage',
|
|
keyword: 'BI',
|
|
description: 'Begins an inline image object',
|
|
numArgs: 0,
|
|
variableArgs: false,
|
|
class: 'named-element'
|
|
},
|
|
'64': {
|
|
name: 'beginImageData',
|
|
keyword: 'ID',
|
|
description: 'Begins the inline image data',
|
|
numArgs: 0,
|
|
variableArgs: false,
|
|
class: 'named-element'
|
|
},
|
|
'65': {
|
|
name: 'endInlineImage',
|
|
keyword: 'EI',
|
|
description: 'Ends an inline image object',
|
|
numArgs: 1,
|
|
variableArgs: false,
|
|
class: 'named-element'
|
|
},
|
|
'66': {
|
|
name: 'paintXObject',
|
|
keyword: 'Do',
|
|
description: 'Paints the specified XObject',
|
|
numArgs: 1,
|
|
variableArgs: false,
|
|
class: 'named-element'
|
|
},
|
|
'67': {
|
|
name: 'markPoint',
|
|
keyword: 'MP',
|
|
description: 'Marks a point in the content stream',
|
|
numArgs: 1,
|
|
variableArgs: false,
|
|
class: 'marked-content'
|
|
},
|
|
'68': {
|
|
name: 'markPointProps',
|
|
keyword: 'DP',
|
|
description: 'Marks a point in the content stream with properties',
|
|
numArgs: 2,
|
|
variableArgs: false,
|
|
class: 'marked-content'
|
|
},
|
|
'69': {
|
|
name: 'beginMarkedContent',
|
|
keyword: 'BMC',
|
|
description: 'Begins a marked-content sequence',
|
|
numArgs: 1,
|
|
variableArgs: false,
|
|
class: 'marked-content'
|
|
},
|
|
'70': {
|
|
name: 'beginMarkedContentProps',
|
|
keyword: 'BDC',
|
|
description: 'Begins a marked-content sequence with properties',
|
|
numArgs: 2,
|
|
variableArgs: false,
|
|
class: 'marked-content'
|
|
},
|
|
'71': {
|
|
name: 'endMarkedContent',
|
|
keyword: 'EMC',
|
|
description: 'Ends a marked-content sequence',
|
|
numArgs: 0,
|
|
variableArgs: false,
|
|
class: 'marked-content'
|
|
},
|
|
'72': {
|
|
name: 'beginCompat',
|
|
keyword: 'BX',
|
|
description: 'Begins a compatibility section',
|
|
numArgs: 0,
|
|
variableArgs: false,
|
|
class: 'operator'
|
|
},
|
|
'73': {
|
|
name: 'endCompat',
|
|
keyword: 'EX',
|
|
description: 'Ends a compatibility section',
|
|
numArgs: 0,
|
|
variableArgs: false,
|
|
class: 'operator'
|
|
},
|
|
'74': {
|
|
name: 'paintFormXObjectBegin',
|
|
keyword: null,
|
|
description: 'Begins painting a form XObject',
|
|
class: 'named-element'
|
|
},
|
|
'75': {
|
|
name: 'paintFormXObjectEnd',
|
|
keyword: null,
|
|
description: 'Ends painting a form XObject',
|
|
class: 'named-element'
|
|
},
|
|
'76': {
|
|
name: 'beginGroup',
|
|
keyword: null,
|
|
description: 'Begins a transparency group',
|
|
class: 'operator'
|
|
},
|
|
'77': {
|
|
name: 'endGroup',
|
|
keyword: null,
|
|
description: 'Ends a transparency group',
|
|
class: 'operator'
|
|
},
|
|
'80': {
|
|
name: 'beginAnnotation',
|
|
keyword: null,
|
|
description: 'Begins an annotation',
|
|
class: 'named-element'
|
|
},
|
|
'81': {
|
|
name: 'endAnnotation',
|
|
keyword: null,
|
|
description: 'Ends an annotation',
|
|
class: 'named-element'
|
|
},
|
|
'83': {
|
|
name: 'paintImageMaskXObject',
|
|
keyword: null,
|
|
description: 'Paints an image mask XObject',
|
|
class: 'named-element'
|
|
},
|
|
'84': {
|
|
name: 'paintImageMaskXObjectGroup',
|
|
keyword: null,
|
|
description: 'Paints an image mask XObject group',
|
|
class: 'named-element'
|
|
},
|
|
'85': {
|
|
name: 'paintImageXObject',
|
|
keyword: null,
|
|
description: 'Paints an image XObject',
|
|
class: 'named-element'
|
|
},
|
|
'86': {
|
|
name: 'paintInlineImageXObject',
|
|
keyword: null,
|
|
description: 'Paints an inline image XObject',
|
|
class: 'named-element'
|
|
},
|
|
'87': {
|
|
name: 'paintInlineImageXObjectGroup',
|
|
keyword: null,
|
|
description: 'Paints an inline image XObject group',
|
|
class: 'named-element'
|
|
},
|
|
'88': {
|
|
name: 'paintImageXObjectRepeat',
|
|
keyword: null,
|
|
description: 'Paints a repeated image XObject',
|
|
class: 'named-element'
|
|
},
|
|
'89': {
|
|
name: 'paintImageMaskXObjectRepeat',
|
|
keyword: null,
|
|
description: 'Paints a repeated image mask XObject',
|
|
class: 'named-element'
|
|
},
|
|
'90': {
|
|
name: 'paintSolidColorImageMask',
|
|
keyword: null,
|
|
description: 'Paints a solid color image mask',
|
|
class: 'named-element'
|
|
},
|
|
'91': {
|
|
name: 'constructPath',
|
|
keyword: null,
|
|
description: 'Constructs a path from the specified segments',
|
|
class: 'path-construct'
|
|
},
|
|
'92': {
|
|
name: 'setStrokeTransparent',
|
|
keyword: null,
|
|
description: 'Sets the stroke transparency',
|
|
class: 'operator'
|
|
},
|
|
'93': {
|
|
name: 'setFillTransparent',
|
|
keyword: null,
|
|
description: 'Sets the fill transparency',
|
|
class: 'operator'
|
|
}
|
|
}; |