File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -346,15 +346,15 @@ function parsePptxPresentation(xml: string): {
346346 const sldIdLst = between ( xml , '<p:sldIdLst>' , '</p:sldIdLst>' )
347347 const slideCount = ( sldIdLst . match ( / < p : s l d I d \b / g) ?? [ ] ) . length
348348
349- // Slide size in EMU — 1 inch = 914400 EMU
350- const sldSzMatch = / < p : s l d S z \b [ ^ > ] * \b c x = " ( \d + ) " [ ^ > ] * \b c y = " ( \d + ) " / . exec ( xml )
349+ // Slide size in EMU — 1 inch = 914400 EMU. Capture cx/cy independently so
350+ // attribute order (LibreOffice/Google Slides may write cy before cx) doesn't matter.
351+ const cxMatch = / < p : s l d S z \b [ ^ > ] * \b c x = " ( \d + ) " / . exec ( xml )
352+ const cyMatch = / < p : s l d S z \b [ ^ > ] * \b c y = " ( \d + ) " / . exec ( xml )
351353 let aspectRatio : '16:9' | '4:3' | 'custom' = 'custom'
352- if ( sldSzMatch ) {
353- const cx = Number . parseInt ( sldSzMatch [ 1 ] )
354- const cy = Number . parseInt ( sldSzMatch [ 2 ] )
354+ if ( cxMatch && cyMatch ) {
355+ const cx = Number . parseInt ( cxMatch [ 1 ] )
356+ const cy = Number . parseInt ( cyMatch [ 1 ] )
355357 const ratio = cx / cy
356- // 16:9 ≈ 1.7778 (covers both 9144000×5143500 and 12192000×6858000)
357- // 4:3 ≈ 1.3333 (9144000×6858000 or 10×7.5 inches)
358358 if ( Math . abs ( ratio - 16 / 9 ) < 0.01 ) aspectRatio = '16:9'
359359 else if ( Math . abs ( ratio - 4 / 3 ) < 0.01 ) aspectRatio = '4:3'
360360 }
You can’t perform that action at this time.
0 commit comments