AnnotationLayer links misaligned
See original GitHub issueBefore you start - checklist
- I followed instructions in documentation written for my React-PDF version
- I have checked if this bug is not already reported
- I have checked if an issue is not listed in Known issues
- If I have a problem with PDF rendering, I checked if my PDF renders properly in PDF.js demo
Description
The links contained in my pdf file are misaligned while using the react-pdf. I can see a bright yellow box and a cursor pointer indicating the link but it’s out of place (I tried showing it on a screenshot below)
Steps to reproduce
Create a NextJs project Copy the code below Attach a pdf file
Expected behavior
Annotations to be aligned with hyperlink text
Actual behavior
Annotations being misaligned
Additional information
My code is as follows:
import { Document, DocumentProps, Page, pdfjs } from "react-pdf";
import "react-pdf/dist/esm/Page/AnnotationLayer.css";
pdfjs.GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.min.js`;
interface galleryProps {
isOpen: boolean;
handleClose: () => void;
}
const options = {
cMapUrl: "cmaps/",
cMapPacked: true,
standardFontDataUrl: "standard_fonts/",
};
type LoadCallback = Required<DocumentProps>["onLoadSuccess"];
const [numPages, setNumPages] = useState(0);
const [pageNumber, setPageNumber] = useState(1);
const onLoad: LoadCallback = useCallback((pdf) => {
setNumPages(pdf.numPages);
}, []);
const handleNextPage = () => {
pageNumber < 2
? setPageNumber(pageNumber + 1)
: setPageNumber(pageNumber - 1);
};
const setDefaultPage = () => {
setTimeout(() => setPageNumber(1), 500);
};
const handlers = useSwipeable({
onSwipedDown: () => handleNextPage(),
onSwipedUp: () => handleNextPage(),
});
return (
<section
className={`${styles.container} ${isOpen && styles.open}`}
onWheel={handleNextPage}
{...handlers}
>
<button
className={styles["close-btn"]}
aria-label="close-cv-gallery"
onClick={() => {
handleClose();
setDefaultPage();
}}
>
<CloseIcon fontSize="large" className={styles.icon} />
</button>
<Document
file="/CV/mm-cv.pdf"
onLoadSuccess={onLoad}
externalLinkTarget="_blank"
options={options}
className={styles.document}
>
<Page
pageNumber={pageNumber}
renderAnnotationLayer={true}
renderTextLayer={false}
/>
<button
onClick={handleNextPage}
aria-label="cv-next-page"
type="button"
className={styles["next-btn"]}
>
<ArrowCircleDownOutlinedIcon
fontSize="large"
className={styles.icon}
/>
</button>
</Document>
<p>
Page {pageNumber} of {numPages}
</p>
</section>
);
}
Environment
- Browser (if applicable): Brave v1.43 (Chromium 105)
- React-PDF version: 5.7.2
- React version: 18.2
- **NextJS 12.2
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:6 (1 by maintainers)
Top Results From Across the Web
How to left align text in annotate from ggplot2 - Stack Overflow
In ggplot2 , these arguments are present any time text preferences are set. They work for annotate , geom_text , or in element_text...
Read more >Why is object appearing in wrong position in section VP?
But in section it seems to be misaligned by 1mm in each ... but in the annotation layer it will produce a dimension...
Read more >forScore 11.2 User Guide
Links : Create links between two pages of the current score to quickly handle ... Each page has a single annotation layer by...
Read more >OntoTag - CORE
4.3.1.3.1 Annotations at the Concept Semantic Annotation Layer . ... Sub-goal 1.5: Ontological formalisation of the knowledge required to link, ...
Read more >Computing EM-based Alignments of Routes and Route ...
tion rules using a special link function. ... semantic annotation layer given an attribute a of ... misaligned with frame elements containing pro-....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
try to upgrade to version 6 but I got this building problem: #1043
manually import the css and set
externalLinkTarget
to_blank
can also fix this in v5.7.2Check out 6.0.0 beta - rendering these layers were completely revamped in this version.