Sphinx documentation: Include svg images in PDFs via latex - pdf

I'm doing an internship for an IT company which needs a document application for its firmware docs (md files).
The request was to maintain these md files and to convert them to rst format (I used pandoc). So now I have a configured Sphinx application with only rst files. The problem now is that some rst have links to SVG images, and I have to use the latex builder of Sphinx to convert them to PDFs.
I've searched around and I found this solution from 2 years ago, which was essentially what I was looking for: https://sites.google.com/site/nickfolse/home/sphinx-latexpdf-output-with-svg-images. I tried to implement it but I'm not an expert with GNU makefiles and I don't know if the current version of Sphinx allows it or if it is out there an easy workaround, so the thing didn't succeed.
Does someone have a viable solution for this?

At this time, SVG is still not supported. I work around it in Pyramid docs by exporting the original file (OmniGraffle) to both SVG and PNG.
In docs/narr/router.rst:
.. image:: ../_static/pyramid_request_processing.*
And we place images in docs/_static.
The HTML uses SVG and the PDF uses PNG.

There is available the Sphinx SVG to PDF converter extension to automatically convert from SVG to PDF.

Related

Is it possible to convert fabricjs svg output to pdf without rasterizing?

We are building a web app where the user can make a design by using fabric.js and at the end he should receive a pdf file with his work.
At first, we tried to use JSPDF because it was prefered to have a cliente-side solution. However by doing pdf.addImage(canvas.toDataURL(),...) we are rasterizing the design.
In second place, we tried server side solution using WKHTMLTOPDF, sending canvas.toSVG(), but there are some issues with fonts and shapes rendering.
The designs are complex as they can have text, shapes, images and svg.
We also tried INKSCAPE (inkscape --without-gui --export-pdf ...), MPDF and MUPDF without good results. IMAGEMAGICK is not a solution has it also rasterize the design.
The main goal is to get a vector pdf, where it's possible to increase size and where the elements of the design are selectable, and if possible that pdf should be ready to print (300 dpi and cmyk)
Yes its possible using TCPDF library.
Please check this ImageSVG api for more information for converting SVG to PDF.
https://tcpdf.org/examples/example_058/
Export the canvas to svg and use pdflib to make the pdf.
You can find an exemple here:https://www.pdflib.com/pdflib-cookbook/graphics/starter-svg/

PDF converter for HTML

I am searching for a product that converts HTML to PDF in VB. I have searched alot for the products, but most of them are very expensive or doesn't work very well. Can anyone suggest me of a good quality, working product?
Thanks
Try using mPDF. mPDF is a PHP class which generates PDF files from UTF-8 encoded HTML. Its free and works very good.
http://www.mpdf1.com/mpdf/index.php
See WKHTMLPDF.
I have checked quality and used this tool. This is the good one and Opensource. This is shell utility to convert html to pdf using the webkit rendering engine, and qt.
I use htmldoc
Don't know if it fits your definition of "works very well", but for me, it does the trick.
A different approach is to install a print-to-pdf printer driver (such as freepdf), and print from the browser.

How to read a pdf file by using HTML5?

I want to create html file by which i could read any PDF file by providing the source of that PDF file. How can i do this by using only html5?
For example i want read a pdf file which is available in C drive so scr="http://virdir/mypdf.pdf".
I want something like this.
You want to use the developing HTML 5 File API. Mozilla has a good explanation, and you can also refer directly to the spec.
Since PDF is a binary format, you will probably want to use FileReader.readAsBinaryString().
Parsing and rendering (e.g. to a canvas) a PDF in JavaScript is possible, but it would be very challenging.
Here is an open source pdf reader written in javascript.
https://github.com/mozilla/pdf.js
There are APIs available to play with. It comes built into Firefox browser and has good support from Mozilla community.

Jekyll documentation to PDF with TOC

I would like to write documentation using Jekyll with HTML and PDF outputs. Html can have a navigation but the PDF should have table of contents. Is there a free and easy way to do that?
The HTML part is easy but I would like to use #media print CSS for making the PDF file.
I have a few ideas how to do this.
Use PrinceXML, unfortunately this is commercial product with a nasty price tag ~$500
Use WKHTMLTOPDF
Use Maruku, since it is possible to do a PDF conversion using it
I would like to have multiple pages HTML and single page PDF with a TOC. Any suggestions?
Btw. Buildr has solved this problem using PrinceXML.
If 'free' is your most important criterion, than wkhtmltopdf is your best bet. It supports things like covers, toc, headers, footers and sections. Depending on how exotic the layout of your document will be, you most likely will run into some page-break issues, but with a bit of tinkering you should be fine.
I've been using wkhtmltopdf for a bit now, with some quite complicated documents (with javascript charts, tables, svg images, etc.) and have not run into too many issues.
Make sure you use the static version of wkhtmltopdf, as it is the only version which supports rendering of a TOC page.
You can use the PDFKit gem, which uses wkhtmltopdf behind the scenes. Then you can put your PDF logic in a Jekyll plugin as a generator or converter.
For generating a table of contents using Jekyll, you can use the {:toc} macro offered by markdown, or write your own textile table of contents filter if you prefer to use textile..
For generating a PDF from Html and CSS, I have found weasyprint to be a good solution. Since they do not rely upon an external engine for rendering, they do not depend upon foreign project's roadmaps for implementing relevant features such as CSS generated content or #page CSS-declarations. (But in contrast to wkhtmltopdf, weasyprint does not parse javascript).
You could also use a browser extension called Awesome Screenshot to create JPEG/PDF from a page. The extension allows you to create a full-page image or export it to PDF. With this tool, you can export all pages really quickly (and/or later combine all PDFs together to create a single document).
I am aware this is a quick & dirty solution (not perfect). E.g: while using images instead of text, the full-text search will not work. Additionally, it may require some manual work, but it does the job when you just want to read it.

PDF Generation with High Resultion SVG Images (suggestions needed!)

Can anyone suggest/recommend a product that can be used to dynamically produce PDFs that can contain high-res images?
We're currently using a product called Highwire from a company called Corda to produce PDFs of our HTML pages.
Highwire is crap at producing PDFs though becuase it does not conform to HTML standards (i.e. it requires table layouts rather than CSS/Div layouts). We have to use it though because it is capable of incorporating high-definition SVG images into its PDF output.
Thanks
Dave
What about Prince?
It can handle XHTML and CSS just fine as well as SVG.
I used Apache FOP together with this stylesheet from HTML to XSL-FO with success in some projects. Embedding SVG ist straight forward, since FOP incorporates Batik, Apache's SVG library. You can copy SVG images 1:1 to the XSL-FO file.