React-pdf: Image elements returns "skipped due to invalid dimensions"

Created on 3 Apr 2019  路  5Comments  路  Source: diegomura/react-pdf

Describe the bug
Image component seems to be broken. I tried many ways to render image in pdf but it always returns "Image with src [...] skipped due to invalid dimensions". Even if I used an image from examples folder https://blog.oxforddictionaries.com/wp-content/uploads/mountain-names.jpg. I tried local files, base64, external files. Did I do something wrong?

To Reproduce
Here is a codesandbox with simplest example: https://codesandbox.io/s/yjpk4nkk61

Most helpful comment

Old issue,but :) ,

<View style={{flexDirection:'row'}}>
  <View style={{flex:1}}>
      <Image
        style={{
          width:'auto'}}
        src="/static/images/quijote1.jpg"
      />
  </View>
  <View style={{flex:1}}>
      <Image
        style={{
          width:'auto'}}
        src="/static/images/quijote1.jpg"
      />
  </View>
</View>

works. Just set width:'auto' on image as its not default here @diegomura

All 5 comments

I figured it out. It was caused by StyleSheet style but this error is misleading as hell. Just removed flexDirection and flexGrow and now it's works as expected.

Does that mean we cannot use flex box in any of its ancestors?

Not necessarily, but there are some cases in which flexbox will cause issues on images. I couldn't still get exactly in which cases this happens

Old issue,but :) ,

<View style={{flexDirection:'row'}}>
  <View style={{flex:1}}>
      <Image
        style={{
          width:'auto'}}
        src="/static/images/quijote1.jpg"
      />
  </View>
  <View style={{flex:1}}>
      <Image
        style={{
          width:'auto'}}
        src="/static/images/quijote1.jpg"
      />
  </View>
</View>

works. Just set width:'auto' on image as its not default here @diegomura

@0FilipK @lulalachen

Was this page helpful?
0 / 5 - 0 ratings