How can I create a single rule for arara that crops the output PDF file using pdfcrop command then convert the output cropped file the same way done by CarLaTeX's convert rule (shown below)?
!config
# Convert .pdf to any format file allowed by ImageMagick convert command (the default is png)
# author: CarLaTeX
# last edited by: CarLaTeX, Dicember 26th 2016
# requires arara 3.0+
#
# Sample usage:
# - these both create a .png file
# % arara: convert
# % arara: convert: {format: png}
#
# - this creates a .gif file with red background
# % arara: convert: {format: gif, background: red}
#
# - this creates a .png file with a trimmed image
# (use the parameter "otheroptions" to add any option not already explicitly considered by the rule,
# that is any option different from -background, -alpha, -density and -quality}
# % arara: convert: {otheroptions: -trim +repage}
#
#
# This rule is really just a shortcut for commands like the following:
#
# convert -density 300 myfile.pdf myfile.png
#
# which will output myfile.png
#
identifier: convert
name: convert
commands:
- <arara> @{ isWindows( "cmd /c convert", "convert" ) } -background @{background} -alpha @{alpha} -density @{density} @{otheroptions} "@{ getBasename(file) }.pdf" -quality @{quality} "@{ getBasename(file) }.@{format}"
arguments:
- identifier: density
flag: <arara> @{parameters.density}
default: 150
- identifier: otheroptions
flag: <arara> @{parameters.otheroptions}
- identifier: quality
flag: <arara> @{parameters.quality}
default: 100
- identifier: background
flag: <arara> @{parameters.background}
default: white
- identifier: alpha
flag: <arara> @{parameters.alpha}
default: remove
- identifier: format
flag: <arara> @{parameters.format}
default: png

:)Output ofarara -v foo.texandarara.logwill help. – Paulo Cereda Jan 22 '18 at 16:15:)It's odd, I've never seenpdfcropfail before. What's the output when you runperl.exe c:\texlive\2016\texmf-dist\scripts\pdfcrop\pdfcrop.pl test.pdf test-tmp.pdfin the command line? Does it fail too? – Paulo Cereda Jan 22 '18 at 16:24--inito make it run successfully. – Diaa Jan 22 '18 at 16:28iniflag too. – Paulo Cereda Jan 22 '18 at 16:29pdfcropoptions? or the output quality would be the same in either case? – Diaa Jan 22 '18 at 16:31--iniflag forpdfcrop. I really don't know too much ofpdfcrop, as I am really surprised it failed with you. I didn't even know about the--iniflag! I think your question is beyond my humble comprehension of those tools, perhaps a follow-up question might enlight us all (regardingpdfcrop, of course).:)– Paulo Cereda Jan 22 '18 at 16:35\nopagenumbersinstead of\def\folio{}. – Henri Menke Jan 23 '18 at 01:08--ini? Additionally, in the help file ofpdfcrop, for example, margins can be set as--margins '5 10 5 20', so how can I set it here using these values? – Diaa Jan 23 '18 at 12:59defaultkey to theiniparameter, please edit the value and add the default fallback. Regarding--margins, you will only be able to set up just one value (which will be applied to all margins) because of a bug/restriction ofarara3.0 (solved in the unreleased version 4.0); this is achieved by setting% arara: pconv: { margins: 10 }. Hope it helps! – Paulo Cereda Jan 23 '18 at 13:17convertandpdfcropin the official repo: https://gitlab.com/islandoftex/arara/-/blob/development/rules/arara-rule-convert.yaml and https://gitlab.com/islandoftex/arara/-/blob/development/rules/arara-rule-pdfcrop.yaml They are targeted for the release of version 6, but are compatible with version 5 as well. Hope it helps!:)– Paulo Cereda Dec 01 '20 at 18:53