Possible to print to PDF from Mac terminal?
Is it possible to take a file and print it to a PDF using nothing but terminal commands? I am guessing you would somehow make use of the lpr command, but I have yet to discover the correct syntax.
macos pdf printing
|
show 2 more comments
Is it possible to take a file and print it to a PDF using nothing but terminal commands? I am guessing you would somehow make use of the lpr command, but I have yet to discover the correct syntax.
macos pdf printing
What sort of file? plain text?
– Doug Harris
Jan 5 '11 at 15:46
1
@Daniel, I should've been more clear in my question: What sort of source file? -- My answer below will work for plain text files, but not for images.
– Doug Harris
Jan 5 '11 at 16:06
@Doug I apologize, I actually misread the question.
– Daniel Beck♦
Jan 5 '11 at 16:08
1
@Daniel - What I'm really aiming for is something more graphically intensive, say HTML pages. Is this possible?
– tambler
Jan 5 '11 at 18:05
1
Your main problem probably is, that the viewer application is file format dependent. Make up your mind what format you want and you'll get specific answers.
– Daniel Beck♦
Jan 5 '11 at 18:41
|
show 2 more comments
Is it possible to take a file and print it to a PDF using nothing but terminal commands? I am guessing you would somehow make use of the lpr command, but I have yet to discover the correct syntax.
macos pdf printing
Is it possible to take a file and print it to a PDF using nothing but terminal commands? I am guessing you would somehow make use of the lpr command, but I have yet to discover the correct syntax.
macos pdf printing
macos pdf printing
edited Jan 5 '11 at 15:50
Daniel Beck♦
92k12232284
92k12232284
asked Jan 5 '11 at 15:38
tambler
181114
181114
What sort of file? plain text?
– Doug Harris
Jan 5 '11 at 15:46
1
@Daniel, I should've been more clear in my question: What sort of source file? -- My answer below will work for plain text files, but not for images.
– Doug Harris
Jan 5 '11 at 16:06
@Doug I apologize, I actually misread the question.
– Daniel Beck♦
Jan 5 '11 at 16:08
1
@Daniel - What I'm really aiming for is something more graphically intensive, say HTML pages. Is this possible?
– tambler
Jan 5 '11 at 18:05
1
Your main problem probably is, that the viewer application is file format dependent. Make up your mind what format you want and you'll get specific answers.
– Daniel Beck♦
Jan 5 '11 at 18:41
|
show 2 more comments
What sort of file? plain text?
– Doug Harris
Jan 5 '11 at 15:46
1
@Daniel, I should've been more clear in my question: What sort of source file? -- My answer below will work for plain text files, but not for images.
– Doug Harris
Jan 5 '11 at 16:06
@Doug I apologize, I actually misread the question.
– Daniel Beck♦
Jan 5 '11 at 16:08
1
@Daniel - What I'm really aiming for is something more graphically intensive, say HTML pages. Is this possible?
– tambler
Jan 5 '11 at 18:05
1
Your main problem probably is, that the viewer application is file format dependent. Make up your mind what format you want and you'll get specific answers.
– Daniel Beck♦
Jan 5 '11 at 18:41
What sort of file? plain text?
– Doug Harris
Jan 5 '11 at 15:46
What sort of file? plain text?
– Doug Harris
Jan 5 '11 at 15:46
1
1
@Daniel, I should've been more clear in my question: What sort of source file? -- My answer below will work for plain text files, but not for images.
– Doug Harris
Jan 5 '11 at 16:06
@Daniel, I should've been more clear in my question: What sort of source file? -- My answer below will work for plain text files, but not for images.
– Doug Harris
Jan 5 '11 at 16:06
@Doug I apologize, I actually misread the question.
– Daniel Beck♦
Jan 5 '11 at 16:08
@Doug I apologize, I actually misread the question.
– Daniel Beck♦
Jan 5 '11 at 16:08
1
1
@Daniel - What I'm really aiming for is something more graphically intensive, say HTML pages. Is this possible?
– tambler
Jan 5 '11 at 18:05
@Daniel - What I'm really aiming for is something more graphically intensive, say HTML pages. Is this possible?
– tambler
Jan 5 '11 at 18:05
1
1
Your main problem probably is, that the viewer application is file format dependent. Make up your mind what format you want and you'll get specific answers.
– Daniel Beck♦
Jan 5 '11 at 18:41
Your main problem probably is, that the viewer application is file format dependent. Make up your mind what format you want and you'll get specific answers.
– Daniel Beck♦
Jan 5 '11 at 18:41
|
show 2 more comments
9 Answers
9
active
oldest
votes
lpr
is indeed the correct command. There's not much to it, just
lpr filename.pdf
should simply work, presuming that the default printer is set correctly. If not, you might have to do
lpr -P printername filename.pdf
Note that there's a man page -- "man lpr" if you need to see the content. Yes, the CUPS print daemon that OS X uses is already PDF aware.
Provided solution gives zero-size pdf on Yosemite. Any ideas how to solve it?
– Stanislav Mekhonoshin
Jun 1 '15 at 12:41
Sorry for duplication. Provided solution gives zero-size pdf on Yosemite, when I'm trying to pring .pages document. RTF or txt are printed well. Any ideas how to fix it?
– Stanislav Mekhonoshin
Jun 1 '15 at 13:06
lpr does not generate pdf files, so I am not sure I understand the comment. You cannot generate pdf files with lpr.
– Perry
May 18 '17 at 21:32
4
This does not answer the original question as it was how to 'print to pdf', not print a pdf.
– dorien
Jun 27 '17 at 1:29
add a comment |
I know that I have seen something in a merely hidden system folder:
/Library/Scripts/Printing Scripts/Convert To PDF.scpt
I have created a new application from AppleScript but calling the script directly should work also.
EDIT:
actually you simply can call
/System/Library/Printers/Libraries/convert -f file.rtf -o file.pdf -j "application/pdf"
6
This answer is obsolete. Tested in OS X 10.9.5.
– 4ae1e1
Oct 15 '14 at 7:38
@4ae1e1 No, it isn't. Just that "convert" doesn't exist. It's a symlink to /usr/sbin/cupsfilter and cupsfilter will still work this way even on 10.13.6.
– cde
Nov 8 at 3:13
add a comment |
1) The Open Source Word processor, AbiWord, includes an option of converting between any formats it knows on the commandline, including PDF e.g.,
abiword --to=pdf filename.html
(It'll also handle, e.g., MS Word .doc files, .docx, .odt, .rtf, etc., both input and output.)
I know it's available for Mac, though I've never used it on a mac.
2) The ebook-convert
command line program from calibre (on mac you need to follow the instructions here to get the commandline tools) is useful for many formats, too.
ebook-convert filename.html filename.pdf
It can handle .rtf and .odt input, and lots of ebook formats like .epub and .mobi.
3) PrinceXML can be used on the commandline, and will convert HTML to PDF very beautifully.
4) There's wkhtmltopdf, which uses the webkit engine to convert HTML to PDF from the commandline. I've never tried it.
5) I can think of other methods using, e.g., ConTeXt or pdflatex, but they get more and more involved.
NB: AbiWord doesn't work on intel based Mac
– inspectorG4dget
Jan 22 '14 at 18:31
add a comment |
For plain text files, you can use enscript
(comes with OS X) to generate a postscript file.
$ enscript -p ~/Desktop/profile.ps /etc/profile
[ 1 pages * 1 copy ] left in /Users/dharris/Desktop/profile.ps
OS X's Preview app can open (and convert) to PDF, or you can install ps2pdf (I installed it via macports) and convert at the command line.
$ ps2pdf ~/Desktop/profile.ps ~/Desktop/profile.pdf
What if I wanted to do something more graphically intensive? Say, converting an HTML page to PDF from the terminal?
– tambler
Jan 5 '11 at 17:53
I know this is old, but PhantomJS can do this, and it does it very well.
– Brad
Jun 13 '13 at 3:34
add a comment |
You could also use pandoc from http://johnmacfarlane.net/pandoc/installing.html
With this command you would convert the html file to pdf:
pandoc -o output.pdf input.html
But note that pandoc uses LaTeX for the conversion, so you have to have a LaTeX system installed (http://www.tug.org/mactex/).
Pandoc can also convert to other formats like .odt, .docx and .epub
add a comment |
For local web page files, you can try to use Download URLs as PDF Automator action. Download and install.
I had to start Automator in 32 bit mode:
Create an Automator Application that automatically receives files and folders as input, with this action as the only one. Save e.g. as Save as PDF
.
Open the Get Info dialog of your application, and check Open in 32-bit mode also here. Double-click it once to make sure Launch Services knows the application.
You can use this application from the command line like this:
osascript -e 'tell application "Save as PDF" to open { POSIX file "/path/to/file.html" as alias }'
Of course, you can wrap this in a nice AppleScript .scpt
, bash
function, shell script, or what not.
This solution is actually pretty flexible. I was able to convert text files and HTML files, and the Automator action is also somewhat configurable.
add a comment |
First get the printer name
lpstat -p
Then use the printer name (Canon1234 - for eg)
lp -d Canon1234 PathToDocument.pdf
Op is looking to print an arbitrary file to a pdf document, not print a pdf to a real printer.
– cde
Nov 8 at 3:37
add a comment |
Actually it's a lot easier than that. You can just type on the command line open *.pdf
and Preview will open with all the files there. Weirdly though if you type open *.pdf */*.pdf
you get two windows. In each you then have to go into the side bar, select one of the boxy formats (if there are a lot of files it opens by default in list format which doesn't work) type CMD-A to select all, then use the print-selected-pages command to get all of them.
add a comment |
you can add pdf printer driver from using pdf printer
- first install
pdf printer
from the store then - start
pdf printer
go to system preferences
open printers and scanners
click
+
buttonin printers list select
pdf printer
wait for a second
then click add
set
pdf printer
as default printer then close...
open terminal
then execute the command for print a file
lp /path/to/your/file/to/print.txt
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f229418%2fpossible-to-print-to-pdf-from-mac-terminal%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
9 Answers
9
active
oldest
votes
9 Answers
9
active
oldest
votes
active
oldest
votes
active
oldest
votes
lpr
is indeed the correct command. There's not much to it, just
lpr filename.pdf
should simply work, presuming that the default printer is set correctly. If not, you might have to do
lpr -P printername filename.pdf
Note that there's a man page -- "man lpr" if you need to see the content. Yes, the CUPS print daemon that OS X uses is already PDF aware.
Provided solution gives zero-size pdf on Yosemite. Any ideas how to solve it?
– Stanislav Mekhonoshin
Jun 1 '15 at 12:41
Sorry for duplication. Provided solution gives zero-size pdf on Yosemite, when I'm trying to pring .pages document. RTF or txt are printed well. Any ideas how to fix it?
– Stanislav Mekhonoshin
Jun 1 '15 at 13:06
lpr does not generate pdf files, so I am not sure I understand the comment. You cannot generate pdf files with lpr.
– Perry
May 18 '17 at 21:32
4
This does not answer the original question as it was how to 'print to pdf', not print a pdf.
– dorien
Jun 27 '17 at 1:29
add a comment |
lpr
is indeed the correct command. There's not much to it, just
lpr filename.pdf
should simply work, presuming that the default printer is set correctly. If not, you might have to do
lpr -P printername filename.pdf
Note that there's a man page -- "man lpr" if you need to see the content. Yes, the CUPS print daemon that OS X uses is already PDF aware.
Provided solution gives zero-size pdf on Yosemite. Any ideas how to solve it?
– Stanislav Mekhonoshin
Jun 1 '15 at 12:41
Sorry for duplication. Provided solution gives zero-size pdf on Yosemite, when I'm trying to pring .pages document. RTF or txt are printed well. Any ideas how to fix it?
– Stanislav Mekhonoshin
Jun 1 '15 at 13:06
lpr does not generate pdf files, so I am not sure I understand the comment. You cannot generate pdf files with lpr.
– Perry
May 18 '17 at 21:32
4
This does not answer the original question as it was how to 'print to pdf', not print a pdf.
– dorien
Jun 27 '17 at 1:29
add a comment |
lpr
is indeed the correct command. There's not much to it, just
lpr filename.pdf
should simply work, presuming that the default printer is set correctly. If not, you might have to do
lpr -P printername filename.pdf
Note that there's a man page -- "man lpr" if you need to see the content. Yes, the CUPS print daemon that OS X uses is already PDF aware.
lpr
is indeed the correct command. There's not much to it, just
lpr filename.pdf
should simply work, presuming that the default printer is set correctly. If not, you might have to do
lpr -P printername filename.pdf
Note that there's a man page -- "man lpr" if you need to see the content. Yes, the CUPS print daemon that OS X uses is already PDF aware.
edited Jan 20 '16 at 2:09
Alex K
1034
1034
answered Jun 13 '13 at 21:10
Perry
21524
21524
Provided solution gives zero-size pdf on Yosemite. Any ideas how to solve it?
– Stanislav Mekhonoshin
Jun 1 '15 at 12:41
Sorry for duplication. Provided solution gives zero-size pdf on Yosemite, when I'm trying to pring .pages document. RTF or txt are printed well. Any ideas how to fix it?
– Stanislav Mekhonoshin
Jun 1 '15 at 13:06
lpr does not generate pdf files, so I am not sure I understand the comment. You cannot generate pdf files with lpr.
– Perry
May 18 '17 at 21:32
4
This does not answer the original question as it was how to 'print to pdf', not print a pdf.
– dorien
Jun 27 '17 at 1:29
add a comment |
Provided solution gives zero-size pdf on Yosemite. Any ideas how to solve it?
– Stanislav Mekhonoshin
Jun 1 '15 at 12:41
Sorry for duplication. Provided solution gives zero-size pdf on Yosemite, when I'm trying to pring .pages document. RTF or txt are printed well. Any ideas how to fix it?
– Stanislav Mekhonoshin
Jun 1 '15 at 13:06
lpr does not generate pdf files, so I am not sure I understand the comment. You cannot generate pdf files with lpr.
– Perry
May 18 '17 at 21:32
4
This does not answer the original question as it was how to 'print to pdf', not print a pdf.
– dorien
Jun 27 '17 at 1:29
Provided solution gives zero-size pdf on Yosemite. Any ideas how to solve it?
– Stanislav Mekhonoshin
Jun 1 '15 at 12:41
Provided solution gives zero-size pdf on Yosemite. Any ideas how to solve it?
– Stanislav Mekhonoshin
Jun 1 '15 at 12:41
Sorry for duplication. Provided solution gives zero-size pdf on Yosemite, when I'm trying to pring .pages document. RTF or txt are printed well. Any ideas how to fix it?
– Stanislav Mekhonoshin
Jun 1 '15 at 13:06
Sorry for duplication. Provided solution gives zero-size pdf on Yosemite, when I'm trying to pring .pages document. RTF or txt are printed well. Any ideas how to fix it?
– Stanislav Mekhonoshin
Jun 1 '15 at 13:06
lpr does not generate pdf files, so I am not sure I understand the comment. You cannot generate pdf files with lpr.
– Perry
May 18 '17 at 21:32
lpr does not generate pdf files, so I am not sure I understand the comment. You cannot generate pdf files with lpr.
– Perry
May 18 '17 at 21:32
4
4
This does not answer the original question as it was how to 'print to pdf', not print a pdf.
– dorien
Jun 27 '17 at 1:29
This does not answer the original question as it was how to 'print to pdf', not print a pdf.
– dorien
Jun 27 '17 at 1:29
add a comment |
I know that I have seen something in a merely hidden system folder:
/Library/Scripts/Printing Scripts/Convert To PDF.scpt
I have created a new application from AppleScript but calling the script directly should work also.
EDIT:
actually you simply can call
/System/Library/Printers/Libraries/convert -f file.rtf -o file.pdf -j "application/pdf"
6
This answer is obsolete. Tested in OS X 10.9.5.
– 4ae1e1
Oct 15 '14 at 7:38
@4ae1e1 No, it isn't. Just that "convert" doesn't exist. It's a symlink to /usr/sbin/cupsfilter and cupsfilter will still work this way even on 10.13.6.
– cde
Nov 8 at 3:13
add a comment |
I know that I have seen something in a merely hidden system folder:
/Library/Scripts/Printing Scripts/Convert To PDF.scpt
I have created a new application from AppleScript but calling the script directly should work also.
EDIT:
actually you simply can call
/System/Library/Printers/Libraries/convert -f file.rtf -o file.pdf -j "application/pdf"
6
This answer is obsolete. Tested in OS X 10.9.5.
– 4ae1e1
Oct 15 '14 at 7:38
@4ae1e1 No, it isn't. Just that "convert" doesn't exist. It's a symlink to /usr/sbin/cupsfilter and cupsfilter will still work this way even on 10.13.6.
– cde
Nov 8 at 3:13
add a comment |
I know that I have seen something in a merely hidden system folder:
/Library/Scripts/Printing Scripts/Convert To PDF.scpt
I have created a new application from AppleScript but calling the script directly should work also.
EDIT:
actually you simply can call
/System/Library/Printers/Libraries/convert -f file.rtf -o file.pdf -j "application/pdf"
I know that I have seen something in a merely hidden system folder:
/Library/Scripts/Printing Scripts/Convert To PDF.scpt
I have created a new application from AppleScript but calling the script directly should work also.
EDIT:
actually you simply can call
/System/Library/Printers/Libraries/convert -f file.rtf -o file.pdf -j "application/pdf"
edited Jan 15 '12 at 14:29
answered Jan 15 '12 at 13:53
user113731
6
This answer is obsolete. Tested in OS X 10.9.5.
– 4ae1e1
Oct 15 '14 at 7:38
@4ae1e1 No, it isn't. Just that "convert" doesn't exist. It's a symlink to /usr/sbin/cupsfilter and cupsfilter will still work this way even on 10.13.6.
– cde
Nov 8 at 3:13
add a comment |
6
This answer is obsolete. Tested in OS X 10.9.5.
– 4ae1e1
Oct 15 '14 at 7:38
@4ae1e1 No, it isn't. Just that "convert" doesn't exist. It's a symlink to /usr/sbin/cupsfilter and cupsfilter will still work this way even on 10.13.6.
– cde
Nov 8 at 3:13
6
6
This answer is obsolete. Tested in OS X 10.9.5.
– 4ae1e1
Oct 15 '14 at 7:38
This answer is obsolete. Tested in OS X 10.9.5.
– 4ae1e1
Oct 15 '14 at 7:38
@4ae1e1 No, it isn't. Just that "convert" doesn't exist. It's a symlink to /usr/sbin/cupsfilter and cupsfilter will still work this way even on 10.13.6.
– cde
Nov 8 at 3:13
@4ae1e1 No, it isn't. Just that "convert" doesn't exist. It's a symlink to /usr/sbin/cupsfilter and cupsfilter will still work this way even on 10.13.6.
– cde
Nov 8 at 3:13
add a comment |
1) The Open Source Word processor, AbiWord, includes an option of converting between any formats it knows on the commandline, including PDF e.g.,
abiword --to=pdf filename.html
(It'll also handle, e.g., MS Word .doc files, .docx, .odt, .rtf, etc., both input and output.)
I know it's available for Mac, though I've never used it on a mac.
2) The ebook-convert
command line program from calibre (on mac you need to follow the instructions here to get the commandline tools) is useful for many formats, too.
ebook-convert filename.html filename.pdf
It can handle .rtf and .odt input, and lots of ebook formats like .epub and .mobi.
3) PrinceXML can be used on the commandline, and will convert HTML to PDF very beautifully.
4) There's wkhtmltopdf, which uses the webkit engine to convert HTML to PDF from the commandline. I've never tried it.
5) I can think of other methods using, e.g., ConTeXt or pdflatex, but they get more and more involved.
NB: AbiWord doesn't work on intel based Mac
– inspectorG4dget
Jan 22 '14 at 18:31
add a comment |
1) The Open Source Word processor, AbiWord, includes an option of converting between any formats it knows on the commandline, including PDF e.g.,
abiword --to=pdf filename.html
(It'll also handle, e.g., MS Word .doc files, .docx, .odt, .rtf, etc., both input and output.)
I know it's available for Mac, though I've never used it on a mac.
2) The ebook-convert
command line program from calibre (on mac you need to follow the instructions here to get the commandline tools) is useful for many formats, too.
ebook-convert filename.html filename.pdf
It can handle .rtf and .odt input, and lots of ebook formats like .epub and .mobi.
3) PrinceXML can be used on the commandline, and will convert HTML to PDF very beautifully.
4) There's wkhtmltopdf, which uses the webkit engine to convert HTML to PDF from the commandline. I've never tried it.
5) I can think of other methods using, e.g., ConTeXt or pdflatex, but they get more and more involved.
NB: AbiWord doesn't work on intel based Mac
– inspectorG4dget
Jan 22 '14 at 18:31
add a comment |
1) The Open Source Word processor, AbiWord, includes an option of converting between any formats it knows on the commandline, including PDF e.g.,
abiword --to=pdf filename.html
(It'll also handle, e.g., MS Word .doc files, .docx, .odt, .rtf, etc., both input and output.)
I know it's available for Mac, though I've never used it on a mac.
2) The ebook-convert
command line program from calibre (on mac you need to follow the instructions here to get the commandline tools) is useful for many formats, too.
ebook-convert filename.html filename.pdf
It can handle .rtf and .odt input, and lots of ebook formats like .epub and .mobi.
3) PrinceXML can be used on the commandline, and will convert HTML to PDF very beautifully.
4) There's wkhtmltopdf, which uses the webkit engine to convert HTML to PDF from the commandline. I've never tried it.
5) I can think of other methods using, e.g., ConTeXt or pdflatex, but they get more and more involved.
1) The Open Source Word processor, AbiWord, includes an option of converting between any formats it knows on the commandline, including PDF e.g.,
abiword --to=pdf filename.html
(It'll also handle, e.g., MS Word .doc files, .docx, .odt, .rtf, etc., both input and output.)
I know it's available for Mac, though I've never used it on a mac.
2) The ebook-convert
command line program from calibre (on mac you need to follow the instructions here to get the commandline tools) is useful for many formats, too.
ebook-convert filename.html filename.pdf
It can handle .rtf and .odt input, and lots of ebook formats like .epub and .mobi.
3) PrinceXML can be used on the commandline, and will convert HTML to PDF very beautifully.
4) There's wkhtmltopdf, which uses the webkit engine to convert HTML to PDF from the commandline. I've never tried it.
5) I can think of other methods using, e.g., ConTeXt or pdflatex, but they get more and more involved.
answered Jan 5 '11 at 20:25
frabjous
8,52822726
8,52822726
NB: AbiWord doesn't work on intel based Mac
– inspectorG4dget
Jan 22 '14 at 18:31
add a comment |
NB: AbiWord doesn't work on intel based Mac
– inspectorG4dget
Jan 22 '14 at 18:31
NB: AbiWord doesn't work on intel based Mac
– inspectorG4dget
Jan 22 '14 at 18:31
NB: AbiWord doesn't work on intel based Mac
– inspectorG4dget
Jan 22 '14 at 18:31
add a comment |
For plain text files, you can use enscript
(comes with OS X) to generate a postscript file.
$ enscript -p ~/Desktop/profile.ps /etc/profile
[ 1 pages * 1 copy ] left in /Users/dharris/Desktop/profile.ps
OS X's Preview app can open (and convert) to PDF, or you can install ps2pdf (I installed it via macports) and convert at the command line.
$ ps2pdf ~/Desktop/profile.ps ~/Desktop/profile.pdf
What if I wanted to do something more graphically intensive? Say, converting an HTML page to PDF from the terminal?
– tambler
Jan 5 '11 at 17:53
I know this is old, but PhantomJS can do this, and it does it very well.
– Brad
Jun 13 '13 at 3:34
add a comment |
For plain text files, you can use enscript
(comes with OS X) to generate a postscript file.
$ enscript -p ~/Desktop/profile.ps /etc/profile
[ 1 pages * 1 copy ] left in /Users/dharris/Desktop/profile.ps
OS X's Preview app can open (and convert) to PDF, or you can install ps2pdf (I installed it via macports) and convert at the command line.
$ ps2pdf ~/Desktop/profile.ps ~/Desktop/profile.pdf
What if I wanted to do something more graphically intensive? Say, converting an HTML page to PDF from the terminal?
– tambler
Jan 5 '11 at 17:53
I know this is old, but PhantomJS can do this, and it does it very well.
– Brad
Jun 13 '13 at 3:34
add a comment |
For plain text files, you can use enscript
(comes with OS X) to generate a postscript file.
$ enscript -p ~/Desktop/profile.ps /etc/profile
[ 1 pages * 1 copy ] left in /Users/dharris/Desktop/profile.ps
OS X's Preview app can open (and convert) to PDF, or you can install ps2pdf (I installed it via macports) and convert at the command line.
$ ps2pdf ~/Desktop/profile.ps ~/Desktop/profile.pdf
For plain text files, you can use enscript
(comes with OS X) to generate a postscript file.
$ enscript -p ~/Desktop/profile.ps /etc/profile
[ 1 pages * 1 copy ] left in /Users/dharris/Desktop/profile.ps
OS X's Preview app can open (and convert) to PDF, or you can install ps2pdf (I installed it via macports) and convert at the command line.
$ ps2pdf ~/Desktop/profile.ps ~/Desktop/profile.pdf
answered Jan 5 '11 at 15:58
Doug Harris
20.2k1463103
20.2k1463103
What if I wanted to do something more graphically intensive? Say, converting an HTML page to PDF from the terminal?
– tambler
Jan 5 '11 at 17:53
I know this is old, but PhantomJS can do this, and it does it very well.
– Brad
Jun 13 '13 at 3:34
add a comment |
What if I wanted to do something more graphically intensive? Say, converting an HTML page to PDF from the terminal?
– tambler
Jan 5 '11 at 17:53
I know this is old, but PhantomJS can do this, and it does it very well.
– Brad
Jun 13 '13 at 3:34
What if I wanted to do something more graphically intensive? Say, converting an HTML page to PDF from the terminal?
– tambler
Jan 5 '11 at 17:53
What if I wanted to do something more graphically intensive? Say, converting an HTML page to PDF from the terminal?
– tambler
Jan 5 '11 at 17:53
I know this is old, but PhantomJS can do this, and it does it very well.
– Brad
Jun 13 '13 at 3:34
I know this is old, but PhantomJS can do this, and it does it very well.
– Brad
Jun 13 '13 at 3:34
add a comment |
You could also use pandoc from http://johnmacfarlane.net/pandoc/installing.html
With this command you would convert the html file to pdf:
pandoc -o output.pdf input.html
But note that pandoc uses LaTeX for the conversion, so you have to have a LaTeX system installed (http://www.tug.org/mactex/).
Pandoc can also convert to other formats like .odt, .docx and .epub
add a comment |
You could also use pandoc from http://johnmacfarlane.net/pandoc/installing.html
With this command you would convert the html file to pdf:
pandoc -o output.pdf input.html
But note that pandoc uses LaTeX for the conversion, so you have to have a LaTeX system installed (http://www.tug.org/mactex/).
Pandoc can also convert to other formats like .odt, .docx and .epub
add a comment |
You could also use pandoc from http://johnmacfarlane.net/pandoc/installing.html
With this command you would convert the html file to pdf:
pandoc -o output.pdf input.html
But note that pandoc uses LaTeX for the conversion, so you have to have a LaTeX system installed (http://www.tug.org/mactex/).
Pandoc can also convert to other formats like .odt, .docx and .epub
You could also use pandoc from http://johnmacfarlane.net/pandoc/installing.html
With this command you would convert the html file to pdf:
pandoc -o output.pdf input.html
But note that pandoc uses LaTeX for the conversion, so you have to have a LaTeX system installed (http://www.tug.org/mactex/).
Pandoc can also convert to other formats like .odt, .docx and .epub
answered Jul 5 '13 at 16:06
nnn
14616
14616
add a comment |
add a comment |
For local web page files, you can try to use Download URLs as PDF Automator action. Download and install.
I had to start Automator in 32 bit mode:
Create an Automator Application that automatically receives files and folders as input, with this action as the only one. Save e.g. as Save as PDF
.
Open the Get Info dialog of your application, and check Open in 32-bit mode also here. Double-click it once to make sure Launch Services knows the application.
You can use this application from the command line like this:
osascript -e 'tell application "Save as PDF" to open { POSIX file "/path/to/file.html" as alias }'
Of course, you can wrap this in a nice AppleScript .scpt
, bash
function, shell script, or what not.
This solution is actually pretty flexible. I was able to convert text files and HTML files, and the Automator action is also somewhat configurable.
add a comment |
For local web page files, you can try to use Download URLs as PDF Automator action. Download and install.
I had to start Automator in 32 bit mode:
Create an Automator Application that automatically receives files and folders as input, with this action as the only one. Save e.g. as Save as PDF
.
Open the Get Info dialog of your application, and check Open in 32-bit mode also here. Double-click it once to make sure Launch Services knows the application.
You can use this application from the command line like this:
osascript -e 'tell application "Save as PDF" to open { POSIX file "/path/to/file.html" as alias }'
Of course, you can wrap this in a nice AppleScript .scpt
, bash
function, shell script, or what not.
This solution is actually pretty flexible. I was able to convert text files and HTML files, and the Automator action is also somewhat configurable.
add a comment |
For local web page files, you can try to use Download URLs as PDF Automator action. Download and install.
I had to start Automator in 32 bit mode:
Create an Automator Application that automatically receives files and folders as input, with this action as the only one. Save e.g. as Save as PDF
.
Open the Get Info dialog of your application, and check Open in 32-bit mode also here. Double-click it once to make sure Launch Services knows the application.
You can use this application from the command line like this:
osascript -e 'tell application "Save as PDF" to open { POSIX file "/path/to/file.html" as alias }'
Of course, you can wrap this in a nice AppleScript .scpt
, bash
function, shell script, or what not.
This solution is actually pretty flexible. I was able to convert text files and HTML files, and the Automator action is also somewhat configurable.
For local web page files, you can try to use Download URLs as PDF Automator action. Download and install.
I had to start Automator in 32 bit mode:
Create an Automator Application that automatically receives files and folders as input, with this action as the only one. Save e.g. as Save as PDF
.
Open the Get Info dialog of your application, and check Open in 32-bit mode also here. Double-click it once to make sure Launch Services knows the application.
You can use this application from the command line like this:
osascript -e 'tell application "Save as PDF" to open { POSIX file "/path/to/file.html" as alias }'
Of course, you can wrap this in a nice AppleScript .scpt
, bash
function, shell script, or what not.
This solution is actually pretty flexible. I was able to convert text files and HTML files, and the Automator action is also somewhat configurable.
answered Jan 5 '11 at 18:35
Daniel Beck♦
92k12232284
92k12232284
add a comment |
add a comment |
First get the printer name
lpstat -p
Then use the printer name (Canon1234 - for eg)
lp -d Canon1234 PathToDocument.pdf
Op is looking to print an arbitrary file to a pdf document, not print a pdf to a real printer.
– cde
Nov 8 at 3:37
add a comment |
First get the printer name
lpstat -p
Then use the printer name (Canon1234 - for eg)
lp -d Canon1234 PathToDocument.pdf
Op is looking to print an arbitrary file to a pdf document, not print a pdf to a real printer.
– cde
Nov 8 at 3:37
add a comment |
First get the printer name
lpstat -p
Then use the printer name (Canon1234 - for eg)
lp -d Canon1234 PathToDocument.pdf
First get the printer name
lpstat -p
Then use the printer name (Canon1234 - for eg)
lp -d Canon1234 PathToDocument.pdf
answered Oct 9 '15 at 8:11
Thejus Krishna
1091
1091
Op is looking to print an arbitrary file to a pdf document, not print a pdf to a real printer.
– cde
Nov 8 at 3:37
add a comment |
Op is looking to print an arbitrary file to a pdf document, not print a pdf to a real printer.
– cde
Nov 8 at 3:37
Op is looking to print an arbitrary file to a pdf document, not print a pdf to a real printer.
– cde
Nov 8 at 3:37
Op is looking to print an arbitrary file to a pdf document, not print a pdf to a real printer.
– cde
Nov 8 at 3:37
add a comment |
Actually it's a lot easier than that. You can just type on the command line open *.pdf
and Preview will open with all the files there. Weirdly though if you type open *.pdf */*.pdf
you get two windows. In each you then have to go into the side bar, select one of the boxy formats (if there are a lot of files it opens by default in list format which doesn't work) type CMD-A to select all, then use the print-selected-pages command to get all of them.
add a comment |
Actually it's a lot easier than that. You can just type on the command line open *.pdf
and Preview will open with all the files there. Weirdly though if you type open *.pdf */*.pdf
you get two windows. In each you then have to go into the side bar, select one of the boxy formats (if there are a lot of files it opens by default in list format which doesn't work) type CMD-A to select all, then use the print-selected-pages command to get all of them.
add a comment |
Actually it's a lot easier than that. You can just type on the command line open *.pdf
and Preview will open with all the files there. Weirdly though if you type open *.pdf */*.pdf
you get two windows. In each you then have to go into the side bar, select one of the boxy formats (if there are a lot of files it opens by default in list format which doesn't work) type CMD-A to select all, then use the print-selected-pages command to get all of them.
Actually it's a lot easier than that. You can just type on the command line open *.pdf
and Preview will open with all the files there. Weirdly though if you type open *.pdf */*.pdf
you get two windows. In each you then have to go into the side bar, select one of the boxy formats (if there are a lot of files it opens by default in list format which doesn't work) type CMD-A to select all, then use the print-selected-pages command to get all of them.
edited Oct 9 '15 at 8:30
kenorb
10.7k1577111
10.7k1577111
answered May 5 '11 at 12:52
Joanna Bryson
91
91
add a comment |
add a comment |
you can add pdf printer driver from using pdf printer
- first install
pdf printer
from the store then - start
pdf printer
go to system preferences
open printers and scanners
click
+
buttonin printers list select
pdf printer
wait for a second
then click add
set
pdf printer
as default printer then close...
open terminal
then execute the command for print a file
lp /path/to/your/file/to/print.txt
add a comment |
you can add pdf printer driver from using pdf printer
- first install
pdf printer
from the store then - start
pdf printer
go to system preferences
open printers and scanners
click
+
buttonin printers list select
pdf printer
wait for a second
then click add
set
pdf printer
as default printer then close...
open terminal
then execute the command for print a file
lp /path/to/your/file/to/print.txt
add a comment |
you can add pdf printer driver from using pdf printer
- first install
pdf printer
from the store then - start
pdf printer
go to system preferences
open printers and scanners
click
+
buttonin printers list select
pdf printer
wait for a second
then click add
set
pdf printer
as default printer then close...
open terminal
then execute the command for print a file
lp /path/to/your/file/to/print.txt
you can add pdf printer driver from using pdf printer
- first install
pdf printer
from the store then - start
pdf printer
go to system preferences
open printers and scanners
click
+
buttonin printers list select
pdf printer
wait for a second
then click add
set
pdf printer
as default printer then close...
open terminal
then execute the command for print a file
lp /path/to/your/file/to/print.txt
answered Dec 14 at 4:50
NuOne T Attygalle
101
101
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f229418%2fpossible-to-print-to-pdf-from-mac-terminal%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What sort of file? plain text?
– Doug Harris
Jan 5 '11 at 15:46
1
@Daniel, I should've been more clear in my question: What sort of source file? -- My answer below will work for plain text files, but not for images.
– Doug Harris
Jan 5 '11 at 16:06
@Doug I apologize, I actually misread the question.
– Daniel Beck♦
Jan 5 '11 at 16:08
1
@Daniel - What I'm really aiming for is something more graphically intensive, say HTML pages. Is this possible?
– tambler
Jan 5 '11 at 18:05
1
Your main problem probably is, that the viewer application is file format dependent. Make up your mind what format you want and you'll get specific answers.
– Daniel Beck♦
Jan 5 '11 at 18:41