MCPcopy Index your code
hub / github.com/OpenSignLabs/OpenSign / _drawTextField

Function _drawTextField

apps/OpenSign/src/constant/Utils.js:3902–3948  ·  view source on GitHub ↗
(page, field, rect, font)

Source from the content-addressed store, hash-verified

3900}
3901
3902function _drawTextField(page, field, rect, font) {
3903 let text = "";
3904 try {
3905 text = field.getText?.() ?? "";
3906 } catch {
3907 text = "";
3908 }
3909 text = String(text ?? "");
3910
3911 if (!text) return;
3912
3913 let multiline = false;
3914 try {
3915 multiline = field.isMultiline?.() ?? false;
3916 } catch {
3917 /* ignore */
3918 }
3919
3920 let comb = false;
3921 try {
3922 comb = field.isCombed?.() ?? false;
3923 } catch {
3924 /* ignore */
3925 }
3926
3927 if (comb) {
3928 _drawCombText(page, text, rect, font);
3929 return;
3930 }
3931
3932 if (multiline || text.includes("\n")) {
3933 _drawMultilineText(page, text, rect, font);
3934 return;
3935 }
3936
3937 const fontSize = _fitSingleLineFontSize(text, rect, font);
3938 const baselineY = rect.y + Math.max(2, (rect.height - fontSize) / 2);
3939
3940 page.drawText(text, {
3941 x: rect.x + 2,
3942 y: baselineY,
3943 size: fontSize,
3944 font,
3945 color: rgb(0, 0, 0),
3946 maxWidth: Math.max(1, rect.width - 4)
3947 });
3948}
3949
3950function _drawMultilineText(page, text, rect, font) {
3951 const lines = String(text).replace(/\r/g, "").split("\n");

Callers 1

flattenPdfFunction · 0.85

Calls 3

_drawCombTextFunction · 0.85
_drawMultilineTextFunction · 0.85
_fitSingleLineFontSizeFunction · 0.85

Tested by

no test coverage detected