#I want to convert it to pdf

1 messages ยท Page 1 of 1 (latest)

dark grail
#

You can easily convert that to markdown, each chapter title/subchapter having its own heading level and adding pagebreaks after each subchapter/chapter

#

You can iterate through it and create a string

#

I'm assuming you already know markdown?

#

Anyways, there are python libraries that can take markdown and convert it into PDFs

meager niche
#

I am out rn. Actually, I made this when I was at home on my pc a few hrs ago. We had to go to someone's wedding today, so I cannot do it. Can you help me?

#

And yk, pydroid3 is shit

#

Can only be used to run codes

dark grail
#

for future tasks you can use termux and edit the code in any editor you'd like, but termux allows you to have a whole command line

#

packages and stuff

#

handy

meager niche
#

Yeha. But i was getting errors downloading pip packages

dark grail
#

with termux?

meager niche
#

Yeah

dark grail
#

that's weird...

meager niche
#

Ik.

dark grail
#

And you don't even need a library to convert to PDFs

#

Some sites do that

#

so all you need to do

#

is add a neat little hashtag behind chapter titles

#

and some newlines

meager niche
#

From json to pdf?

dark grail
#

yep

meager niche
#

Hmm

#

I'll find out

#

Thanks man for the suggestion

#

You want source code?

#

@dark grail

dark grail
#

of?

meager niche
#

The program and the prompts to make the book

#

Using Gemini pro

dark grail
#

No it's fine ๐Ÿ˜„

meager niche
#

๐Ÿ˜€

#

Bye

dark grail
#

Oh, we're done {?}

#

I have more to say @meager niche ๐Ÿ˜”

meager niche
#

Sure. Go on

#

@dark grail

dark grail
#

Yes give me a sec I need to drink water

#

dry throat

meager niche
#

Lol

dark grail
#

But yes I'm back

#

So this book, you didn't do it through makersuite or bard?

#

You made a whole program for it?

#

You there @meager niche ?

#

Well that's a shame, I was just stalling ๐Ÿ˜”

#
import json

book : list[dict[str,str]] = json.load(open("The Train Of Lost Souls.json", 'r'))

output = "# The Train Of Lost Souls\n\n### By @emperorayush\n\n<div style=\"page-break-after: always\"></div>\n\n"


for chapter in book:
    title = chapter["chapter_title"]
    subchapters : list[dict[str,str]] = chapter["subchapters"]
    output+=f"## {title}\n\n"
    for subchapter in subchapters:
        subchapter_title = subchapter["subchapter"]
        subchapter_content = subchapter["content"]
        
        output+=f"### {subchapter_title} \n\n {subchapter_content} \n\n"
    output+="<div style=\"page-break-after: always\"></div>\n\n"

print(output)```
#

To convert the output markdown I just went to a markdown render site, https://md2pdf.netlify.app/ which opens the Print dialogue - allows you to save as PDF, just hide the footers and headers

#

enjoy ๐Ÿ˜„