inkscape: multiple page pdf to multiple png - pdf

when I convert pdf to image in linux command line, it seems inkscape gets the best result (better quality than gs with same dpi). Unfortunately, it only converts the first page to png. How to convert every pdf page to different png file? Do I have to extract one PDF page and store to a new pdf file , then do inkscape concert, and so on?

This isn't solely using Inkscape, but you could use e.g. pdftk to split up the pdf-file into separate pages and convert every page into a png with Inkscape. For example, like this:
pdftk file.pdf burst;
l=$(ls pg_*.pdf)
for i in $l; do inkscape "$i" -z --export-dpi=300 --export-area-page --export-png="$i.png"; done
Note that pdftk burst creates pdf-files called pg_0001.pdf, etc., so if you have any files named like that, they'll be overwritten. You can remove them afterwards easily using
rm pg_*.pdf

Lu Kas' answer threw warnings for me without doing the conversion. Probably because I'm running Inkscape 1.1
However, i got it running by replacing some deprecated commands:
inkscape pdfFile.pdf --export-dpi=300 --export-area-page --export-filename=imageFile.png;

For batch processing rather than slowly looping through file by file inkscape has a shell mode for command file scripting. See https://wiki.inkscape.org/wiki/index.php/Using_the_Command_Line#Shell_mode
However like all other #file.txt scripts you need to write a custom text file. and for Windows users run against higher ranking inkscape.com not .exe
Since version 1.0 (currently 1.2) a multipage pdf of contents can be addressed for multiple outputs. for some other examples see https://inkscape.org/doc/inkscape-man.html#EXAMPLES
Commands get replaced over time so currently to export png use --export-type="xxx" to batch export a list of input files to type xxx. Thus in this case --export-type="png"
Also for pdf related inputs and support see https://wiki.inkscape.org/wiki/index.php/Using_the_Command_Line#New_options
For windows users there is a handy batchfile converter here https://gist.github.com/JohannesDeml/779b29128cdd7f216ab5000466404f11

Related

some markdown files into one pdf document

I have approximately 20 files in markdown type and I need to convert those into one pdf document. I try using online converter, but the images are not showing, it just like ![alt text](image.png)
Using Calibre app also not showing images.
Btw, I am using Gitbook to generate my markdown and html view, I read the documentation about how to convert into pdf using gitbook pdfin command line, but it returns TypeError
Does anyone know how to solve this? I am using Windows 10
Hi you can use the Pandoc tool (it runs on Windows/MacOS/Linux).
It is an command line tool which can easily convert your Markdown file into PDF (or other kind of format).
Take a look to Pandoc website
Maybe you will have to install a LaTeX environnement like Miktex in order to convet into PDF.
An example from Pandoc documentation :
From markdown to PDF:
pandoc myInput.md --latex-engine=xelatex -o myOutput.pdf
Furthermore, there is several interesting options if you want to generate a table of contents in your output for instance.

Convert all pages of PDF to multiple png files with Inkscape Commnad line

I'm new to Inkscape (commandline options).
I wish to convert a multi-pages PDF file to multiple png files (each pahe as one png file).
NOTE: Also need to maintain transparency.
Please help
I used following command to resolve my requirement.
mudraw.exe -r100 -o Paper.pdf_%d.png Paper.pdf
It worked smoothly.

Pandoc disable figure stretching from Markdown to PDF conversion

I create PDF documents from Markdown documents using the simplest pandoc command:
pandoc my.md -o my.pdf
The figures inside the PDF are all stretched, i.e: 100% width.
Which configuration should I give to pandoc to leave the figures as is without changing figure size.
Currently you cannot control that feature directly from Markdown.
In recent months there have been some discussions going on in the Pandoc developer + user community about how to best implement it and create an easy-to-use syntax, for example
![Image Caption](./path/to/image.jpg "Image Comment"){width="60%", height="150px"}
(Warning: Example only, made up on the fly and drawn out of thin air by myself -- can't remember the latest state of the discussion...) This is designed to then transfer to all the supported output formats which can contain images, not just PDF.
So this is planned to be a major new feature for the next major release of Pandoc.
As you may or may not know, Pandoc doesn't create the PDFs itself. It produces LaTeX and employs LaTeX technology (by default its pdflatex command) to convert the LaTeX to PDF (then deleting the intermediate LaTeX files).
To execute some (limited) control about how the LaTeX/PDF pages (or other outputs) look like, Pandoc uses template files. You can look at the exact template definitions your own Pandoc version uses for LaTeX/PDF output by running
pandoc -D latex
So if you are a LaTeX hacker (or know one), you are able to modify that or create your own template from scratch.
In the current release of Pandoc (v1.13.2.1), there is this code snippet in the LaTeX template:
\makeatletter
\def\maxwidth{\ifdim\Gin#nat#width>\linewidth\linewidth\else\Gin#nat#width\fi}
\def\maxheight{\ifdim\Gin#nat#height>\textheight\textheight\else\Gin#nat#height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
This should keep the original image sizes if they fit into the page width, and scale them down to the page width if they don't.
If this is not the behavior you experience with your PDF output, I suspect you are an a rather old version of Pandoc.
For using your own template instead of the builtin internal one, you can add
--template=/path/to/myown-template.latex
to the Pandoc command line.
#KurtPfeifle Thanks for your help. I updated the latex to set static width and hight for the images using the tip.
In my latex template I have:
\setkeys{Gin}{width=128pt,height=192pt,keepaspectratio}
This works great for the mobile images. But I also have a cover page, where the cover figure is now small sized.
I tried creating 2 different latex files and combining them but the figure sizes are back to being stretched:
pandoc _cover_page.md -o _cover_page.tex
pandoc ... -template=mobile_images.latex -o remaining.tex
pandoc _cover_page.tex remaining.tex -o out.pdf
Is there an easy way to combine latex files whicih obey the templates in Pandoc?
I can create 2 pdf files: cover.pdf and remaining.pdf, and combine them too. Is there an easy tool that you know?

Ghostscript PDF printing garbled

I'm trying to use Ghostscript 9.02 on Windows 7 to print a PDF to an Epson Workforce printer from the command line using the following command:
gswin32c -dPrinted -dBATCH -dNOPAUSE -dNOSAFER -q -dNumCopies=1 -sDEVICE=epson -sOutputFile=\\spool\EPSON C:\Document1.pdf
When executing this command, pages will print from my printer, but it is just garbled text instead of the PDF.
I have tried 3 different PDF files with similar results.
I doubt that the previous answer is the issue, but rather is a problem with getting the epson format data passed through correctly as binary. Particularly if the 'init_string' == "\f\033#" doesn't make it in,
the rest of the data will be interpreted by the printer as text instead of raster data.
Since you are on Windows, you may get better results by using the -sDEVICE=mswinpr2 device which sends the raster image for the page through GDI to the manufacturer's driver. See http://artifex.com/gs-current-release/Devices.htm#Win for documentation on printing from windows using Ghostscript.
BTW, you can easily check if the problem is with gswin32c being able to properly render the input PDF by
looking at it on the default 'display' device using:
gswin32c C:\Document1.pdf
your problem may be probably related with encoding used by pdf file
how this pdf has been produced?
I seen several times this problem arise with pdf produced by internal pdf exporter of OpenOffice
I have had a similar issue, and it looks like not all listed devices are capable of printing PDF files. I have used ljet4 option for Ricoh network printer and it prints fine. The only problem is it always prints immediately instead of "HoldPrint" queue.

How to merge many PDF files into a single one? [duplicate]

This question already has answers here:
Merge / convert multiple PDF files into one PDF [closed]
(23 answers)
Closed 6 years ago.
I have 16 pdfs that I want to convert into a single one... I am on Ubuntu 10.10, how can I do it?
First, get Pdftk:
sudo apt-get install pdftk
Now, as shown on example page, use
pdftk 1.pdf 2.pdf 3.pdf cat output 123.pdf
for merging pdf files into one.
You can also use Ghostscript to merge different PDFs. You can even use it to merge a mix of PDFs, PostScript (PS) and EPS into one single output PDF file:
gs \
-o merged.pdf \
-sDEVICE=pdfwrite \
-dPDFSETTINGS=/prepress \
input_1.pdf \
input_2.pdf \
input_3.eps \
input_4.ps \
input_5.pdf
However, I agree with other answers: for your use case of merging PDF file types only, pdftk may be the best (and certainly fastest) option.
Update:
If processing time is not the main concern, but if the main concern is file size (or a fine-grained control over certain features of the output file), then the Ghostscript way certainly offers more power to you. To highlight a few of the differences:
Ghostscript can 'consolidate' the fonts of the input files which leads to a smaller file size of the output. It also can re-sample images, or scale all pages to a different size, or achieve a controlled color conversion from RGB to CMYK (or vice versa) should you need this (but that will require more CLI options than outlined in above command).
pdftk will just concatenate each file, and will not convert any colors. If each of your 16 input PDFs contains 5 subsetted fonts, the resulting output will contain 80 subsetted fonts. The resulting PDF's size is (nearly exactly) the sum of the input file bytes.
You can use http://www.mergepdf.net/ for example
Or:
PDFTK http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/
If you are NOT on Ubuntu and you have the same problem (and you wanted to start a new topic on SO and SO suggested to have a look at this question) you can also do it like this:
Things You'll Need:
* Full Version of Adobe Acrobat
Open all the .pdf files you wish to merge. These can be minimized on your desktop as individual tabs.
Pull up what you wish to be the first page of your merged document.
Click the 'Combine Files' icon on the top left portion of the screen.
The 'Combine Files' window that pops up is divided into three sections. The first section is titled, 'Choose the files you wish to combine'. Select the 'Add Open Files' option.
Select the other open .pdf documents on your desktop when prompted.
Rearrange the documents as you wish in the second window, titled, 'Arrange the files in the order you want them to appear in the new PDF'
The final window, titled, 'Choose a file size and conversion setting' allows you to control the size of your merged PDF document. Consider the purpose of your new document. If its to be sent as an e-mail attachment, use a low size setting. If the PDF contains images or is to be used for presentation, choose a high setting. When finished, select 'Next'.
A final choice: choose between either a single PDF document, or a PDF package, which comes with the option of creating a specialized cover sheet. When finished, hit 'Create', and save to your preferred location.
Tips & Warnings
Double check the PDF documents prior to merging to make sure all pertinent information is included. Its much easier to re-create a single PDF page than a multi-page document.
There are lots of free tools that can do this.
I use PDFTK (a open source cross-platform command-line tool) for things like that.
Also seem pdfjam: http://www2.warwick.ac.uk/fac/sci/statistics/staff/academic/firth/software/pdfjam/