wkhtmltopdf doesn't show desktop size page in pdf - linux

I have been trying to set up wkthmltopdf to convert html to pdf documents on-the-fly on my linux web server. I've looked around for solutions around the default 800x600 issue and found this:
/usr/bin/xvfb-run --server-args="-screen 0, 1024x768x24" wkhtmltopdf --use-xserver http://domain.com /home/location/apps/test1.pdf
However, this STILL gives the resulting pdf a width of 800. What am I missing?
I've tried to run xvfb-run from the ssh command line and it works flawlessly. It also creates the pdf with a normal output.. it's just that the width is NOT being recognized...

Just a guess, but you might need another set of quotes around "0, 1024x768x24' so that it's considered a single argument after being passed on. So something like this:
/usr/bin/xvfb-run --server-args="-screen \"0, 1024x768x24\"" wkhtmltopdf --use-xserver http://domain.com /home/location/apps/test1.pdf
They are escaped with \ so that the xvfb-run command does not consider them argument delimiters, but rather passes them on to wkhtmltopdf.
(I don't know about xvfb-run, but assume that it is in turn building a wkhtmltopdf command line.)

Related

Converting svg to png with inkscape command line failing

I feel like I must be doing something silly wrong, but I just can't get this to work. This is the command I am running from cmd:
inkscape.com "C:\path\ship.svg" -e --export-png="C:\Path\ship.png" --without-gui
In return, I get:
WARNING: File path "--export-png=C:\path\ship.png" includes directory that doesn't exist.
It does exist. What am I missing?
You should have used either -e or --export-png, not both, since they mean the same thing.
But According to the docs, -e and --export-png are no longer available. You should use -o or --export-filename=FILENAME instead. And still, you can use only one of them since -o is just the shortcut for --export-filename.
inkscape "C:\path\ship.svg" -o "C:\path\ship.png"
or
inkscape "C:\path\ship.svg" --export-filename="C:\path\ship.png"
Just an update for 2021 (it should be typed in oneline - broken down for readability only)
inkscape
--export-width=128
--export-type=png
--export-filename="C:\path\ship.png" "C:\path\build.svg"
or if you want transparent PNGs, add --export-background-opacity=0 to invocation arguments:
inkscape
--export-background-opacity=0
--export-width=128
--export-type=png
--export-filename="C:\path\ship.png" "C:\path\build.svg"
In inkscape version 1.0.2 following command will work:
inkscape --export-type="png" myfile.svg --export-filename=myfile.png

add a permitted path to ghostscipt running configuration

I use a program which create me postscript file before using ps2pdf to make it a readable pdf, i've made a program which add some string to overwrite the company new logo. (The first program can't import image file itself).
I add the string before the before-last line of the file (" showpage").
While running my program to add the logo there is no error.
With the option -dNOSAFER everything is fine, but by default it's set to -dSAFER, and an invalidfileaccess error pop, the files are 6 jpg images alone in their directory.
I don't want to make it run with the -dNOSAFER option on. As it will fully open the file system.
In the documentation I've seen that there is a "permitted path" setting, but i can't find nowhere to set this up. Is it just a command line option to set in the command launching the program ? Or is there a config file for GhostScript / ps2pdf where i can put the path to this directory as permitted path.
in this documentation :
http://www.ghostscript.com/doc/current/Use.htm
I only find
-dTTYPAUSE
Causes Ghostscript to read a character from /dev/tty, rather than
standard input, at the end of each page. This may be useful if input
is coming from a pipe. Note that -dTTYPAUSE overrides -dNOPAUSE. Also
note that -dTTYPAUSE requires opening the terminal device directly,
and may cause problems in combination with -dSAFER. Permission errors
can be avoided by adding the device to the permitted reading list
before invoking safer mode
gs -dTTYPAUSE -dDELAYSAFER -c '<< /PermitFileReading [ (/dev/tty)] >> setuserparams .locksafe' -dSAFER
The quote is just for the context but is this a way to put the permitted path ?
As gs automatically launch with the full system as readOnly there will be no difference ? There is no other find result for PermitFile in this page.
Try adding the required path to the search path with -I (Include) See Use.htm, section 8 How Ghostscript finds files. This should only be a problem if you are using 'run' or similar to read files from another location.
The section on TTYPAUSE is not relevant.

Convert (numerically ordered) bitmap files to video file using avconv

I am attempting to convert a directory full of .bmp files into a .mp4 file (or similar format).
The bitmap files have the following name scheme:
output_N_1024.bmp
Where N is an integer in the range 0 to 1023. (No zero padding / fixed width.)
The command I am using is:
avconv -r 25 -i output_{0..1023}_1024.bmp outputfile.mp4
This appears to run okay, and takes about a minute to convert all 1024, 1024 by 1024 resolution - (confusing?) bitmap images into a new file, outputfile.mp4.
However, when I attempt to open this file with VLC, a black window briefly flashes up and then closes. VLC then goes back to its mode where it waits for you to tell it which file to open next. No error or warning messages appear from VLC, which seems kind of strange since it seems to be refusing to play.
What can I do to fix this? Perhaps my converting command is incorrect?
The problem most likely is that you haven't actually passed the command to encode these files to avconv. This has happened because your shell has expanded the filenames already.
The command i have just managed to get to work on my machine is:
avconv -r 2 -i "%d.bmp" -s 600x400 -an out.ogv
Also for whatever reason it didn't want to work without explicitely giving it the size, but i don't think this is your problem.
In here quotes tell your shell not to touch this string. %d means digits from 1 to whatever the last file is (if you would want them to be 0-padded this would look like %000d to have maximum of three naughts in front).
VLC has then opened and ran my file just fine.

Perl color specifiers with redirected output

I have a Perl script that uses Term::ANSIColor. It used to be the case that if I redirect the output to a file > file.txt then the file contains just the text, and not the color codes ^[[0m
Something changed on my machine, Ubuntu 10.04, such that redirected output includes these special characters that specify color.
Any idea how to fix this? Can I detect output redirection from inside the perl script and skip the color part?
Thanks!
You can test whether you're running interactively using the IO::Interactive package:
use IO::Interactive qw(is_interactive);
if (is_interactive())
{
# show some fancy color
}
The rationale behind using IO::Interactive (instead of just testing if STDIN is a tty with the -t operator) is extensively explained by Damian Conway.

CCNetConfig command line parameter for opening a ccnet.config?

I'm trying out CCNetConfig (warning, website a little slow). Great app, one annoyance.
I can see in the documentation and even in the source code (Look at the end of the Initialize method) that I should be able to pass in a command line parameter to automatically load the configuration file.
I have tried:
-f E:\CruiseControl.Net\server\ccnet.config
-file E:\CruiseControl.Net\server\ccnet.config
-f=E:\CruiseControl.Net\server\ccnet.config
-file=E:\CruiseControl.Net\server\ccnet.config
And the same 4 switches with quotes around the file name just in case.
They all produce errors or just don't work. Has anyone had success doing this?
Thanks in advance.
Try moving it to a different path. Try the simplest thing: c:\ccnet.config.
I'm guessing it's the source of the problem because I recall CCNetConfig gave me sh!t early on when I tried to open files in paths that had spaces in them (e..g in Program Files).
According to my version of CCNet the command line flag for using a different config file is -c or --config, so the following should do it...
-c "E:\CruiseControl.Net\server\ccnet.config"
...which works for me.
I don't know why it uses a non-standard flag, but there you go.

Resources