PDF Generation Issue: Footer Images Not Rendering & "Buffer is not defined" Warning
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- react, typescript
Research direction
Start with pdfHeader.jsx and pdfFooter.jsx, then reproduce the deployed Netlify case using @react-pdf/renderer v4.3.0 while checking the reported console warnings. Compare the two image URLs and verify that the footer image renders in the deployed PDF without the reported warnings.
Written by the indexing model from the issue text.
Description
When generating a prescription PDF using @react-pdf/renderer, the footer image fails to render on the deployed Netlify environment, although the header image and a separate signature image (both loaded via URL) render correctly. Additionally, the console displays "Buffer is not defined" and "Not valid image extension" warnings.
The issue initially arose when deploying, as image assets loaded from the frontend's public folder failed to load, reporting "Buffer is not defined". Moving the image assets to the backend and providing direct URLs resolved the header and signature issues, but the footer image issue persists only on the deployed version.
Screenshots
LocalHost When Making pdf with images in the public folder(Header & Footer Visible)
Netlify when making pdf with images in the public folder(Both Header and Footer not Visible)
Local/Netlify when making pdf with images coming from backend(Header Visible but not Footer)
But the Image Path is correct when accessed in browser directly
Code for when Header is working fine but footer is not
// pdfHeader.jsx
import React from "react";
import { View, Text, Image } from "@react-pdf/renderer";
import { styles } from "../styles";
import { environmentUrls } from "../../../constants";
const PDFHeader = () => {
const HeaderImg = `${environmentUrls.file_url}/uploads/document-header.png`;
console.log("HeaderImg", HeaderImg);
return (
<View style={styles.header} fixed>
<View
style={{
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center",
padding: 10,
}}
>
{/* Logo or left content */}
<Image src={HeaderImg} style={styles.header} />
</View>
</View>
);
};
export default PDFHeader;
//pdfFooter.jsx
import { Image, View } from "@react-pdf/renderer";
import { styles } from "../styles";
import { environmentUrls } from "../../../constants";
const PDFFooter = () => {
const FooterImg = `${environmentUrls.file_url}/uploads/document-footer.png`;
console.log("FooterImg", FooterImg);
return (
<View style={styles.footer} fixed>
<Image src={FooterImg} style={styles.footer} />
</View>
);
};
export default PDFFooter;
Also Styling is not an issue since FooterImg when replaced with header's link , renders successfully at the footer's place
PDF Library: @react-pdf/renderer v4.3.0
Browser: Google Chrome
Operating System (Dev): Linux Ubuntu
Deployment: Netlify
- Dominant language
- TypeScript
- Stars
- 16.9k
- Forks
- 1.3k
- Avg merge
- 11m
- Merged PRs (30d)
- 2
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from diegomura/react-pdf
-
@react-pdf/font: published types import fontkit, but @types/fontkit is only a devDependencyPossibly taken @iliev-blnk claimed this 13 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Unable to set flexShrink to 0Possibly taken @adarshsm claimed this 12 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
@react-pdf/hyphenate: import-only exports map throws ERR_PACKAGE_PATH_NOT_EXPORTED in require-condition resolvers (every tsx script loading renderer >= 4.7 crashes)Possibly taken @cruzdanilo claimed this 42 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
diegomura/react-pdf#3551 · 2 reactions ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 48/100
diegomura/react-pdf#3606 · 3 reactions ·
Maintainers usually reply within 1 day
All issues in diegomura/react-pdf
Similar issues
-
area: infrastructure bug priority: low
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
snapotter-hq/SnapOtter#4575 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
documentation server-memory v2
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
modelcontextprotocol/servers#5457 ·
Maintainers usually reply within 1 day
-
comp: ssr comp: zones type: feature version: current (v17+)
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
angular/angularfire#3836 ·
Maintainers usually reply within 3 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day