ghostscript command line arguments output file name change - printing

I am using ghostscript to print a pdf by command line arguments in c#. but it shows the printed document's name as ghostScript output. I want to change it to a custom name(as letter's name). I know in command line parameters, it does not allow to change it. please help.

I'm sorry, I really don't understand what you're asking. You specify where Ghostscript should write it's output using the "-o" or "-sOutputfile=" command line parameters. The name of the input file does not influence the output file.
Unless you are using something like ps2pdf.....
If you can clarify what you are trying to do, I or someone else can likely help.
Chris

Related

How to read a user input in a text filed in ruby on rails and pass the value to a shell script command

I am very new to ruby on rails and I have a very simple question.
I am able to read the user input from a text field in ruby on rails
#user = params[:user]
I have to pass this value as an argument to a shell script
I tried a number of things, but nothing works
run_command "./file.sh #{#user}"
and
%x(./file.sh #{#user})
The script receives "{user="
Any help is appreciated!
First, make sure you escape any parameters you pass to command line. You may be easily attacked via command line injection this way. Try this instead:
system "/path/to/file.sh #{#user.shellescape}"
You may also want to try exec, depending on how you want to track output. Please see http://ruby-doc.org/core-2.3.0/Kernel.html for more details on both

how to overwrite, or delete the file, used by writefile() calls?

I use the following to save screen output to a file
writefile("file.txt"),
tex(expression),
closefile()
The above sends the output of the tex() to the file automatically. which is all and well and what I want. (side-point: It also sends an annoying NIL line each time to the file, which I had to parse put later).
Now, when running the above code again, the file is appended to, which is not what I want. I want to either overwrite the file each time, or if there is a way to delete the file, so I can call delete on it before.
I looked at help and not able to find a command to delete a file, and I also see no option to tell writefile() to overwrite the file?
Is there an option or way around this? I am on windows 7, Maxima version: 5.36.1
Lisp: SBCL 1.2.7
I guess you are trying to capture the output of tex into a file. If so, here are a couple of other ways to do it:
tex (expr, destination);
where destination is either a file name (which is appended) or a stream, as created by opena or openw and closed by close. By the way, destination could be false, in which case tex returns a string.
with_stdout (destination, tex (expr));
where again destination is either a file name (which is appended or clobbered, as determined by the global flag file_output_append) or a stream.
with_stdout could be useful if you want to mix in some output not generated by tex, e.g., print("% some commentary");.

getting a substring from a text file for later use

I have a text file that contains version information. There are multiple lines, but the specific line i need looks like this:
#define SW_VERSION "3.4.3.1 R3 08-06-12"
I specifically need the 3.4.3.1 R3 from the text file.
My first thought was to do execute a short script that would grab this data out and use a set for later use, though i am having quite a bit of trouble getting it to work.
I ran this: Find /I "#define SW_VERSION" C:\SW\bin\SW_Version.txt
and it showed me the line in the file that i expected, but i couldn't figure out how to parse it afterwards. Help?
You can write a custom task for Ant.
Your custom task would parse the version line and extract the information you need.

Ruby PDF:Toolkit using pdftotext

I'm converting pdf files in my Ruby project. I'm using the pdf toolkit gem for this.
The documentation shows how you can use pdftotext
pdftotext(file,outfile = nil,&block)
In my project I am converting a PDF file without any arguments and can just do this:
PDF::Toolkit.pdftotext("file.pdf", "file.txt)
If I run it from the command line, I can preserve the layout by passing that param
pdftotext -layout file.pdf
What is the correct syntax to achieve this with PDF::Toolkit?
Thanks!
Figured out how to make it work so I'm answering my own question, but if there's a "proper way" to do this, I'd love to see how to do it.
Put the options in the second argument and the text file will be named file_name.txt
PDF::Toolkit.pdftotext("file_name.pdf","-layout" )

How can I print a file from the command line?

Is there a way to run a file through a print driver without opening the application?
Ex: run a .docx file, without opening word, and save it to file?
Since it is a .docx-file Microsoft Word is probably the best program to do the task.
I would have a look at the [command line arguments] to Word:
Have a look at the following switches:
/q, /n, /mFilePrintDefault and /mFileExit
(/q and /n explained in the page above, and /mXxxx refers to macros. Have a look att google.)
Example:
WINWORD.EXE your_document.docx /mFilePrintDefault /mFileExit /q /n
The following page seems to explain how to convert it to PDF.
What you are looking for is called "headless start" of the program which needs to print.
I know for sure that OpenOffice can do this.
Basically, you need to start it and invoke a macro which will do the printing. Even more, you can print to a PDF, HTML, or anything else that Oo supports.
This negates the need for install of Microsoft Word and the cost of license, because OpenOffice is free.
If you are looking only for .docx silent printing then [aioobe] answer is the best. If you want a more generic silent print program that runs on Windows, use powershell or .NET and use the print verb. http://www.eggheadcafe.com/software/aspnet/30441939/how-to-suppress-printdialog-when-using-print-verb.aspx provides an example.
Hope this helps, if so +1 please :)
You might be interested in DocTo which will convert a word document to another file format, including pdf and XPS but does require Word on the machine.
For example
Docto -f "c:\docs\mydocument.docx" -o "c:\output" -t wdFormatPDF
Will output mydocument.docx to c:\output\mydocument.pdf as a pdf file.

Resources