diegomura / diegomura/react-pdf

Opening a PDF in a Blob Instead of a PDF Preview Component

Open
#2,809 0 comments 1 reaction 0 assignees View on GitHub
new feature
Dominant language
TypeScript
Stars
16.8k
Forks
1.3k
Avg merge
5h 6m
Merged PRs (30d)
52

Description

I'm currently using **BlobProvider** to open a PDF document in a new tab as a blob. Here’s the code snippet I’m using:
`
}>
{({ url, ...rest }) => {
return (



);
}}

`

but now I want to open the pdf from link after getting data from link, and open it in blob not in pdfPreview component like the example bellow:

`
const OrderReceipt = () => {
const { orderId } = useParams()
const { user } = useAuthContext()
const token = user?.apikey?.token

const [orderData, setOrderData] = useState();
const [isLoading, setIsLoading] = useState(false);
const [isError, setIsError] = useState(null);

const navigate = useNavigate()
useEffect(() => {
setIsLoading(true)
getFetch(token, /orders/${orderId})
.then((res) => {
setOrderData(res.data?.data)
})

.catch((e) => {
setIsError(e?.response?.data?.message)
toast({
variant: 'destructive',
description: e.response.data.message,
});
navigate('/')
})
.finally(() => setIsLoading(false))
}, [])

if (isLoading) {
return




}
if (isError) {
return

unexpected error



}

return

}

export default OrderReceipt

`

**What I Need:**
I would like to open the PDF in the current window as a blob after getting the data, instead of using the PDFViewer component. How can I achieve this?

**Additional Context:**
The goal is to replace the PDFViewer component with functionality that opens the PDF in the browser's current tab as a blob.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.