-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
109 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
import * as path from 'path'; | ||
|
||
export default () => ({ | ||
port: parseInt(process.env.PORT) || 3000, | ||
pdfOutputPath: path.resolve(__dirname, '../../test/pdf/output'), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Group } from './Group'; | ||
|
||
export interface IHoraireCours { | ||
code: string; | ||
title: string; | ||
prerequisites: string; | ||
groups: { [groupNumber: string]: Group }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import PDFParser, { Output } from 'pdf2json'; | ||
import { TextExtractor } from './textExtractorUtil'; | ||
|
||
export class PdfParserUtil { | ||
public static async parsePdfBuffer( | ||
pdfBuffer: Buffer, | ||
processData: (pdfData: Output) => any, | ||
): Promise<any> { | ||
const parser = new PDFParser(); | ||
|
||
return new Promise((resolve, reject) => { | ||
parser.on('pdfParser_dataError', (errData) => console.error(errData)); | ||
parser.on('pdfParser_dataReady', async (pdfData) => { | ||
try { | ||
const result = await processData(pdfData); | ||
resolve(result); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
parser.parseBuffer(pdfBuffer); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Text } from 'pdf2json'; | ||
|
||
export class TextExtractor { | ||
public static extractTextDetails(textItem: Text): { | ||
fontSize: number; | ||
textContent: string; | ||
xPos: number; | ||
yPos: number; | ||
bold: boolean; | ||
} { | ||
const textContent: string = decodeURIComponent(textItem.R[0].T).trim(); | ||
const fontSize: number = textItem.R[0].TS[1]; | ||
const xPos: number = textItem.x; | ||
const yPos: number = textItem.y; | ||
const bold: boolean = textItem.R[0].TS[2] === 1; | ||
|
||
return { textContent, fontSize, xPos, yPos, bold }; | ||
} | ||
} |
Oops, something went wrong.