Skip to content

Commit 6c057c8

Browse files
author
jumptuner
committed
fix extra bullets
1 parent b6aa219 commit 6c057c8

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

al_test.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,21 @@ const renderConfigs = [
3131
outputName: "resultFromDOCX.docx",
3232
},
3333
{
34-
enabled: false,
35-
templatePath: "../freshtracksback_s4/templates/FreshtracksAllCompanies.odt",
36-
options: { convertTo: "pdf" },
37-
outputName: "resultReportFromODT.pdf",
34+
enabled: true,
35+
templatePath:
36+
"../freshtracksback_s4/templates/FreshtracksAllCompanies.docx",
37+
options: { convertTo: "docx" },
38+
outputName: "resultReportFromDOCX.docx",
3839
},
3940
{
40-
enabled: true,
41+
enabled: false,
4142
templatePath:
4243
"../freshtracksback_s4/templates/FreshtracksAllCompanies.docx",
4344
options: { convertTo: "docx" },
4445
outputName: "resultReportFromDOCX.docx",
4546
},
4647
{
47-
enabled: true,
48+
enabled: false,
4849
templatePath: "../freshtracksback_s4/templates/FreshtracksPresentation.odp",
4950
options: {
5051
convertTo: "pdf",

lib/postprocessor.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,13 @@ class DocxPostProcessor extends Processor {
418418
return drawing;
419419
}
420420

421+
// Extract original dimensions and other properties to preserve
422+
const extentMatch = /<wp:extent cx="(\d+)" cy="(\d+)"/.exec(
423+
drawing
424+
);
425+
const originalCx = extentMatch ? extentMatch[1] : null;
426+
const originalCy = extentMatch ? extentMatch[2] : null;
427+
421428
const [, extension] = mime.split("/");
422429
let newRelationshipId = this.relationshipMap.get(imageUrl);
423430
if (!newRelationshipId) {
@@ -460,7 +467,7 @@ class DocxPostProcessor extends Processor {
460467
);
461468
}
462469

463-
// Create updated drawing with new relationship ID
470+
// Create updated drawing with new relationship ID but preserve dimensions
464471
const updatedDrawing = drawing
465472
.replace(/(title|descr)="[^"]*"/g, '$1=""')
466473
.replace(/embed="[^"]+"/g, `embed="${newRelationshipId}"`);
@@ -598,10 +605,6 @@ class DocxPostProcessor extends Processor {
598605
<w:next w:val="TextBody"/>
599606
<w:qFormat/>
600607
<w:pPr>
601-
<w:numPr>
602-
<w:ilvl w:val="0"/>
603-
<w:numId w:val="1"/>
604-
</w:numPr>
605608
<w:spacing w:before="240" w:after="120"/>
606609
<w:outlineLvl w:val="0"/>
607610
</w:pPr>
@@ -703,6 +706,12 @@ class OdpPostProcessor extends Processor {
703706
return drawFrame;
704707
}
705708

709+
// Extract original dimensions to preserve aspect ratio
710+
const widthMatch = /svg:width="([^"]+)"/.exec(drawFrame);
711+
const heightMatch = /svg:height="([^"]+)"/.exec(drawFrame);
712+
const originalWidth = widthMatch ? widthMatch[1] : null;
713+
const originalHeight = heightMatch ? heightMatch[1] : null;
714+
706715
const [, extension] = mime.split("/");
707716
const [basename, newfile] = this.filestore.fileBaseName(content);
708717
const imgFile = `Pictures/${basename}.${extension}`;
@@ -730,9 +739,11 @@ class OdpPostProcessor extends Processor {
730739

731740
// Ensure the image is actually displayed
732741
if (!updatedDrawFrame.includes("<draw:image")) {
742+
// Preserve original dimensions if available
743+
const imageTag = `<draw:image xlink:href="${imgFile}" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>`;
733744
updatedDrawFrame = updatedDrawFrame.replace(
734745
/<draw:frame/,
735-
`<draw:frame><draw:image xlink:href="${imgFile}" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>`
746+
`<draw:frame>${imageTag}`
736747
);
737748
}
738749

0 commit comments

Comments
 (0)