dvargas92495 / SmartBlocks

Useful examples from developer community for Roam42 SmartBlocks
147 stars 7 forks source link

PDF & DOCX Export #209

Open mlava opened 3 years ago

mlava commented 3 years ago

βœ‚οΈ Copy of your #42SmartBlock from Roam

PDF - DOCX Export.zip

πŸ“‹ Describe the SmartBlock

This SmartBlock exports the current page as either PDF or DOCX format.

You can configure whether you want to include the linked references section from the bottom of the page.

It relies on @roamhacker's Roam42 conversion engine, using the Markdown flattening and Markdown to HTML functions.

Note: all the available scripts to convert html to pdf do so by creating an image and then printing that to pdf. This will mean your pdf is not searchable. I will be happy to update if/when someone smarter than me figures out how to export html to pdf without doing so via image.

Created to fulfil a bounty posted by Justin Shaffner and the linked references section by Owen Cyrulnik.

βœ… Describe any prerequisites or dependencies that are required for this SmartBlock

Roam 42 and roam/js.

πŸ“· Screenshot of your #42SmartBlock workflow/template from Roam

πŸ’‘ Additional Info

Loom video: https://www.loom.com/share/23a3e2f913cc4cb69aff548fe10a56a6

stevenhill1 commented 3 years ago

This is fantastically useful - thank you. I don't have the expertise, but would it be feasible to extend this using https://docverter.com/api/

migdur commented 3 years ago

Hi, sorry, pretty new to smartblocks here. Am I supposed to copy /paste the contents of PDF DOCX Export.zip into a block in a Smartblock workflow? This does not seem to work for me. Thanks for helping!

stevenhill1 commented 3 years ago

Hi, sorry, pretty new to smartblocks here. Am I supposed to copy /paste the contents of PDF DOCX Export.zip into a block in a Smartblock workflow? This does not seem to work for me. Thanks for helping!

You need to extract the json file from the zip archive and then import the file (PDF & DOCX Export.json) into your Roam database (choose 'import files' from the ... menu). This will add a new page to you Roam graph which has full instructions for set up.

mlava commented 3 years ago

@stevenhill1 Thanks, I am glad it's helpful. Will take a look at your link. And thanks for helping @migdur.

@migdur - did you get it working?

mlava commented 3 years ago

New version in first post.

Fixed: removal of trigger phrase before rendering of pdf/docx file.

migdur commented 3 years ago

@stevenhill1 Thanks, I am glad it's helpful. Will take a look at your link. And thanks for helping @migdur.

@migdur - did you get it working?

Yes I did - thanks!

lkonstan commented 3 years ago

This is great; would love it if it were somehow able to parse and output footnotes.

mottonew commented 3 years ago

This looks very useful. I've installed, fire the SB, but it just disappears without exporting anything. That goes for both the PDF and the DOCX formats. It looks like the Loom is on a PC and I'm on a Mac - would that affect the export? I'm using Roam on Chrome, which is set to export to /downloads after asking. I've tried turning off other jss in Roam but that doesn't make any difference. My other SBs are working fine. Thanks.

mlava commented 3 years ago

Did you uncomment the correct javascript imports in the roam/js block?

On Sat, 27 Feb 2021, 10:32 am mottonew, notifications@github.com wrote:

This looks very useful. I've installed, fire the SB, but it just disappears without exporting anything. That goes for both the PDF and the DOCX formats. It looks like the Loom is on a PC and I'm on a Mac - would that affect the export? I'm using Roam on Chrome, which is set to export to /downloads after asking. I've tried turning off other jss in Roam but that doesn't make any difference. My other SBs are working fine. Thanks.

β€” You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/roamhacker/SmartBlocks/issues/209#issuecomment-786949404, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABUKIPWQZUWFPWSXVRGG3BLTBAVQ3ANCNFSM4XWCLLAA .

ItsJamesWeiss commented 3 years ago

Hey, I'm having trouble with the Docx exportingβ€”they're blank when I try to open them. I'm on Mac btw.

mottonew commented 3 years ago

Yes, I uncommented all of them, removing the \

Where would the exported files go - to where the setting on Chrome tells them?

Thanks for getting to me so quickly

mlava commented 3 years ago

Yes. You should get a download appear at the bottom of the window. Other thing to do would be check downloads using ctrl-j.

On Sun, 28 Feb 2021, 9:21 am mottonew, notifications@github.com wrote:

Yes, I uncommented all of them, removing the \

Where would the exported files go - to where the setting on Chrome tells them?

Thanks for getting to me so quickly

β€” You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/roamhacker/SmartBlocks/issues/209#issuecomment-787196455, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABUKIPQ72PMOE7K5VIDKP7LTBFV53ANCNFSM4XWCLLAA .

mlava commented 3 years ago

@mottonew Could you send me a screenshot of your roam/js block please?

cobblepot1 commented 3 years ago

This is great! My docx export did not preserve indentation - everything was at root level. Is this intended?

mlava commented 3 years ago

Hi. Yes, the original request from the person who posted the bounty was to simplify (flatten) the markdown language for readability. It can be modified, but we did find it was hard to follow in docx without flattening. Mark

On Tue, Mar 2, 2021 at 1:29 PM cobblepot1 notifications@github.com wrote:

This is great! My docx export did not preserve indentation - everything was at root level. Is this intended?

β€” You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/roamhacker/SmartBlocks/issues/209#issuecomment-788528099, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABUKIPVX2YBQ4IAMBWO5QDLTBREPHANCNFSM4XWCLLAA .

RoamStack commented 3 years ago

Part of the SmartBlock trigger (jj) still shows up when I export to PDF (see first line in the attached example). When I export to .docx, the file is empty.

When installing the script, I didn't have to uncomment any line as they weren't commented: image

PDF (see jj in the first line): Export pages using Roam42.pdf

DOCX (completely empty): Export pages using Roam42.docx

mlava commented 3 years ago

Can you check which version of the script you're using? Current is 0.2

On Wed, Mar 3, 2021 at 10:41 PM RoamStack notifications@github.com wrote:

Part of the SmartBlock trigger (jj) still shows up when I export to PDF (see first line in the attached example). When I export to .docx, the file is empty.

When installing the script, I didn't have to uncomment any line as they weren't commented: [image: image] https://user-images.githubusercontent.com/77009918/109800536-94f65700-7c1d-11eb-814a-d7ee8a0ae7b4.png

PDF (see jj in the first line): Export pages using Roam42.pdf https://github.com/roamhacker/SmartBlocks/files/6075662/Export.pages.using.Roam42.pdf

DOCX (completely empty): Export pages using Roam42.docx https://github.com/roamhacker/SmartBlocks/files/6075663/Export.pages.using.Roam42.docx

β€” You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/roamhacker/SmartBlocks/issues/209#issuecomment-789653623, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABUKIPWSPVLXO5Q5WRWFLSLTBYN55ANCNFSM4XWCLLAA .

orkhan10 commented 3 years ago

For this page, which is rather short, Docx is empty, pdf is not. Roman Empire (1).docx Roman Empire (1).pdf

I have a longer page. PDF is empty but 50 pages long. Docx is also empty but only 1 page long.

CourseStock 1 Foundation (1).docx CourseStock 1 Foundation (4).pdf

And also is it possible to improve the image quality of pdf? It is actually a bit interesting. Blurry on 100% zoom but better when zoomed in.

100%: Screenshot 2021-03-06 at 13 22 30

Zoomed in: Screenshot 2021-03-06 at 13 22 46

mlava commented 3 years ago

@RoamStack Are you on Mac by any chance?

@orkhan10 appears to be on Mac and is having issues.

I wonder if it is an OS issue as I am using Windows and both pdf and docx are working perfectly, without the trigger phrase and no empty files.

stevenhill1 commented 3 years ago

@RoamStack Are you on Mac by any chance?

@orkhan10 appears to be on Mac and is having issues.

I wonder if it is an OS issue as I am using Windows and both pdf and docx are working perfectly, without the trigger phrase and no empty files.

Also works fine for me on Windows, but getting these problems on Safari on iOS

mlava commented 3 years ago

Ok, well that's interesting. I don't have a Mac or iphone so can't troubleshoot. Mark

On Sun, Mar 7, 2021 at 3:31 AM Steven notifications@github.com wrote:

@RoamStack https://github.com/RoamStack Are you on Mac by any chance?

@orkhan10 https://github.com/orkhan10 appears to be on Mac and is having issues.

I wonder if it is an OS issue as I am using Windows and both pdf and docx are working perfectly, without the trigger phrase and no empty files.

Also works fine for me on Windows, but getting these problems on Safari on iOS

β€” You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/roamhacker/SmartBlocks/issues/209#issuecomment-791983036, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABUKIPTEC6C4ODVP6SZCMWTTCJKG7ANCNFSM4XWCLLAA .

diegouriarte commented 3 years ago

Hi, in mi case it leaves jjdoc in exported document, and it doesn't recognizes Spanish characters image

ghost commented 3 years ago

Hi, in mi case it leaves jjdoc in exported document, and it doesn't recognizes Spanish characters image

Turkish characters either :(

sandeepkelvadi commented 3 years ago

image The trigger doesn't seem to do anything for me. I'm on Windows and using the Brave browser. Also tried on Chrome, but no luck. Is there something I'm missing. I followed the instructions in the configuration section.

zzzgithubzzz commented 3 years ago

Hi, This is a great utility. Is there a way to export the page along with all the images embedded within a page while exporting as pdf with this smartblock trigger? Vinod

jbnv commented 3 years ago

I have custom CSS in my graph for both light and dark mode. I usually work in dark mode, but I definitely don't want the dark mode exported to PDF. Is there a way around this?

Elwood4415 commented 3 years ago

This is a tremendous resource, but from time-to-time it quits working. Usually, restarting Roam gets it working again and if that doesn't then rebooting the computer does. But now it is not working at all. As far as I can tell, everything is still present. Any tips would be appreciated.

mlava commented 3 years ago

The DOCX version of this script is now available in the SmartBlocks store within Roam Research.

The required roam/js to allow it to work is below:

mlava commented 3 years ago

The PDF version of this script is now available in the SmartBlocks store within Roam Research.

The required roam/js to allow it to work is below: