Skip to content

Commit

Permalink
Merge pull request #25 from abzokhattab/fix-negative-top-padding-in-s…
Browse files Browse the repository at this point in the history
…ingle-pdf

Fix negative top padding in single pdfs
  • Loading branch information
Beamanator committed Apr 15, 2024
2 parents 261a3be + e637647 commit 6c4a5f6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/PageRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ function PageRenderer({index, style, data}: Props) {
*/
const pageHeight = calculatePageHeight(index);
const devicePixelRatio = getDevicePixelRatio(pageWidth, pageHeight);
const topPadding = numPages > 1 ? parseFloat(style.top as unknown as string) + PAGE_BORDER : (containerHeight - parseFloat(style.height as unknown as string)) / 2;
const parsedHeight = parseFloat(style.height as unknown as string);
const parsedTop = parseFloat(style.top as unknown as string);
const topPadding = numPages > 1 || parsedHeight > containerHeight ? parsedTop + PAGE_BORDER : (containerHeight - parsedHeight) / 2;
return (
<div style={{...styles.pageWrapper, ...style, top: `${topPadding}px`}}>
<Page
Expand Down

0 comments on commit 6c4a5f6

Please sign in to comment.