Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/embedpre.../assets/pdf/build
File: pdf.worker.js
result.fillColorSpace = ColorSpace.parse({
[38500] Fix | Delete
cs: args[0],
[38501] Fix | Delete
xref: this.xref,
[38502] Fix | Delete
resources: this.resources,
[38503] Fix | Delete
pdfFunctionFactory: this._pdfFunctionFactory,
[38504] Fix | Delete
localColorSpaceCache: this._localColorSpaceCache
[38505] Fix | Delete
});
[38506] Fix | Delete
break;
[38507] Fix | Delete
case OPS.setFillColor:
[38508] Fix | Delete
const cs = result.fillColorSpace;
[38509] Fix | Delete
cs.getRgbItem(args, 0, result.fontColor, 0);
[38510] Fix | Delete
break;
[38511] Fix | Delete
case OPS.setFillRGBColor:
[38512] Fix | Delete
ColorSpace.singletons.rgb.getRgbItem(args, 0, result.fontColor, 0);
[38513] Fix | Delete
break;
[38514] Fix | Delete
case OPS.setFillGray:
[38515] Fix | Delete
ColorSpace.singletons.gray.getRgbItem(args, 0, result.fontColor, 0);
[38516] Fix | Delete
break;
[38517] Fix | Delete
case OPS.setFillCMYKColor:
[38518] Fix | Delete
ColorSpace.singletons.cmyk.getRgbItem(args, 0, result.fontColor, 0);
[38519] Fix | Delete
break;
[38520] Fix | Delete
case OPS.showText:
[38521] Fix | Delete
case OPS.showSpacedText:
[38522] Fix | Delete
case OPS.nextLineShowText:
[38523] Fix | Delete
case OPS.nextLineSetSpacingShowText:
[38524] Fix | Delete
breakLoop = true;
[38525] Fix | Delete
break;
[38526] Fix | Delete
}
[38527] Fix | Delete
}
[38528] Fix | Delete
} catch (reason) {
[38529] Fix | Delete
warn(`parseAppearanceStream - ignoring errors: "${reason}".`);
[38530] Fix | Delete
}
[38531] Fix | Delete
this.stream.reset();
[38532] Fix | Delete
delete result.scaleFactor;
[38533] Fix | Delete
delete result.fillColorSpace;
[38534] Fix | Delete
return result;
[38535] Fix | Delete
}
[38536] Fix | Delete
get _localColorSpaceCache() {
[38537] Fix | Delete
return shadow(this, "_localColorSpaceCache", new LocalColorSpaceCache());
[38538] Fix | Delete
}
[38539] Fix | Delete
get _pdfFunctionFactory() {
[38540] Fix | Delete
const pdfFunctionFactory = new PDFFunctionFactory({
[38541] Fix | Delete
xref: this.xref,
[38542] Fix | Delete
isEvalSupported: this.evaluatorOptions.isEvalSupported
[38543] Fix | Delete
});
[38544] Fix | Delete
return shadow(this, "_pdfFunctionFactory", pdfFunctionFactory);
[38545] Fix | Delete
}
[38546] Fix | Delete
}
[38547] Fix | Delete
function parseAppearanceStream(stream, evaluatorOptions, xref) {
[38548] Fix | Delete
return new AppearanceStreamEvaluator(stream, evaluatorOptions, xref).parse();
[38549] Fix | Delete
}
[38550] Fix | Delete
function getPdfColor(color, isFill) {
[38551] Fix | Delete
if (color[0] === color[1] && color[1] === color[2]) {
[38552] Fix | Delete
const gray = color[0] / 255;
[38553] Fix | Delete
return `${numberToString(gray)} ${isFill ? "g" : "G"}`;
[38554] Fix | Delete
}
[38555] Fix | Delete
return Array.from(color, c => numberToString(c / 255)).join(" ") + ` ${isFill ? "rg" : "RG"}`;
[38556] Fix | Delete
}
[38557] Fix | Delete
function createDefaultAppearance({
[38558] Fix | Delete
fontSize,
[38559] Fix | Delete
fontName,
[38560] Fix | Delete
fontColor
[38561] Fix | Delete
}) {
[38562] Fix | Delete
return `/${escapePDFName(fontName)} ${fontSize} Tf ${getPdfColor(fontColor, true)}`;
[38563] Fix | Delete
}
[38564] Fix | Delete
class FakeUnicodeFont {
[38565] Fix | Delete
constructor(xref, fontFamily) {
[38566] Fix | Delete
this.xref = xref;
[38567] Fix | Delete
this.widths = null;
[38568] Fix | Delete
this.firstChar = Infinity;
[38569] Fix | Delete
this.lastChar = -Infinity;
[38570] Fix | Delete
this.fontFamily = fontFamily;
[38571] Fix | Delete
const canvas = new OffscreenCanvas(1, 1);
[38572] Fix | Delete
this.ctxMeasure = canvas.getContext("2d");
[38573] Fix | Delete
if (!FakeUnicodeFont._fontNameId) {
[38574] Fix | Delete
FakeUnicodeFont._fontNameId = 1;
[38575] Fix | Delete
}
[38576] Fix | Delete
this.fontName = Name.get(`InvalidPDFjsFont_${fontFamily}_${FakeUnicodeFont._fontNameId++}`);
[38577] Fix | Delete
}
[38578] Fix | Delete
get fontDescriptorRef() {
[38579] Fix | Delete
if (!FakeUnicodeFont._fontDescriptorRef) {
[38580] Fix | Delete
const fontDescriptor = new Dict(this.xref);
[38581] Fix | Delete
fontDescriptor.set("Type", Name.get("FontDescriptor"));
[38582] Fix | Delete
fontDescriptor.set("FontName", this.fontName);
[38583] Fix | Delete
fontDescriptor.set("FontFamily", "MyriadPro Regular");
[38584] Fix | Delete
fontDescriptor.set("FontBBox", [0, 0, 0, 0]);
[38585] Fix | Delete
fontDescriptor.set("FontStretch", Name.get("Normal"));
[38586] Fix | Delete
fontDescriptor.set("FontWeight", 400);
[38587] Fix | Delete
fontDescriptor.set("ItalicAngle", 0);
[38588] Fix | Delete
FakeUnicodeFont._fontDescriptorRef = this.xref.getNewPersistentRef(fontDescriptor);
[38589] Fix | Delete
}
[38590] Fix | Delete
return FakeUnicodeFont._fontDescriptorRef;
[38591] Fix | Delete
}
[38592] Fix | Delete
get descendantFontRef() {
[38593] Fix | Delete
const descendantFont = new Dict(this.xref);
[38594] Fix | Delete
descendantFont.set("BaseFont", this.fontName);
[38595] Fix | Delete
descendantFont.set("Type", Name.get("Font"));
[38596] Fix | Delete
descendantFont.set("Subtype", Name.get("CIDFontType0"));
[38597] Fix | Delete
descendantFont.set("CIDToGIDMap", Name.get("Identity"));
[38598] Fix | Delete
descendantFont.set("FirstChar", this.firstChar);
[38599] Fix | Delete
descendantFont.set("LastChar", this.lastChar);
[38600] Fix | Delete
descendantFont.set("FontDescriptor", this.fontDescriptorRef);
[38601] Fix | Delete
descendantFont.set("DW", 1000);
[38602] Fix | Delete
const widths = [];
[38603] Fix | Delete
const chars = [...this.widths.entries()].sort();
[38604] Fix | Delete
let currentChar = null;
[38605] Fix | Delete
let currentWidths = null;
[38606] Fix | Delete
for (const [char, width] of chars) {
[38607] Fix | Delete
if (!currentChar) {
[38608] Fix | Delete
currentChar = char;
[38609] Fix | Delete
currentWidths = [width];
[38610] Fix | Delete
continue;
[38611] Fix | Delete
}
[38612] Fix | Delete
if (char === currentChar + currentWidths.length) {
[38613] Fix | Delete
currentWidths.push(width);
[38614] Fix | Delete
} else {
[38615] Fix | Delete
widths.push(currentChar, currentWidths);
[38616] Fix | Delete
currentChar = char;
[38617] Fix | Delete
currentWidths = [width];
[38618] Fix | Delete
}
[38619] Fix | Delete
}
[38620] Fix | Delete
if (currentChar) {
[38621] Fix | Delete
widths.push(currentChar, currentWidths);
[38622] Fix | Delete
}
[38623] Fix | Delete
descendantFont.set("W", widths);
[38624] Fix | Delete
const cidSystemInfo = new Dict(this.xref);
[38625] Fix | Delete
cidSystemInfo.set("Ordering", "Identity");
[38626] Fix | Delete
cidSystemInfo.set("Registry", "Adobe");
[38627] Fix | Delete
cidSystemInfo.set("Supplement", 0);
[38628] Fix | Delete
descendantFont.set("CIDSystemInfo", cidSystemInfo);
[38629] Fix | Delete
return this.xref.getNewPersistentRef(descendantFont);
[38630] Fix | Delete
}
[38631] Fix | Delete
get baseFontRef() {
[38632] Fix | Delete
const baseFont = new Dict(this.xref);
[38633] Fix | Delete
baseFont.set("BaseFont", this.fontName);
[38634] Fix | Delete
baseFont.set("Type", Name.get("Font"));
[38635] Fix | Delete
baseFont.set("Subtype", Name.get("Type0"));
[38636] Fix | Delete
baseFont.set("Encoding", Name.get("Identity-H"));
[38637] Fix | Delete
baseFont.set("DescendantFonts", [this.descendantFontRef]);
[38638] Fix | Delete
baseFont.set("ToUnicode", Name.get("Identity-H"));
[38639] Fix | Delete
return this.xref.getNewPersistentRef(baseFont);
[38640] Fix | Delete
}
[38641] Fix | Delete
get resources() {
[38642] Fix | Delete
const resources = new Dict(this.xref);
[38643] Fix | Delete
const font = new Dict(this.xref);
[38644] Fix | Delete
font.set(this.fontName.name, this.baseFontRef);
[38645] Fix | Delete
resources.set("Font", font);
[38646] Fix | Delete
return resources;
[38647] Fix | Delete
}
[38648] Fix | Delete
_createContext() {
[38649] Fix | Delete
this.widths = new Map();
[38650] Fix | Delete
this.ctxMeasure.font = `1000px ${this.fontFamily}`;
[38651] Fix | Delete
return this.ctxMeasure;
[38652] Fix | Delete
}
[38653] Fix | Delete
createFontResources(text) {
[38654] Fix | Delete
const ctx = this._createContext();
[38655] Fix | Delete
for (const line of text.split(/\r\n?|\n/)) {
[38656] Fix | Delete
for (const char of line.split("")) {
[38657] Fix | Delete
const code = char.charCodeAt(0);
[38658] Fix | Delete
if (this.widths.has(code)) {
[38659] Fix | Delete
continue;
[38660] Fix | Delete
}
[38661] Fix | Delete
const metrics = ctx.measureText(char);
[38662] Fix | Delete
const width = Math.ceil(metrics.width);
[38663] Fix | Delete
this.widths.set(code, width);
[38664] Fix | Delete
this.firstChar = Math.min(code, this.firstChar);
[38665] Fix | Delete
this.lastChar = Math.max(code, this.lastChar);
[38666] Fix | Delete
}
[38667] Fix | Delete
}
[38668] Fix | Delete
return this.resources;
[38669] Fix | Delete
}
[38670] Fix | Delete
static getFirstPositionInfo(rect, rotation, fontSize) {
[38671] Fix | Delete
const [x1, y1, x2, y2] = rect;
[38672] Fix | Delete
let w = x2 - x1;
[38673] Fix | Delete
let h = y2 - y1;
[38674] Fix | Delete
if (rotation % 180 !== 0) {
[38675] Fix | Delete
[w, h] = [h, w];
[38676] Fix | Delete
}
[38677] Fix | Delete
const lineHeight = LINE_FACTOR * fontSize;
[38678] Fix | Delete
const lineDescent = LINE_DESCENT_FACTOR * fontSize;
[38679] Fix | Delete
return {
[38680] Fix | Delete
coords: [0, h + lineDescent - lineHeight],
[38681] Fix | Delete
bbox: [0, 0, w, h],
[38682] Fix | Delete
matrix: rotation !== 0 ? getRotationMatrix(rotation, h, lineHeight) : undefined
[38683] Fix | Delete
};
[38684] Fix | Delete
}
[38685] Fix | Delete
createAppearance(text, rect, rotation, fontSize, bgColor, strokeAlpha) {
[38686] Fix | Delete
const ctx = this._createContext();
[38687] Fix | Delete
const lines = [];
[38688] Fix | Delete
let maxWidth = -Infinity;
[38689] Fix | Delete
for (const line of text.split(/\r\n?|\n/)) {
[38690] Fix | Delete
lines.push(line);
[38691] Fix | Delete
const lineWidth = ctx.measureText(line).width;
[38692] Fix | Delete
maxWidth = Math.max(maxWidth, lineWidth);
[38693] Fix | Delete
for (const code of codePointIter(line)) {
[38694] Fix | Delete
const char = String.fromCodePoint(code);
[38695] Fix | Delete
let width = this.widths.get(code);
[38696] Fix | Delete
if (width === undefined) {
[38697] Fix | Delete
const metrics = ctx.measureText(char);
[38698] Fix | Delete
width = Math.ceil(metrics.width);
[38699] Fix | Delete
this.widths.set(code, width);
[38700] Fix | Delete
this.firstChar = Math.min(code, this.firstChar);
[38701] Fix | Delete
this.lastChar = Math.max(code, this.lastChar);
[38702] Fix | Delete
}
[38703] Fix | Delete
}
[38704] Fix | Delete
}
[38705] Fix | Delete
maxWidth *= fontSize / 1000;
[38706] Fix | Delete
const [x1, y1, x2, y2] = rect;
[38707] Fix | Delete
let w = x2 - x1;
[38708] Fix | Delete
let h = y2 - y1;
[38709] Fix | Delete
if (rotation % 180 !== 0) {
[38710] Fix | Delete
[w, h] = [h, w];
[38711] Fix | Delete
}
[38712] Fix | Delete
let hscale = 1;
[38713] Fix | Delete
if (maxWidth > w) {
[38714] Fix | Delete
hscale = w / maxWidth;
[38715] Fix | Delete
}
[38716] Fix | Delete
let vscale = 1;
[38717] Fix | Delete
const lineHeight = LINE_FACTOR * fontSize;
[38718] Fix | Delete
const lineDescent = LINE_DESCENT_FACTOR * fontSize;
[38719] Fix | Delete
const maxHeight = lineHeight * lines.length;
[38720] Fix | Delete
if (maxHeight > h) {
[38721] Fix | Delete
vscale = h / maxHeight;
[38722] Fix | Delete
}
[38723] Fix | Delete
const fscale = Math.min(hscale, vscale);
[38724] Fix | Delete
const newFontSize = fontSize * fscale;
[38725] Fix | Delete
const buffer = ["q", `0 0 ${numberToString(w)} ${numberToString(h)} re W n`, `BT`, `1 0 0 1 0 ${numberToString(h + lineDescent)} Tm 0 Tc ${getPdfColor(bgColor, true)}`, `/${this.fontName.name} ${numberToString(newFontSize)} Tf`];
[38726] Fix | Delete
const {
[38727] Fix | Delete
resources
[38728] Fix | Delete
} = this;
[38729] Fix | Delete
strokeAlpha = typeof strokeAlpha === "number" && strokeAlpha >= 0 && strokeAlpha <= 1 ? strokeAlpha : 1;
[38730] Fix | Delete
if (strokeAlpha !== 1) {
[38731] Fix | Delete
buffer.push("/R0 gs");
[38732] Fix | Delete
const extGState = new Dict(this.xref);
[38733] Fix | Delete
const r0 = new Dict(this.xref);
[38734] Fix | Delete
r0.set("ca", strokeAlpha);
[38735] Fix | Delete
r0.set("CA", strokeAlpha);
[38736] Fix | Delete
r0.set("Type", Name.get("ExtGState"));
[38737] Fix | Delete
extGState.set("R0", r0);
[38738] Fix | Delete
resources.set("ExtGState", extGState);
[38739] Fix | Delete
}
[38740] Fix | Delete
const vShift = numberToString(lineHeight);
[38741] Fix | Delete
for (const line of lines) {
[38742] Fix | Delete
buffer.push(`0 -${vShift} Td <${stringToUTF16HexString(line)}> Tj`);
[38743] Fix | Delete
}
[38744] Fix | Delete
buffer.push("ET", "Q");
[38745] Fix | Delete
const appearance = buffer.join("\n");
[38746] Fix | Delete
const appearanceStreamDict = new Dict(this.xref);
[38747] Fix | Delete
appearanceStreamDict.set("Subtype", Name.get("Form"));
[38748] Fix | Delete
appearanceStreamDict.set("Type", Name.get("XObject"));
[38749] Fix | Delete
appearanceStreamDict.set("BBox", [0, 0, w, h]);
[38750] Fix | Delete
appearanceStreamDict.set("Length", appearance.length);
[38751] Fix | Delete
appearanceStreamDict.set("Resources", resources);
[38752] Fix | Delete
if (rotation) {
[38753] Fix | Delete
const matrix = getRotationMatrix(rotation, w, h);
[38754] Fix | Delete
appearanceStreamDict.set("Matrix", matrix);
[38755] Fix | Delete
}
[38756] Fix | Delete
const ap = new StringStream(appearance);
[38757] Fix | Delete
ap.dict = appearanceStreamDict;
[38758] Fix | Delete
return ap;
[38759] Fix | Delete
}
[38760] Fix | Delete
}
[38761] Fix | Delete
[38762] Fix | Delete
;// CONCATENATED MODULE: ./src/core/name_number_tree.js
[38763] Fix | Delete
[38764] Fix | Delete
[38765] Fix | Delete
[38766] Fix | Delete
class NameOrNumberTree {
[38767] Fix | Delete
constructor(root, xref, type) {
[38768] Fix | Delete
if (this.constructor === NameOrNumberTree) {
[38769] Fix | Delete
unreachable("Cannot initialize NameOrNumberTree.");
[38770] Fix | Delete
}
[38771] Fix | Delete
this.root = root;
[38772] Fix | Delete
this.xref = xref;
[38773] Fix | Delete
this._type = type;
[38774] Fix | Delete
}
[38775] Fix | Delete
getAll() {
[38776] Fix | Delete
const map = new Map();
[38777] Fix | Delete
if (!this.root) {
[38778] Fix | Delete
return map;
[38779] Fix | Delete
}
[38780] Fix | Delete
const xref = this.xref;
[38781] Fix | Delete
const processed = new RefSet();
[38782] Fix | Delete
processed.put(this.root);
[38783] Fix | Delete
const queue = [this.root];
[38784] Fix | Delete
while (queue.length > 0) {
[38785] Fix | Delete
const obj = xref.fetchIfRef(queue.shift());
[38786] Fix | Delete
if (!(obj instanceof Dict)) {
[38787] Fix | Delete
continue;
[38788] Fix | Delete
}
[38789] Fix | Delete
if (obj.has("Kids")) {
[38790] Fix | Delete
const kids = obj.get("Kids");
[38791] Fix | Delete
if (!Array.isArray(kids)) {
[38792] Fix | Delete
continue;
[38793] Fix | Delete
}
[38794] Fix | Delete
for (const kid of kids) {
[38795] Fix | Delete
if (processed.has(kid)) {
[38796] Fix | Delete
throw new FormatError(`Duplicate entry in "${this._type}" tree.`);
[38797] Fix | Delete
}
[38798] Fix | Delete
queue.push(kid);
[38799] Fix | Delete
processed.put(kid);
[38800] Fix | Delete
}
[38801] Fix | Delete
continue;
[38802] Fix | Delete
}
[38803] Fix | Delete
const entries = obj.get(this._type);
[38804] Fix | Delete
if (!Array.isArray(entries)) {
[38805] Fix | Delete
continue;
[38806] Fix | Delete
}
[38807] Fix | Delete
for (let i = 0, ii = entries.length; i < ii; i += 2) {
[38808] Fix | Delete
map.set(xref.fetchIfRef(entries[i]), xref.fetchIfRef(entries[i + 1]));
[38809] Fix | Delete
}
[38810] Fix | Delete
}
[38811] Fix | Delete
return map;
[38812] Fix | Delete
}
[38813] Fix | Delete
get(key) {
[38814] Fix | Delete
if (!this.root) {
[38815] Fix | Delete
return null;
[38816] Fix | Delete
}
[38817] Fix | Delete
const xref = this.xref;
[38818] Fix | Delete
let kidsOrEntries = xref.fetchIfRef(this.root);
[38819] Fix | Delete
let loopCount = 0;
[38820] Fix | Delete
const MAX_LEVELS = 10;
[38821] Fix | Delete
while (kidsOrEntries.has("Kids")) {
[38822] Fix | Delete
if (++loopCount > MAX_LEVELS) {
[38823] Fix | Delete
warn(`Search depth limit reached for "${this._type}" tree.`);
[38824] Fix | Delete
return null;
[38825] Fix | Delete
}
[38826] Fix | Delete
const kids = kidsOrEntries.get("Kids");
[38827] Fix | Delete
if (!Array.isArray(kids)) {
[38828] Fix | Delete
return null;
[38829] Fix | Delete
}
[38830] Fix | Delete
let l = 0,
[38831] Fix | Delete
r = kids.length - 1;
[38832] Fix | Delete
while (l <= r) {
[38833] Fix | Delete
const m = l + r >> 1;
[38834] Fix | Delete
const kid = xref.fetchIfRef(kids[m]);
[38835] Fix | Delete
const limits = kid.get("Limits");
[38836] Fix | Delete
if (key < xref.fetchIfRef(limits[0])) {
[38837] Fix | Delete
r = m - 1;
[38838] Fix | Delete
} else if (key > xref.fetchIfRef(limits[1])) {
[38839] Fix | Delete
l = m + 1;
[38840] Fix | Delete
} else {
[38841] Fix | Delete
kidsOrEntries = kid;
[38842] Fix | Delete
break;
[38843] Fix | Delete
}
[38844] Fix | Delete
}
[38845] Fix | Delete
if (l > r) {
[38846] Fix | Delete
return null;
[38847] Fix | Delete
}
[38848] Fix | Delete
}
[38849] Fix | Delete
const entries = kidsOrEntries.get(this._type);
[38850] Fix | Delete
if (Array.isArray(entries)) {
[38851] Fix | Delete
let l = 0,
[38852] Fix | Delete
r = entries.length - 2;
[38853] Fix | Delete
while (l <= r) {
[38854] Fix | Delete
const tmp = l + r >> 1,
[38855] Fix | Delete
m = tmp + (tmp & 1);
[38856] Fix | Delete
const currentKey = xref.fetchIfRef(entries[m]);
[38857] Fix | Delete
if (key < currentKey) {
[38858] Fix | Delete
r = m - 2;
[38859] Fix | Delete
} else if (key > currentKey) {
[38860] Fix | Delete
l = m + 2;
[38861] Fix | Delete
} else {
[38862] Fix | Delete
return xref.fetchIfRef(entries[m + 1]);
[38863] Fix | Delete
}
[38864] Fix | Delete
}
[38865] Fix | Delete
}
[38866] Fix | Delete
return null;
[38867] Fix | Delete
}
[38868] Fix | Delete
}
[38869] Fix | Delete
class NameTree extends NameOrNumberTree {
[38870] Fix | Delete
constructor(root, xref) {
[38871] Fix | Delete
super(root, xref, "Names");
[38872] Fix | Delete
}
[38873] Fix | Delete
}
[38874] Fix | Delete
class NumberTree extends NameOrNumberTree {
[38875] Fix | Delete
constructor(root, xref) {
[38876] Fix | Delete
super(root, xref, "Nums");
[38877] Fix | Delete
}
[38878] Fix | Delete
}
[38879] Fix | Delete
[38880] Fix | Delete
;// CONCATENATED MODULE: ./src/core/cleanup_helper.js
[38881] Fix | Delete
[38882] Fix | Delete
[38883] Fix | Delete
[38884] Fix | Delete
[38885] Fix | Delete
function clearGlobalCaches() {
[38886] Fix | Delete
clearPatternCaches();
[38887] Fix | Delete
clearPrimitiveCaches();
[38888] Fix | Delete
clearUnicodeCaches();
[38889] Fix | Delete
JpxImage.cleanup();
[38890] Fix | Delete
}
[38891] Fix | Delete
[38892] Fix | Delete
;// CONCATENATED MODULE: ./src/core/file_spec.js
[38893] Fix | Delete
[38894] Fix | Delete
[38895] Fix | Delete
[38896] Fix | Delete
function pickPlatformItem(dict) {
[38897] Fix | Delete
if (!(dict instanceof Dict)) {
[38898] Fix | Delete
return null;
[38899] Fix | Delete
}
[38900] Fix | Delete
if (dict.has("UF")) {
[38901] Fix | Delete
return dict.get("UF");
[38902] Fix | Delete
} else if (dict.has("F")) {
[38903] Fix | Delete
return dict.get("F");
[38904] Fix | Delete
} else if (dict.has("Unix")) {
[38905] Fix | Delete
return dict.get("Unix");
[38906] Fix | Delete
} else if (dict.has("Mac")) {
[38907] Fix | Delete
return dict.get("Mac");
[38908] Fix | Delete
} else if (dict.has("DOS")) {
[38909] Fix | Delete
return dict.get("DOS");
[38910] Fix | Delete
}
[38911] Fix | Delete
return null;
[38912] Fix | Delete
}
[38913] Fix | Delete
function stripPath(str) {
[38914] Fix | Delete
return str.substring(str.lastIndexOf("/") + 1);
[38915] Fix | Delete
}
[38916] Fix | Delete
class FileSpec {
[38917] Fix | Delete
#contentAvailable = false;
[38918] Fix | Delete
constructor(root, xref, skipContent = false) {
[38919] Fix | Delete
if (!(root instanceof Dict)) {
[38920] Fix | Delete
return;
[38921] Fix | Delete
}
[38922] Fix | Delete
this.xref = xref;
[38923] Fix | Delete
this.root = root;
[38924] Fix | Delete
if (root.has("FS")) {
[38925] Fix | Delete
this.fs = root.get("FS");
[38926] Fix | Delete
}
[38927] Fix | Delete
if (root.has("RF")) {
[38928] Fix | Delete
warn("Related file specifications are not supported");
[38929] Fix | Delete
}
[38930] Fix | Delete
if (!skipContent) {
[38931] Fix | Delete
if (root.has("EF")) {
[38932] Fix | Delete
this.#contentAvailable = true;
[38933] Fix | Delete
} else {
[38934] Fix | Delete
warn("Non-embedded file specifications are not supported");
[38935] Fix | Delete
}
[38936] Fix | Delete
}
[38937] Fix | Delete
}
[38938] Fix | Delete
get filename() {
[38939] Fix | Delete
let filename = "";
[38940] Fix | Delete
const item = pickPlatformItem(this.root);
[38941] Fix | Delete
if (item && typeof item === "string") {
[38942] Fix | Delete
filename = stringToPDFString(item).replaceAll("\\\\", "\\").replaceAll("\\/", "/").replaceAll("\\", "/");
[38943] Fix | Delete
}
[38944] Fix | Delete
return shadow(this, "filename", filename || "unnamed");
[38945] Fix | Delete
}
[38946] Fix | Delete
get content() {
[38947] Fix | Delete
if (!this.#contentAvailable) {
[38948] Fix | Delete
return null;
[38949] Fix | Delete
}
[38950] Fix | Delete
this._contentRef ||= pickPlatformItem(this.root?.get("EF"));
[38951] Fix | Delete
let content = null;
[38952] Fix | Delete
if (this._contentRef) {
[38953] Fix | Delete
const fileObj = this.xref.fetchIfRef(this._contentRef);
[38954] Fix | Delete
if (fileObj instanceof BaseStream) {
[38955] Fix | Delete
content = fileObj.getBytes();
[38956] Fix | Delete
} else {
[38957] Fix | Delete
warn("Embedded file specification points to non-existing/invalid content");
[38958] Fix | Delete
}
[38959] Fix | Delete
} else {
[38960] Fix | Delete
warn("Embedded file specification does not have any content");
[38961] Fix | Delete
}
[38962] Fix | Delete
return content;
[38963] Fix | Delete
}
[38964] Fix | Delete
get description() {
[38965] Fix | Delete
let description = "";
[38966] Fix | Delete
const desc = this.root?.get("Desc");
[38967] Fix | Delete
if (desc && typeof desc === "string") {
[38968] Fix | Delete
description = stringToPDFString(desc);
[38969] Fix | Delete
}
[38970] Fix | Delete
return shadow(this, "description", description);
[38971] Fix | Delete
}
[38972] Fix | Delete
get serializable() {
[38973] Fix | Delete
return {
[38974] Fix | Delete
rawFilename: this.filename,
[38975] Fix | Delete
filename: stripPath(this.filename),
[38976] Fix | Delete
content: this.content,
[38977] Fix | Delete
description: this.description
[38978] Fix | Delete
};
[38979] Fix | Delete
}
[38980] Fix | Delete
}
[38981] Fix | Delete
[38982] Fix | Delete
;// CONCATENATED MODULE: ./src/core/xml_parser.js
[38983] Fix | Delete
[38984] Fix | Delete
[38985] Fix | Delete
[38986] Fix | Delete
const XMLParserErrorCode = {
[38987] Fix | Delete
NoError: 0,
[38988] Fix | Delete
EndOfDocument: -1,
[38989] Fix | Delete
UnterminatedCdat: -2,
[38990] Fix | Delete
UnterminatedXmlDeclaration: -3,
[38991] Fix | Delete
UnterminatedDoctypeDeclaration: -4,
[38992] Fix | Delete
UnterminatedComment: -5,
[38993] Fix | Delete
MalformedElement: -6,
[38994] Fix | Delete
OutOfMemory: -7,
[38995] Fix | Delete
UnterminatedAttributeValue: -8,
[38996] Fix | Delete
UnterminatedElement: -9,
[38997] Fix | Delete
ElementNeverBegun: -10
[38998] Fix | Delete
};
[38999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function