How to make nice pdf out of jupyter file? - pdf

I am supposed to create pdf documents that contain math expression and graph images.
Until now my work flow was using matlab to draw the plots, export them into jpg, put them into OpenOffice / Word document describe how I get those plots trough math equations and finally export to pdf.
Recently I have found julia ( replacement for matlab ) and jupyter ( replacement for Word ).
Jupyter is awesome but the export to PDF is lacking some features :
Hide code cell. ( I don't want to show the code I used to generate those graphs. )
Hide output of code cell. ( I don't want to show output of using Plots; plotlyjs() )
Hide the IN [...] and OUT [...] annotations.
Increase space size between lines.
I hope there is some easy way to do this. Otherwise I will have to go back to Word and Matlab.
Thank you!

You might want to consider investing some time learning how to use the nbconvert tool that comes with jupyter notebook. It supports multiple output formats including PDF and also supports custom templates. For example see this older post for an example of hiding code input and only showing output.

Related

Using a Pre-Made PDF for jsPDF

I am using jsPDF to build my PDFs in my Quasar/Electron app. I have PDFs that I need to use as the base for the output, and I would love to be able to use that instead of building the whole PDF line by line. Does anyone know if this is possible?
This is an example of the PDF I need to use:
Score Sheet
I need to fill in the various details such as Call Name, Breed, etc. I'm not sure if it's possible to specify the exact position of the data while using the pre-made PDF.
Thanks for help!

Export Jupyter Notebook to PDF With Same Markdown Rendering

Problem
My notebook is solely Markdown and I would like to export it to a PDF with the same Markdown rendering that JupyterLab displays. However, the regular PDF export converts it to LaTex and then to a PDF and it looks nothing like how I want it formatted. I would rather not have to manually edit a Tex file every time I want to export a notebook to a PDF, especially since it is very time-consuming for large files.
Exporting to WebPDF looks much closer to the result I desire, however, the page size is all over the place and I would like it to be Letter size (8.5 x 11 inches).
Question
How can I control the page size on the WebPDF export?
Bonus Question
Is it possible to get the PDF to look the way it does on JupyterLab Markdown rendering, including the dark theme? (printing the page to PDF does a terrible job and makes all the text an image)
Okay, I am a little confused by the question, but I will do my best to answer this.
First, I would like to introduce you to pandoc. Pandoc is a document conversion system. This will let you control how your markdown is converted into a pdf or any other desired format that pandoc converts to. For additional formatting control, pandoc has support for templates. Which will allow you to customize exactly how that document is treated on export.
Now to address your page size question. I do not think that you can control this from markdown alone, however you can if you use pandoc. This can be done by adding some LaTeX code into your markdown file. You can find the information on how to control page size using LaTeX here. Once you add this LaTeX code, you can convert to pdf using pandoc and a pandoc template. Pandoc provides a number of default templates which will work fine. Here is an example of the command used to do this conversion:
pandoc /filepath/doc_name.md -o doc_name.pdf --template /file_path/pandoc-templates/default.latex
Bonus question:
You can make a custom pandoc template to replicate any formatting and rendering that is done in JupyterLab Markdown. I am not too familiar with JuypterLabs, but making pandoc templates is not too bad and pandoc provides great documentation available here.

Write latex comments on any pdf file with option to toggle comments on and off

I am looking to take a .pdf file (for example an Arxiv paper), and add math comments using Latex / Markdown synatx onto the pdf with the option to toggle the comments on and off.
More precisely, consider for example this pdf file http://wwwf.imperial.ac.uk/~pavl/stoch_proc_notes-ch1-3.pdf . Suppose on page 15 of the document I want to add a note to Example 2.21. More specifically i want to add the following math comment (using latex)
$f_X(x) \in \mathbb{E}$ beside the equation in colored text.
If this comment was not mathematical (i.e. just text) , I would be able to easily add it using a pdf reader such as Preview or Adobe acrobatic reader. However, I see no option as to how one can easily add math comments to pdfs.
Furthermore, both preview and acrobat have features where one can toggle the view of all the comments added to the pdf on and off, (which would be very useful when reading).
For complex math formulas you cannot generally use simple text based annotation/comments. In your requested example the top two comments were added by readers as plain text and the conversion is problematic since annotation often has poor support for math unless a few more common/basic symbols like Greek letters.
Plain LaTeX notes would need the PDF to be overstamped
However Editor level viewers can easily add stamped Mathematical PDF rendering such as this using Tracker PDF XChange, given the correct input (the stamp was produced compliments of https://latex.codecogs.com/). and you should be able to scale /colour this snippet as SVG or produce PNG / PDF for insertion or cut and paste to typewriter or if more complex then stamp as an image.
<body><img src="https://latex.codecogs.com/svg.image?\inline&space;f_X(x)&space;\in&space;\mathbb{E}" title="\inline f_X(x) \in \mathbb{E}" />​</body>

White gradient artifacts left over after converting an SVG file to PDF

I have an SVG file of a bar plot that I need to convert to a PDF. The bar plot was made in matplotlib, saved as a PDF and imported into Inkscape. I used Inkscape to add annotations to the figure and then export it back to a PDF to be used in a final document.
This is what the PDF file looks like going into Inkscape
After adding text elsewhere on the figure and saving as a PDF I get the same plot with these white lines:
These are not your typical PDF render artifacts, rather a closer inspection shows that they have a gradient to them.
I think this is somehow a product of the SVG file. I have used an online SVG-to-PDF converter and the lines are still present. Additionally, I use this method to make all my figure, Matplotlib to Inkscape to PDF and I have not had this issue with any other figures.
I've found that Inkscape does this when you import a bar graph which has a shading type that is not the same as any of the preset Inkscape patterns. I've seen this exact issue when I've imported graphs from R programing language and excel so I don't think it's specific to Matplotlib. I don't know the root cause, however, since I experience this problem a lot I'll share the workaround options I typically employ when I get this issue. One is not necessarily better than another and it depends on the situation which I use.
Option 1) Convert the PDF to a .png bitmap image in some other program, (Gimp, Photoshop, Powerpoint....) then embed the image in Inkscape. Make your changes then export from Inkscape as a PDF. This has the disadvantage that the graph will no longer be a vector map. Use option 2 or 3 to keep it a vector map.
Option 2) Import the pdf into Inkscape, ungroup the pdf object, delete the stripped filling in the bar graph, then recreate the filling using an Inkscape made fill. In the worst cases I've actually made custom bar graph patterns in Inkscape to exactly match the pattern that I had before. This process is a pain.
Option 3) Create shapes that cover over the artifacts, remove border lines from the shapes and use the eye dropper to make them exactly the same color as the good parts.
Like I said these are not an academic understanding of the problem to avoid the problem but I hope it can help you accomplish your task.

Best way to generate a custom document?

I am working on generating a document for printing. It should use a specific TTF font and everything must be printed with vector graphics (for quality). Some of the text should be replaced automatically (e.g. current time). Also it should include a custom-generated EPS image with a chart.
Ideally I would like to have some kind of document template where the text could be replaced easily, and it would be nice if it could import the image through path. But I am not sure which format could be good for this. Best I can come to think of is LaTeX, but I don't like that it's a lot of manual work to use it with TTF... any other ideas?
By the way, I am using OS X...
Memoir package is very flexible for your special layouts.
Xetex uses your system fonts (Installed together with TexLive).
You could blend most of those elements to an EPS using imagemagick or gimp script-fu
There are several products out there that will build you a PDF programmatically. I've only used the Coldfusion Report Builder myself and that may not be practical/affordable for your application. If your budget allows I'd look into a commercial reporting product. I know Adobe have several that will generate Flash, FlashPaper or PDF output.