--- tags: GeneLab --- # Rendering markdown as pdf >Among other places, I found this path [here](https://gist.github.com/justincbagley/ec0a6334cc86e854715e459349ab1446), and ended up finding the way below to be the easiest. [toc] ## Install needed program in [conda](https://astrobiomike.github.io/unix/conda-intro) environment ```bash conda create -y -n grip python=3 conda activate grip pip install grip ``` Now we need the markdown file we want to turn into a pdf, **but we don't want to get the page that looks like this (if doing this to a page from github)**: <a href="https://i.imgur.com/7it0KyI.png"><img src="https://i.imgur.com/7it0KyI.png"></a> We want to click the "Raw" button to get to the plain text version, which will look something like this: <a href="https://i.imgur.com/k3ne8tb.png"><img src="https://i.imgur.com/k3ne8tb.png"></a> Then we want to get that file on our computer, so we can copy the link at the top of our browser and download it with `curl` like this example (if this particular example file still exists – if it doesn't because this is the future times, you will get a 404 error at the next step, but the process will work the same with your own): ``` curl -LO https://raw.githubusercontent.com/asaravia-butler/GeneLab_Data_Processing/master/Metagenomics/Illumina/GL-DPPD-7107.md ``` ## Render local html ```bash grip GL-DPPD-7107.md ``` Go to the link it prints out that it is serving it on, e.g. something like `localhost:6419/`. (I was working in a chrome browswer, so the images below match that) > **NOTE** > The example file used previously is gone, and was updated. So the pics below don't match the new example file above. But the concepts are the same. ## Remove anything we don't want, like the top part here Right-click and select "Inspect": <a href="https://i.imgur.com/7PUSI8M.png"><img src="https://i.imgur.com/7PUSI8M.png"></a> In the top-right box, select the elements we want to remove, hovering over them highlights them in the rendered html page, e.g.: <a href="https://i.imgur.com/AfLPWVM.png"><img src="https://i.imgur.com/AfLPWVM.png"></a> And hitting the `delete` key on our keyboard when that object is selected deletes it from this local rendering: <a href="https://i.imgur.com/GPRPwGH.png"><img src="https://i.imgur.com/GPRPwGH.png"></a> Get rid of everything wanted, here I did up to the Table of Contents, so this will start as page 2 and we'll add the cover page: <a href="https://i.imgur.com/25A8KW4.png"><img src="https://i.imgur.com/25A8KW4.png"></a> ## Saving as PDF Then right-click and select "Print..." (I have no idea why this is the standard way to save as a PDF): <a href="https://i.imgur.com/1xgCiRW.png"><img src="https://i.imgur.com/1xgCiRW.png"></a> Click on the "More settings" drop-down menu and make sure "Headers and footers" box is *not* checked, and that the "Background graphics" is checked: <a href="https://i.imgur.com/a2SwFXJ.png"><img src="https://i.imgur.com/a2SwFXJ.png"></a> I also found a "scale" setting that sometimes helps to get more text on the page width-wise, so mess with that if things are getting cut off more than we can trim down. Click save. The browser can now be closed and `ctrl+c` can be run on the command line to cancel the `grip` program. ## Adding front page (for GL-DPPDs) I saved Amanda's front page word doc as a template so we can easily modify it. Can be downloaded with this line: ```bash curl -L -o GL-protocol-pg-1-template.docx https://ndownloader.figshare.com/files/26031350 ``` I modified that in word and saved it as a PDF. Then I combined them into one PDF. I use Mac's Preview app to do this, by dragging the cover page thumbnail over to the full PDF doc: <a href="https://i.imgur.com/x182DJU.png"><img src="https://i.imgur.com/x182DJU.png"></a>