mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-10 02:05:37 +02:00
XFA - Add the possibily to layout and measure text
- some containers doesn't always have their 2 dimensions and those dimensions re based on contents; - so in order to measure text, we must get the glyph widths (for the xfa fonts) before starting the layout; - implement a word-wrap algorithm; - handle font change during text layout.
This commit is contained in:
parent
335d4cb2fc
commit
8eeb7ab4a3
12 changed files with 416 additions and 91 deletions
|
@ -187,13 +187,8 @@ class WorkerMessageHandler {
|
|||
await pdfManager.ensureDoc("checkFirstPage");
|
||||
}
|
||||
|
||||
const [numPages, fingerprint, htmlForXfa] = await Promise.all([
|
||||
pdfManager.ensureDoc("numPages"),
|
||||
pdfManager.ensureDoc("fingerprint"),
|
||||
pdfManager.ensureDoc("htmlForXfa"),
|
||||
]);
|
||||
|
||||
if (htmlForXfa) {
|
||||
const isPureXfa = await pdfManager.ensureDoc("isPureXfa");
|
||||
if (isPureXfa) {
|
||||
const task = new WorkerTask("loadXfaFonts");
|
||||
startWorkerTask(task);
|
||||
await pdfManager
|
||||
|
@ -203,6 +198,17 @@ class WorkerMessageHandler {
|
|||
})
|
||||
.then(() => finishWorkerTask(task));
|
||||
}
|
||||
|
||||
const [numPages, fingerprint] = await Promise.all([
|
||||
pdfManager.ensureDoc("numPages"),
|
||||
pdfManager.ensureDoc("fingerprint"),
|
||||
]);
|
||||
|
||||
// Get htmlForXfa after numPages to avoid to create HTML twice.
|
||||
const htmlForXfa = isPureXfa
|
||||
? await pdfManager.ensureDoc("htmlForXfa")
|
||||
: null;
|
||||
|
||||
return { numPages, fingerprint, htmlForXfa };
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue