cms icon indicating copy to clipboard operation
cms copied to clipboard

Notes not getting downloaded

Open hkirat opened this issue 1 year ago • 10 comments

Clicking on the download button opens a new tab but nothing downloads Tried in chrome

hkirat avatar Apr 06 '24 13:04 hkirat

@hkirat the problem is it works on local setup. Cant really figure out what is going wrong 😞

devsargam avatar Apr 06 '24 13:04 devsargam

hmm got it

hkirat avatar Apr 06 '24 13:04 hkirat

Will try to check what might be going wrong in prod, as it was working fine locally

nimit9 avatar Apr 06 '24 16:04 nimit9

@hkirat upon reading about the issue, I figured out that relative path fails to download file in production. You need to provide the absolute url of the notion doc. On changing the <Link href={/pdf/${id}} target="_blank"> to <Link href={${notion_doc_url} target="_blank"}> in the NotionRenderer.tsx should solve the issue in production.

dyaipayan22 avatar Apr 06 '24 19:04 dyaipayan22

The application currently utilizes an external link to facilitate the downloading of content as a PDF. This method requires users to navigate away from the app, potentially leading to a disjointed user experience and may be causing the issue as @dyaipayan22 suggested

I propose implementing an in-app PDF generation and download feature using react-to-print. This solution involves: Using useRef to directly reference the content that needs to be printed. Employing useReactToPrint for on-the-fly PDF generation and download, triggered by a button within the app. I have implemented the solution locally

image

Keeps users within the app, streamlining the process of converting content into a PDF.

neeshant-pandey avatar Apr 06 '24 21:04 neeshant-pandey

Hey I have implemented the following as well, can I raise a PR @hkirat. @neeshant-pandey if you are not raising I will do it. Thanks

https://github.com/code100x/cms/assets/55043383/2d084854-50f3-45c4-a45c-a62f6fe375d1

Neon-20 avatar Apr 08 '24 09:04 Neon-20

Hi @Neon-20 I am raising a PR. Thanks!

neeshant-pandey avatar Apr 08 '24 09:04 neeshant-pandey

Sure Go Ahead @neeshant-pandey

Neon-20 avatar Apr 08 '24 09:04 Neon-20

@hkirat @devsargam notes get download in mozilla. Also on local chrome issue is replicated. https://stackoverflow.com/questions/6460630/close-window-automatically-after-printing-dialog-closes This explains the reason. Adding a pr with fix

mumin-khan avatar Apr 19 '24 11:04 mumin-khan

The reason the issue was not found in local is most likely because the note is small and hence the function works before closing. https://app.100xdevs.com/courses/3/234/258 Try this in chrome, it also get downloaded in production.

mumin-khan avatar Apr 20 '24 05:04 mumin-khan

seems like this is fixed now?

hkirat avatar May 12 '24 21:05 hkirat