mirror of
https://github.com/jzillmann/pdf-to-markdown.git
synced 2025-01-17 02:58:30 +01:00
Cleanup
This commit is contained in:
parent
2d14de5167
commit
71fb6a23ff
@ -67,20 +67,20 @@ export default class PdfParser {
|
||||
}
|
||||
|
||||
private gatherFontObjects(pages: ParsedPage[]): Promise<Map<string, object>> {
|
||||
let result = Promise.resolve(new Map<string, object>());
|
||||
const uniqueFontIds = new Set<string>();
|
||||
pages.forEach((page) => {
|
||||
const unknownPageFonts: string[] = [];
|
||||
page.items.forEach((item) => {
|
||||
return pages.reduce((promise, page) => {
|
||||
const unknownPageFonts = page.items.reduce((unknowns: string[], item) => {
|
||||
const fontId = item.data['fontName'];
|
||||
if (!uniqueFontIds.has(fontId) && fontId.startsWith('g_d')) {
|
||||
uniqueFontIds.add(fontId);
|
||||
unknownPageFonts.push(fontId);
|
||||
unknowns.push(fontId);
|
||||
}
|
||||
});
|
||||
return unknowns;
|
||||
}, []);
|
||||
|
||||
if (unknownPageFonts.length > 0) {
|
||||
// console.log(`Fetch fonts ${unknownPageFonts} for page ${page.index}`);
|
||||
result = result.then((fontMap) => {
|
||||
promise = promise.then((fontMap) => {
|
||||
return page.pdfjsPage.getOperatorList().then(() => {
|
||||
unknownPageFonts.forEach((fontId) => {
|
||||
const fontObject = page.pdfjsPage.commonObjs.get(fontId);
|
||||
@ -90,8 +90,9 @@ export default class PdfParser {
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
return result;
|
||||
|
||||
return promise;
|
||||
}, Promise.resolve(new Map<string, object>()));
|
||||
}
|
||||
|
||||
private documentInitParameters(src: string | Uint8Array | object): object {
|
||||
|
@ -66,7 +66,7 @@ export default class CalculateStatistics extends ItemTransformer {
|
||||
const mostUsedDistance = parseInt(getMostUsedKey(distanceToOccurrence));
|
||||
|
||||
const fontIdToName: string[] = [];
|
||||
const fontToType = new Map();
|
||||
const fontToType = new Map<string, FontType>();
|
||||
context.fontMap.forEach(function (value, key) {
|
||||
const fontName = value['name'];
|
||||
fontIdToName.push(`${key} = ${fontName}`);
|
||||
|
Loading…
Reference in New Issue
Block a user