@@ -255,7 +255,7 @@ func ParseImportDetails(s string, u types.DisplayUnit) (*Import, error) {
255
255
return imp , nil
256
256
}
257
257
258
- func importImagePDFBytes (wr io.Writer , pageDim * types.Dim , imp * Import ) {
258
+ func importImagePDFBytes (wr io.Writer , pageDim * types.Dim , imgWidth , imgHeight float64 , imp * Import ) {
259
259
260
260
vpw := float64 (pageDim .Width )
261
261
vph := float64 (pageDim .Height )
@@ -270,14 +270,13 @@ func importImagePDFBytes(wr io.Writer, pageDim *types.Dim, imp *Import) {
270
270
return
271
271
}
272
272
273
- w , h := vpw , vph
274
273
if imp .DPI > 0 {
275
274
// NOTE: We could also set "UserUnit" in the page dict.
276
- w *= float64 (72 ) / float64 (imp .DPI )
277
- h *= float64 (72 ) / float64 (imp .DPI )
275
+ imgWidth *= float64 (72 ) / float64 (imp .DPI )
276
+ imgHeight *= float64 (72 ) / float64 (imp .DPI )
278
277
}
279
278
280
- bb := types .RectForDim (w , h )
279
+ bb := types .RectForDim (imgWidth , imgHeight )
281
280
ar := bb .AspectRatio ()
282
281
283
282
if imp .ScaleAbs {
@@ -362,7 +361,7 @@ func NewPagesForImage(xRefTable *model.XRefTable, r io.Reader, parentIndRef *typ
362
361
mediaBox := types .RectForDim (dim .Width , dim .Height )
363
362
364
363
var buf bytes.Buffer
365
- importImagePDFBytes (& buf , dim , imp )
364
+ importImagePDFBytes (& buf , dim , float64 ( imgRes . Width ), float64 ( imgRes . Height ), imp )
366
365
sd , err := xRefTable .NewStreamDictForBuf (buf .Bytes ())
367
366
if err != nil {
368
367
return nil , err
0 commit comments