Describe the bug
When I go to PDF file on my Android device, that doesn’t display the annotations with error “Unable to find DocumentView” from function setVisibilityForAnnotation.
On iOS that works well.
The code
I don’t think it’s in link with the code because that works well on iOS
const MyPdfViewer = ({expanded, file, setOpenIssue, isIssues, filters, onPressDocument}: IPdfViewer) => {
const pdfTronRef = useRefany()
const user = useAppSelector(selectUser)
const {issues, forms} = useAppSelector(selectRootFilters)
const annotationsIds = [...file.issues.map(i => i.key), ...file.forms?.map(i => i.key)]
useEffect(() => {
RNPdftron.initialize('LicenseKey')
RNPdftron.enableJavaScript(true)
}, [])
function init() {
if (issues && forms && annotationsIds) {
console.log(pdfTronRef)
setVisiblityOfAnnotations(isIssues, issues, forms, pdfTronRef, filters, annotationsIds)
}
}
useEffect(() => {
init()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isIssues, issues, forms])
async function getCoords(x: number, y: number) {
const coords = await pdfTronRef.current.convertScreenPointsToPagePoints([{x, y}])
const page = (await pdfTronRef.current.getPageNumberFromScreenPoint(coords[0].x, coords[0].y)) + 1
const rotate = await pdfTronRef.current.getPageRotation()
onPressDocument({x: coords[0].x, y: coords[0].y}, page, rotate)
}
return (
<Styled.Container
onPress={e => {
getCoords(e.nativeEvent.locationX, e.nativeEvent.locationY)
}}
expanded={expanded}>
{!!file.uri && (
<DocumentView
followSystemDarkMode={false}
onDocumentLoaded={() => {
onDocumentLoaded([], file, issues, forms, pdfTronRef)
}}
onAnnotationsSelected={(item: any) => onAnnotationsSelected(item, setOpenIssue)}
onAnnotationChanged={({annotations}: any) => {
annotations.forEach((annotation: any) => {
user && uploadModificationOnAnnotation(annotation, pdfTronRef?.current?.exportAnnotations, file.source, user.uid)
})
}}
ref={pdfTronRef}
document={file.uri}
/>
)}
/Styled.Container
)
}
export default MyPdfViewer
Expected behavior
I want to see the annotations that I imported
Platform/Device Information (please complete the following information if applicable):
• Platform: Android with React Native
• Device: HUAWAI AGS-W09