abdullahkhalids / qecft

The book A Methods Focused Guide to Quantum Error Correction and Fault-Tolerant Quantum Computation
Other
17 stars 7 forks source link

Script to convert book to pdf #4

Closed abdullahkhalids closed 1 year ago

abdullahkhalids commented 1 year ago

Currently the book is not available as a pdf. Some people would like to read it in this form.

To this end, we need a python script which does the following.

Based on my research WeasyPrint seems to be a library that can do this. But I am open to alternate suggestions that work on Debian linux.

If you are interested in this issue, please comment below and I will assign you to it.

MZuhairKhan commented 1 year ago

Hey Abdullah! I would like to give it a try. However, I have a quick question. We should be converting a bunch of jupyter notebooks, right? As such, I think https://jupyterbook.org/en/stable/intro.html might be a better way to proceed. As a windows user, I am unsure if this will work on Debian linux, but I will try to make sure that it does.

abdullahkhalids commented 1 year ago

@MZuhairKhan Thanks for signing up.

Jupyterbook might be overkill, but I see on https://jupyterbook.org/en/stable/advanced/pdf.html that they are using pyppeteer to convert the html of the book to pdf. Would it be better to use pyppeteer directly?

The other method Jupyterbook uses is Latex (via Sphinx). I don't like this option because I don't see ways of customizing the look of the pdf. In the first option above, one can add custom css to change the look at will. Tell me if I am wrong.

Should I assign you to this issue?

MZuhairKhan commented 1 year ago

This is my first contribution to open source ever and I would be grateful to attemp this. I will look into the specific package they imported, as I too felt that jupyternotebooks might be too specific.

abdullahkhalids commented 1 year ago

Perfect. I have assigned you to the issue. If you have any questions or just get stuck, just let me know here.

MZuhairKhan commented 1 year ago

I did have one question. Is information lost when converting from ipynb to say md or html? Would you recommend going directly from ipynb to pdf or should I use another format in between? I have a feeling that changing to md allows me to combine the many parts of the chapters together to help them flow together.

abdullahkhalids commented 1 year ago

No information is lost when going from ipynb to md or html.

I already have a script for converting to html (see the make file). I think its best if we take that html and convert it to pdf. We can then add some more css changes on top of it appropriate for the book (such as hiding the sidebar and topbar).

AbdullahKazi500 commented 1 year ago

Hi @MZuhairKhan and @abdullahkhalids I wanted to work on this as well how can I Collab or proceed

abdullahkhalids commented 1 year ago

@AbdullahKazi500 I don't think this is a two person job. That said if the assigned person needs help, they know how to find you.

MZuhairKhan commented 1 year ago

@abdullahkhalids Where are the html files stored after we run bookcreater.py? Running it locally seems to create only a build subdirectory with an empty intro.html.

abdullahkhalids commented 1 year ago

All html files should end up in the build subdirectory. I have made minor changes and added additional details to the readme and bookcreator.py. Please pull the repo and rerun build steps.

To debug this, can you quickly start a new issue and answer the following questions.

robotAstray commented 1 year ago

Hello, I would like to attempt resolving this issue as well. Am I allowed to? I was reading the rules for unitaryHack and from what I understand anybody is allowed to work on something? https://unitaryhack.dev/rules/ and also the rules/guidelines on discord. Thank you

robotAstray commented 1 year ago

if not, no problem!

abdullahkhalids commented 1 year ago

@robotAstray Yes, those are indeed the rules. If you resolve the issue with a PR first, I will assign the issue/bounty to you.

robotAstray commented 1 year ago

so just to re-iterate @abdullahkhalids you would like to go from .ipynb to pdf ? Do we use the output of bookcreator.py to write a new script and obtain a pdf? Or can we modify bookcreator.py to add the steps to also output the pdf?

abdullahkhalids commented 1 year ago

@robotAstray As mentioned above, we go from html to pdf. So please build the book as specified in the readme. Then convert it to pdf. Please read the thread above to understand requirements for this.

schance995 commented 1 year ago

Hello @abdullahkhalids , I have been developing my solution to this request. I would like to share a PDF draft of the book here: https://drive.google.com/file/d/117kk0xe_mP9d45Bnfk_SXpqmq54Pa8os/view

The book has the following:

There are some optional features that could be added later:

I would appreciate your feedback on the quality of the draft PDF. If is good enough, I can make a PR with the code to generate the book.

abdullahkhalids commented 1 year ago

@schance995 Thanks for the building this. Its a good start, and perhaps can be improved to a usable point. Please do open the PR, so we can look at the build process and see if it is something that can be improved upon.