48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
import { PFile, PFiles } from "./file.ts";
|
|
import { DocuBuilder } from "./pdf_builder/builder.ts";
|
|
import { PDFParse } from "pdf-parse";
|
|
|
|
// Deno.test("PFiles initialization", () => {
|
|
// const pfiles = new PFiles("./mobile_src");
|
|
// console.log(pfiles);
|
|
// });
|
|
|
|
// Deno.test("PDF generate", async () => {
|
|
// const builder = new DocuBuilder();
|
|
// try {
|
|
// await builder.with_browser();
|
|
|
|
// const cfg = JSON.parse(await Deno.readTextFile("config.json"));
|
|
// for (const config of cfg.settings) {
|
|
// console.debug(`Processing config: ${JSON.stringify(config)}`);
|
|
// builder.with_files_sync(config.journal.from_directory);
|
|
// builder.as_html_page();
|
|
// await builder.build_as_pdf(config.playwright);
|
|
// }
|
|
// } finally {
|
|
// await builder.close_browser();
|
|
// }
|
|
// });
|
|
|
|
Deno.test({
|
|
name: "pdf",
|
|
sanitizeOps: false,
|
|
sanitizeResources: false,
|
|
fn: async () => {
|
|
const parser = new PDFParse({ url: "./outputs/mobile.pdf" });
|
|
try {
|
|
for (let i = 0; i < 5; i++) {
|
|
let result = (await parser.getText()).getPageText(i + 1);
|
|
result = result.replaceAll("\n", "").trim();
|
|
if (result.includes("关于融工和党组织")) {
|
|
{
|
|
console.debug(`Page ${i + 1} contains the target text.`);
|
|
}
|
|
}
|
|
}
|
|
} finally {
|
|
await parser.destroy();
|
|
}
|
|
},
|
|
});
|