@cyber-dash-tech/revela 0.4.3 → 0.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/pptx/export.ts +35 -1
- package/package.json +1 -1
package/lib/pptx/export.ts
CHANGED
|
@@ -24,6 +24,7 @@ import { pathToFileURL } from "url"
|
|
|
24
24
|
|
|
25
25
|
const CANVAS_W = 1920
|
|
26
26
|
const CANVAS_H = 1080
|
|
27
|
+
const MIN_PPTX_FONT_SIZE_PT = 6
|
|
27
28
|
const PPT_REL_NS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships"
|
|
28
29
|
const requireFromExportModule = createRequire(import.meta.url)
|
|
29
30
|
|
|
@@ -230,6 +231,39 @@ export async function inlineImageAssets(htmlContent: string, htmlFilePath: strin
|
|
|
230
231
|
return patched
|
|
231
232
|
}
|
|
232
233
|
|
|
234
|
+
export function enforceMinimumPptxFontSize(
|
|
235
|
+
pptxBytes: Uint8Array,
|
|
236
|
+
minFontSizePt = MIN_PPTX_FONT_SIZE_PT,
|
|
237
|
+
): Uint8Array {
|
|
238
|
+
const files = unzipSync(pptxBytes)
|
|
239
|
+
const minSz = Math.round(minFontSizePt * 100)
|
|
240
|
+
const textPropertyTags = ["a:rPr", "a:defRPr", "a:endParaRPr"]
|
|
241
|
+
|
|
242
|
+
for (const path of Object.keys(files)) {
|
|
243
|
+
if (!/^ppt\/slides\/slide\d+\.xml$/.test(path)) continue
|
|
244
|
+
|
|
245
|
+
const doc = parseXml(strFromU8(files[path]))
|
|
246
|
+
let changed = false
|
|
247
|
+
|
|
248
|
+
for (const tag of textPropertyTags) {
|
|
249
|
+
for (const node of Array.from(doc.getElementsByTagName(tag))) {
|
|
250
|
+
const raw = node.getAttribute("sz")
|
|
251
|
+
if (!raw) continue
|
|
252
|
+
|
|
253
|
+
const sz = Number(raw)
|
|
254
|
+
if (!Number.isFinite(sz) || sz >= minSz) continue
|
|
255
|
+
|
|
256
|
+
node.setAttribute("sz", String(minSz))
|
|
257
|
+
changed = true
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if (changed) files[path] = xmlToBytes(doc)
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
return zipSync(files)
|
|
265
|
+
}
|
|
266
|
+
|
|
233
267
|
async function localizeExternalImages(htmlContent: string, tmpDir: string): Promise<LocalizeExternalImagesResult> {
|
|
234
268
|
const uniqueUrls = new Set(
|
|
235
269
|
extractImageAssetRefsForPptx(htmlContent).filter((ref) => ref.startsWith("http://") || ref.startsWith("https://"))
|
|
@@ -512,7 +546,7 @@ async function exportSlidePptx(
|
|
|
512
546
|
|
|
513
547
|
return {
|
|
514
548
|
...slide,
|
|
515
|
-
bytes: Uint8Array.from(pptxBytes),
|
|
549
|
+
bytes: enforceMinimumPptxFontSize(Uint8Array.from(pptxBytes)),
|
|
516
550
|
}
|
|
517
551
|
} catch (error) {
|
|
518
552
|
throw formatSlideFailure(error, diagnostics.slice(diagStart ?? 0), slide)
|