文档部分基本完成,还需要完善生成目录
This commit is contained in:
1 parent
578109c8de
commit
365b1db47e
109 files changed
+6222
-289
No files matched your search
+42
-13
@@ -1,18 +1,47 @@
|
||||
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("./test_example_data");
|
||||
//console.log(pfiles);
|
||||
});
|
||||
// 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();
|
||||
builder.with_files_sync("./test_example_data");
|
||||
await builder.build_as_pdf();
|
||||
} finally {
|
||||
await builder.close_browser();
|
||||
}
|
||||
// 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();
|
||||
}
|
||||
},
|
||||
});
|
||||
Reference in new issue
Block a user