Closed montanhes closed 1 year ago
I was able to solve this. I used this function to get the picture:
const shareImage = async () => {
if (snapshotViewRef.current !== null && snapshotViewRef.current.capture) {
try {
const uri = await snapshotViewRef.current.capture();
shareReceiptImage(uri, card.code);
} catch (error) {
console.log('error:',error)
}
}
};
<ViewShot ref={snapshotViewRef} options={{ fileName: 'ficha', format: "png", quality: 1 }} style={{position: 'absolute', left: -1700}}>
<AutoHeightWebView
onSizeUpdated={size => console.log(size)}
originWhitelist={['*']}
setBuiltInZoomControls={false}
showsHorizontalScrollIndicatorarrow_up={false}
source={{html: receipt}}
style={{margin: 10}}
scalesPageToFit={true}
/>
</ViewShot>
Also I used the react-native-autoheight-webview
to set the auto height and used the offscreen approach described on the docs.
I'm trying to capture a screen that can have a bigger height, so I'm need to put this offscreen. Also I'm using imperative CaptureRef.
I have a modal, inside this modal I have a webview that display what I need to capture as an image. I was able to archive this but the image always share missing some part of the view because of the scroll.
So I found the offscreen example and tried to use it without success.
I always get the
Oops, snapshot failed [Error: Failed to capture view snapshot]
when I try to generate the image using this method.Can someone help?
Version & Platform
Platform: Android only
Expected behavior : allow me to share the offscreen component
Actual behavior: Oops, snapshot failed [Error: Failed to capture view snapshot]
Steps to reproduce the behavior
Function that is attached on the button on the modal:
Modal with the view to user check it before share the image or a PDF: