MCPcopy Create free account
hub / github.com/LibPDF-js/core / processOperation

Method processOperation

src/text/text-extractor.ts:63–173  ·  view source on GitHub ↗

* Process a single content stream operation.

(op: AnyOperation)

Source from the content-addressed store, hash-verified

61 * Process a single content stream operation.
62 */
63 private processOperation(op: AnyOperation): void {
64 // Handle inline images separately
65 if (isInlineImageOperation(op)) {
66 return; // Skip inline images
67 }
68
69 const { operator, operands } = op;
70
71 switch (operator) {
72 // Graphics state operators
73 case "q":
74 this.state.saveGraphicsState();
75 break;
76
77 case "Q":
78 this.state.restoreGraphicsState();
79 break;
80
81 case "cm":
82 this.handleCm(operands);
83 break;
84
85 // Text object operators
86 case "BT":
87 this.state.beginText();
88 break;
89
90 case "ET":
91 this.state.endText();
92 break;
93
94 // Text state operators
95 case "Tc":
96 this.state.charSpacing = this.getNumber(operands[0]);
97 break;
98
99 case "Tw":
100 this.state.wordSpacing = this.getNumber(operands[0]);
101 break;
102
103 case "Tz":
104 this.state.horizontalScale = this.getNumber(operands[0]);
105 break;
106
107 case "TL":
108 this.state.leading = this.getNumber(operands[0]);
109 break;
110
111 case "Tf":
112 this.handleTf(operands);
113 break;
114
115 case "Tr":
116 this.state.renderMode = this.getNumber(operands[0]);
117 break;
118
119 case "Ts":
120 this.state.rise = this.getNumber(operands[0]);

Callers 1

extractMethod · 0.95

Calls 14

handleCmMethod · 0.95
getNumberMethod · 0.95
handleTfMethod · 0.95
handleTjMethod · 0.95
handleTJMethod · 0.95
isInlineImageOperationFunction · 0.90
saveGraphicsStateMethod · 0.80
restoreGraphicsStateMethod · 0.80
beginTextMethod · 0.80
endTextMethod · 0.80
moveTextPositionMethod · 0.80

Tested by

no test coverage detected