Skip to content

[frontend] Improve management of images when moving from HTML to PDF (#8207)#14715

Merged
lndrtrbn merged 1 commit intomasterfrom
issue/8207
Mar 4, 2026
Merged

[frontend] Improve management of images when moving from HTML to PDF (#8207)#14715
lndrtrbn merged 1 commit intomasterfrom
issue/8207

Conversation

@lndrtrbn
Copy link
Member

@lndrtrbn lndrtrbn commented Mar 2, 2026

Proposed changes

  • Improve images in figures management

Related issues

Checklist

  • I consider the submitted work as finished
  • I tested the code for its functionality
  • I wrote test cases for the relevant uses case (coverage and e2e)
  • I added/update the relevant documentation (either on github or on notion)
  • Where necessary I refactored code to improve the overall quality

@lndrtrbn lndrtrbn self-assigned this Mar 2, 2026
@lndrtrbn lndrtrbn added the filigran team use to identify PR from the Filigran team label Mar 2, 2026
@codecov
Copy link

codecov bot commented Mar 2, 2026

Codecov Report

❌ Patch coverage is 0% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 32.37%. Comparing base (f51114e) to head (22b48d9).
⚠️ Report is 9 commits behind head on master.

Files with missing lines Patch % Lines
...i-front/src/utils/htmlToPdf/utils/pdfImageWidth.ts 0.00% 8 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master   #14715   +/-   ##
=======================================
  Coverage   32.37%   32.37%           
=======================================
  Files        3098     3098           
  Lines      211019   211025    +6     
  Branches    38241    38243    +2     
=======================================
+ Hits        68310    68313    +3     
- Misses     142709   142712    +3     
Flag Coverage Δ
opencti-client-python 45.48% <ø> (ø)
opencti-front 2.83% <0.00%> (-0.01%) ⬇️
opencti-graphql 67.74% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@fellowseb fellowseb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a unit test to setImagesWidth so that your use cases are documented. (Or to htmlToPdf with a spy on htmlToPdfMake)
A better testing strategy for pdf generation like this would be too have an integration test but would be too large for this fix. Maybe we can do it when moving away from CKEditor to make sure we have no regression.

Comment on lines +29 to +32
let result = match;
result = result.replace(/ width="\d+"/, '');
result = result.replace(/ height="\d+"/, '');
return result.replace('<img ', `<img width="${widthInPixels}" `);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aspect-ratio-changing edits, with specific height values, are not possible in CKEditor ?

@lndrtrbn
Copy link
Member Author

lndrtrbn commented Mar 4, 2026

I will add the asked tests in an other PR

@lndrtrbn lndrtrbn merged commit 4a42577 into master Mar 4, 2026
36 checks passed
@lndrtrbn lndrtrbn deleted the issue/8207 branch March 4, 2026 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

filigran team use to identify PR from the Filigran team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants