Image file path error while using pandoc for markdown to pdf conversion - pdf

I have a markdown file with images in the same directory as the .md file, e.g. with ![Image test ](test.png) in the .md file.
I convert them into pdf throughpandoc:
pandoc --standalone --pdf-engine=xelatex file.md -o output.pdf
and I get the following error
[WARNING] Could not fetch resource 'test.png': replacing image with description
However, with the same directory I have no issues while converting .md into .html output. Can someone suggest what is the issue with pandoc?

Related

Create Landscape PDF with Pandoc using wkhtmltopdf

I am trying to create PDF with landscape orientation in Pandoc.
I am using WkHtmlToPdf as a PDF Engine. I chose not to use LaTeX. Here is the command I am using:
pandoc test.md -t html -o test.pdf
But it creates a portrait orientation. How can I create PDF in landscape mode?
Things I have tried without success
pandoc -V geometry:landscape test.md -t html -o test.pdf
pandoc -O landscape test.md -t html -o test.pdf
Please help.
Note: I do not want to use LaTeX as my PDF engine.
Please try this:
pandoc test.md -t html \
--pdf-engine-opt="-O" --pdf-engine-opt="Landscape" \
-o test.pdf
Pandoc doesn't know the -O option, it must be given to wkhtmltopdf. Use --pdf-engine-opts, once for each option or argument that you want pandoc to pass to the pdf engine.
The above was tested and succeeds on:
Ubuntu 20.04
pandoc 2.5
wkhtmltopdf 0.12.5

How can I convert pdf to asciidoc using pandoc?

I am trying to convert pdf book to asciidoc document.I have tried the following command:
pandoc -s s.pdf -t asciidoc -o example28.txt
I got "Unknown reader" problem.
q#q-ABRA-A5-V12-1:~/Downloads$ pandoc -s s.pdf -t asciidoc -o example28.txt
pandoc: Unknown reader: pdf
Pandoc can convert to PDF, but not from PDF.
How can I fix this or is there another way to convert from pdf to asciidoc?
Have you tried pdf2txt?
https://pypi.org/project/pdfminer/
It's one of the tools provided there.

How to create a PDF-out-of-Sphinx-documentation-tool

Followed this link to try and generate pdf from Sphinx:
https://www.quora.com/How-to-create-a-PDF-out-of-Sphinx-documentation-tool
$ sphinx-build -b pdf source build/pdf
Error: Cannot find source directory `/Users/seb/mydocs/source'.
$ make all-pdf
make: *** No rule to make target `all-pdf'. Stop.
$ make pdf
make: *** No rule to make target `pdf'. Stop.
Since tried in OSX:
$ conda install -c dfroger rst2pdf=0.93
Fetching package metadata .........
Solving package specifications: .
Error: Package missing in current osx-64 channels:
- rst2pdf 0.93*
You can search for packages on anaconda.org with
anaconda search -t conda rst2pdf
EDIT:
After pip install rst2pdf
install rst2pdf
register rst2pdf in your conf.py Sphinx config
extensions = ['sphinx.ext.autodoc','rst2pdf.pdfbuilder']
But adding 'rst2pdf.pdfbuilder' causes
Extension error:
Config value 'math_number_all' already present
make: *** [html] Error 1
$ sphinx-build -bpdf sourcedir outdir
But what do I specify as sourcedir and outdir? Example please.
EDIT:
Now after make html
and then:
$ rst2pdf index.rst output.pdf
index.rst:14: (ERROR/3) Unknown directive type "toctree".
.. toctree::
:maxdepth: 2
introduction
tutorial
multiple_jobs
deployment
project
index.rst:26: (ERROR/3) Unknown interpreted text role "ref".
index.rst:27: (ERROR/3) Unknown interpreted text role "ref".
index.rst:28: (ERROR/3) Unknown interpreted text role "ref".
Also:
$rst2pdf.py index.rst -o mydocument.pdf
Does produce a mydocument.pdf but completely different from html and toc to all the pages are not even there?
Image of pdf verse HTML same page
This is from the official Sphinx documentation. If you have pdfTex tool installed in your machine, all you need is:
$ make latexpdf
Then, the generated pdf file(s) will be under _build/latex/<PROJECT-NAME>.pdf
So, the complete process from scratch would be as follows:
$ pip install -U sphinx # install the package
$ sphinx-quickstart # create a new project (answer the questions)
$ make latexpdf # compile and generate pdf file
Note that you may also "optionally" install whatever extensions needed by editing the file config.py
NOTE: This answer assumes LaTeX engine is installed on your machine.
I have succeeded in generating a PDF file for the DevStack document by following the configuration changes in this link:
Here are the steps:
Edit your conf.py (edit or append values)
extensions = ['rst2pdf.pdfbuilder']
pdf_documents = [('index', u'rst2pdf', u'Sample rst2pdf doc', u'Your Name'),]
Install the "rst2pdf" if necessary
pip install rst2pdf
Build the PDF file like this:
sphinx-build -b pdf doc/source doc/build
Succeeded in Pdf Generation via Latex (for windows 10)... No need to change existing conf.py file in Sphinx... the best solution is install MiKTeX....install Perl (ActiveState).... after when running sphinx type 'make HTML' type 'make latex' and then make latexPdf... this solved my issue.
You could avoid rst2pdf and use make pdflatex to build pdf output via a latex file.
cf more info:
https://docs.typo3.org/typo3cms/extensions/sphinx/AdvancedUsersManual/RenderingPdf/
Make sure to have a look at http://rst2pdf.ralsina.me/handbook.html#sphinx.
Following applies to Ubuntu 16.
But it is probably less painful to install a full LaTex suite than to try to get this tool running; it is very sensitive to errors, and is difficult to use.
I took a look there (https://tex.stackexchange.com/a/95373) and it looks daunting...
this is more encouraging: https://milq.github.io/install-latex-ubuntu-debian/
And I did it:
sudo apt-get install texlive-full
make clean latexpdf
is worthwhile your patience (and disk space) to install. I got rid of rst2pdf.
Found this related post which discovers that rst2pdf breaks math rendering in Sphinx 1.4.1 because it imports a dummy math module.
In rst2pdf.pdfbuilder:setup(), it calls mathbase.setup() internally to install dummy math module. It causes conflicts and raise errors.
I had this same error when running sphinx-build -b pdf
Extension error:
Config value 'math_number_all' already present
Now looking at latex option, and exporting to pdf as #tfv posted. pdflatex is a larger universe of TeX distribution.
As an alternative to latexpdf: rinohtype
Once rinohtype is installed, sphinx-build -b rinoh . _build
Create a file documentation.md, and open it in Typora software. Navigate to the Sphynx documentation that you need, mark with mouse and copy inside Typora. Then inside typora export as PDF. Done.

How to command line extract svg from pdf using inkscape?

Is there a command line option for asking inkscape to extract svg from pdf page 3 (for example)?
The command I use now is
$ inkscape -f test.pdf -l test.svg
but I would like also the option to export a specific page from this pdf.
What about extracting the page you need with pdftk (or in fact, any other suitable tool) first:
mypage=$(mktemp -u XXXXXX.pdf)
pdftk test.pdf cat 3 output "$mypage"
inkscape -l test.svg "$mypage"
rm "$mypage"
(It would be nice to be able to pipe the output from pdftk directly to inkscape. Unfortunately, when provided from stdin, data are expected by inkscape to be svg. A named pipe doesn't help either, because inkscape seems to attempt to traverse pdf files more than once.)

Downloading .j2k or .png files using wget:if else condition

I am downloading folder consisting of either j2k or png file using wget.
Now i want while downloading folder if user is requesting .j2k file and if .j2k file is not existing in that folder then by default download .png file.
i.e. i want download j2k if present || download .png file.
I have used like this
wget -d any.com -i /folder -r -l 1 -nc -A j2k,png
-d: download from this Domain
-i: download from this foldern
-r: recursive
-l 1: follow only 1 link deep
-nc: no clobber = download only if file doesn't exist
-A: accept/download only all *.ogg and *.mp3
but using this it is downloading both j2k and png.
Any help will be appreciated.
Referred Links:
wget if else download condition
wget manual