Print To Pdf File Linux Console

Posted on

Welcome to LinuxQuestions.org, a friendly and active Linux Community.You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Today!Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.Are you new to LinuxQuestions.org? Visit the following links: If you have any problems with the registration process or your account login, please.

Print To Pdf File Linux Console

If you need to reset your password,.Having a problem logging in? Please visit to clear all LQ-related cookies. Introduction to Linux - A Hands on GuideThis guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration.

This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.to receive this Complete Guide absolutely free. Hi,1 The manual page of ' lp' command does talk about an option called ' -U' to specify a user name along with the command invocation. But there is apparently no separate option for supplying a password with. So I also tried: '-U username/password' and '-U username: password' - in vain.Is there way to specify a username and a password to execute the 'lp' command in a Shell Script (Bash)?

Executing the command without the credentials does not prompt for any credentials and the job is held for authentication (can be noticed in the printer's status in GUI).2 One more thing. I am trying to print out 1st page of a PDF file. If I use ' pdftops' then its metadata are output. This is not desirable. Whatever is on the 1st page of the specified PDF file must be printed out as it is - as it happens in the case of printing out from within a PDF viewer (evince, for example) in the GUI mode.Yes, I have already done some homework and have not got any help by searching it on Google. So posting my questions here.Please also note that I do not wish to store my credentials in the settings of the printer itself.

Nor do I wish to keep my credentials static. If my script is going to be run by somebody else then I will read in the credentials and then pass them to the related options to be used for printing out.I am using CentOS 6.9 and my Repo has Packages from DVD 1 and DVD 2.Please also note:My Linux OS is running on a VM (a VirtualBox instance) and is connected through a DHCP Server which is a Windows Server (possibly as I have set up the VM in my Lab for demo purposes and used Bridged connection). So, to connect to the printer, I have used Windows SAMBA Share.

Whenever I give a print out, I get a prompt for entering my Windows AD (Active Directory) credentials and this works fine as long as I am printing out manually from the GUI / Desktop environment of my CentOS VM.So, I have not had to setup the CUPS utility. Any user who is running the script that prints out a particular log file or a pdf file needs to enter his/her Windows AD credentials and this happens only if the script is executed from within the GUI mode.

If run without entering the credentials, the print job is held for authentication. So, I need to pass the credentials from within the script itself. So, a user can hard-code his/her credentials on the system when wants to run the script. One can in fact use 'expect' as well but the prompt is a GUI one and not a CLI based. Hi,1 The manual page of ' lp' command does talk about an option called ' -U' to specify a user name along with the command invocation.

But there is apparently no separate option for supplying a password with. So I also tried: '-U username/password' and '-U username: password' - in vain.Is there way to specify a username and a password to execute the 'lp' command in a Shell Script (Bash)?

Executing the command without the credentials does not prompt for any credentials and the job is held for authentication (can be noticed in the printer's status in GUI).Yes, I have already done some homework and have not got any help by searching it on Google. So posting my questions here.Please also note that I do not wish to store my credentials in the settings of the printer itself. Nor do I wish to keep my credentials static. If my script is going to be run by somebody else then I will read in the credentials and then pass them to the related options to be used for printing out.You will find a lot of help hereIt is easily possible to allow different users different permissions to print through cups policy.

This allows you to print without a password, while being able to set that other users cannot print without a password.Hope this works for you. You will find a lot of help hereIt is easily possible to allow different users different permissions to print through cups policy. This allows you to print without a password, while being able to set that other users cannot print without a password.Hope this works for you.Apologies for not specifying in my original post this one key thing:My Linux OS is running on a VM (a VirtualBox instance) and is connected through a DHCP Server which is a Windows Server (possibly as I have set up the VM in my Lab for demo purposes and used Bridged connection). So, to connect to the printer, I have used Windows SAMBA Share. Whenever I give a print out, I get a prompt for entering my Windows AD (Active Directory) credentials and this works fine as long as I printing out manually from the GUI / Desktop environment of my CentOS VM.So, I have not had to setup the CUPS utility. Any user who is running the script that prints out a particular log file or a pdf file needs to enter his/her Windows AD credentials and this happens only if the script is executed from within the GUI mode.

If run without entering the credentials, the print job is held for authentication. So, I need to pass the credentials from within the script itself. So, a user can hard-code the credentials on his system when wants to run the script. One can in fact use 'expect' as well but the prompt is a GUI one and not a CLI based. 1 The manual page of ' lp' command does talk about an option called ' -U' to specify a user name along with the command invocation. But there is apparently no separate option for supplying a password with. So I also tried: '-U username/password' and '-U username: password' - in vain.Is there way to specify a username and a password to execute the 'lp' command in a Shell Script (Bash)?

Executing the command without the credentials does not prompt for any credentials and the job is held for authentication (can be noticed in the printer's status in GUI).Yes, sudo will let you do this, as its sole purpose is to allow a user to execute things as another user, and not just root. Read the man page on sudo, paying particular attention to the '-u' flag.

Quote:2 One more thing. I am trying to print out 1st page of a PDF file.

If I use ' pdftops' then its metadata are output. This is not desirable. Whatever is on the 1st page of the specified PDF file must be printed out as it is - as it happens in the case of printing out from within a PDF viewer (evince, for example) in the GUI mode.Yes, I have already done some homework and have not got any help by searching it on Google. So posting my questions here.Very first hit in Google for 'how to print one page of a pdf in linux' is.a how-to, containing MANY options, including the qpdf program stated here. And you say you looked on Google first????

Print

Quote:Please also note that I do not wish to store my credentials in the settings of the printer itself. Nor do I wish to keep my credentials static.

If my script is going to be run by somebody else then I will read in the credentials and then pass them to the related options to be used for printing out.I am using CentOS 6.9 and my Repo has Packages from DVD 1 and DVD 2.Once you use sudo or su correctly in your script (and if you write your script correctly), it should prompt the user, and they can input their own credentials. Quote:Very first hit in Google for 'how to print one page of a pdf in linux' is.a how-to, containing MANY options, including the qpdf program stated here. And you say you looked on Google first????Yes, I did see that page as well before posting my question here. They are talking about 'extracting pages from a pdf file' adding an extra step to the job of printing out a specific number of pages only. As suggested here, I have installed 'qpdf' which may do the job fine.

But this package not being part of a standard installation and not even being shipped with the CentOS 6.9 DVD 1 and 2, I cannot presume it be sitting on another similar Linux machine setup. As we do our jobs, we do them under some security guidelines and have to follow certain policies. I did not wish to describe all those things in my original question.

I welcome anything new but I have to do what is allowed in the process/system. I hope you understand the limitations thrown by the system/process created by stupid managers who are not techies.

One such instance is: If it is not on the installation media, don't download it from the Internet.We can drop this PDF part from our discussion for the time being. Now the question remains: How to read credentials from a user and pass those credentials to 'lp' or 'lpr' command to print out a specific log file that could be a text file or a pdf file? As the 'lp' and 'lpr' commands are shipped with the installation media, we can use them at will and modify their behaviour if needed. Please note that the credentials are required as the printer has been added as a Windows SAMBA Share. (I have updated my post to include this fact I had missed while posting the question.). Quote:But this package not being part of a standard installation and not even being shipped with the CentOS 6.9 DVD 1 and 2, I cannot presume it be sitting on another similar Linux machine setup. As we do our jobs, we do them under some security guidelines and have to follow certain policies.

I did not wish to describe all those things in my original question. I welcome anything new but I have to do what is allowed in the process/system. I hope you understand the limitations thrown by the system/process created by stupid managers who are not techies. One such instance is: If it is not on the installation media, don't download it from the Internet.So then why/how did you install it? Because if it was on the install media, then there's no problem in listing it in the RPM file you build to deploy your scripts, as a prerequisite, which will then install qpdf as part of the 'secure' installation. Since you say this is the environment you're in, and you're a developer with years of experience, packaging your script(s) into an RPM file would seem to make the most sense for what you describe.If it wasn't on the install media, then your solution of qpdf won't work anywhere in your 'secure' environment.

Quote:We can drop this PDF part from our discussion for the time being. Now the question remains: How to read credentials from a user and pass those credentials to 'lp' or 'lpr' command to print out a specific log file that could be a text file or a pdf file? As the 'lp' and 'lpr' commands are shipped with the installation media, we can use them at will and modify their behaviour if needed.

Please note that the credentials are required as the printer has been added as a Windows SAMBA Share. (I have updated my post to include this fact I had missed while posting the question.)There are thousands of bash-scripting examples that show you how to prompt a user for input.U '$adloginname'.Yes, I tried out the 'qpdf' package on my local test VM.From your experience of 'lp' and 'lpr', can you tell if there is a way to specify a password along with a user name when those commands are executed from the command line?Talking about my experience, I can do my job with a ghost script to extract pages from a PDF, so that is not a problem. The only challenge is I have been asked to use only 'lp' or 'lpr' command to submit a print job successfully. In fact, the manager in the question is sticking to 'lpr' as he is using CygWin that I have not ever used and 'lp' command is missing in his environment.If my query sounds too much vague still, please let me know and I will close it myself.

Quote:Talking about my experience, I can do my job with a ghost script to extract pages from a PDF, so that is not a problem. The only challenge is I have been asked to use only 'lp' or 'lpr' command to submit a print job successfully.

In fact, the manager in the question is sticking to 'lpr' as he is using CygWin that I have not ever used and 'lp' command is missing in his environment. If my query sounds too much vague still, please let me know and I will close it myself.Can't give you a more clear answer than what you got. An example of 'lp' or 'lpr' command in which you pass user name and password from the command line itself?Here is an example:lp readme.txt -P 1-0That will print the first 10 pages of the said file. Please extend that command to include a user name and a password, if it is possible with 'lp' or 'lpr'.Very possible, and the man page for lp can get you started, and you can also find several examples on the CUPS site, about setting a CUPSUSER environment variable (which can be done via script, as you know), or having CUPS prompt you for a user id/password.

Again, the CUPS configuration documentation can tell you how.

Part 1: Top 3 Free Ways to Print to PDF on Mac (macOS 10.14 Mojave)There are several virtual printers which can help you print to PDF files on your Mac OS X. There are no download fees required, so all of these PDF software are free and easy installable.#1: PDFelement Pro for Mac – The Best PDF SolutionPDFelement Pro allows you to print to PDF from existing PDF, images, Webpages, text files and more as easy as a breeze. Simply open the webpage, image or file with this virtual PDF printer, then you can directly save it as PDF format. You also can import multiple files and save them into a single PDF file. What's more, this program comes with many functional PDF editing tools so you can make any changes on your PDF documents.

#2: Directly Print to PDF on Mac OSHaving your Mac OS X updated to versions later than 10.6.8. Should help you get your PDF files printed with no additional troubles. Updated versions of Mac OS system have built-in PDF print and convert features which comes with standard update packages, so you just have to click a few times and your PDFs will be ready for printing process.

You can update your Mac OS to latest versions with PDF printing features by downloading free operative system updates on Mac App Store, all free of fees.Steps for Printing PDF Files on MacMac OS X is a great threat to competitors when it comes to printing PDF, because it already has built-in PDF features. Few Mac versions with exception of Mac Tiger, has built-in option inside Mac operative system, so you can run PDF printing without having to install PDF printer software by following some simple steps.Step 1.

Opening and choosing filesChoose the documents or files you want to print in PDF, using your Mac application you have previously downloaded and installed. Once you have chosen your document, open the File drop-down menu and chose Print. #3: CUPS-PDF – Free Virtual Printer for Mac OS XThis virtual printer is genuinely designed for converting PDF files and documents on Mac OS X, but it also has features of printer software, making the process of PDF printing a lot faster and easier. CUPS stands out because of its advanced built-in features, which allows you to reduce the time needed for choosing and printing PDF without having to go through picking out the printing type, dealing with dialog box and choosing the file location every time you print your saved files.

By making CUPS your default virtual printer, you can just create a shortcut command and manage your PDF printing from Mac OS X desktop. Part 2: How to Print to PDF on Widows, Vista and XPPrinting PDF files might be a little harder in Windows, Vista and XP operative systems than it would appear to be on Mac, but you can definitely download some virtual PDF printer software, which could help you convert and print your PDFs easy and fast. PDF is a lot more economic in saving your paper, and as a big plus, your files are organized better, so here are few tricks and tips on how to install virtual PDF printer software and print to PDF on Windows 7, Windows 8, Vista and XP.Method 1: Print to PDF on Vista with CutePDFCutePDF is one great printer app, which should help you get your files ready to be properly printed in PDF format. It is available for free download, but even though it works on 64-bit Vista version, and which most products don't, it can't be installed unattended, so here are some tips on how to install and start using your CutePDF and print your PDF files on Vista.Steps on Printing PDF on VistaStep 1: Installing ghostscriptThis part of CutePDF installation is very important, for this is the script which will later convert your files into PDF. Installation is simple and easy.

Method 2: Print to PDF with BullZipBullZip is a free PDF printer that works on Windows 7 and 8, Vista and XP operative system. You can download BullZip PDF printer for free, and begin installation easy and without doing anything more than few clicks. BullZip virtual printer can be used by ten different users, and has to offer a great number of useful PDF printing features. It has user-friendly interface, passwords to protect your PDF files and documents, supports multiple outputs and is easy to use.

You can print and convert any almost any Windows file to PDF and print it easily in just few steps. Printing to PDF is simple, so basically you will be lead by BullZip app itself. Method 3: Print to PDF Online InstantlyUnfortunately, unlike Mac OS, Windows operative systems don't have PDF built in, so it might take more than just two steps to get your PDF printed. If you dislike downloading, installing and setting up various software and apps, then Web2PDF will be your favorite free PDF converter. There is no need for PDF converters on Mac, you can simply choose the PDF type as an available built-in system option, but if you run on Windows operative system, you will need to convert your files manually before printing. Part 3: How to Print to PDF on Ubuntu (Linux)Ubuntu is not so easily manageable as Windows and Mac operative programs, so if you are not particularly tech sawy, you should avoid having Linux as your operative system.

Also, you will have to put an effort into converting and printing your files to PDF, since Ubuntu, just like Windows, don't have PDF built-in. But as for every other operative system, there are several great virtual printers also designed for printing PDF in Ubuntu Linux.Method 1: Print to PDF in Linux Ubuntu with CUPS-PDFCUPS works great on any Linux program, including Ubuntu, helping you generate your PDF files. This app uses ghostscripts for translating files you choose into PDF, so you can later choose the PDF file type for printing. You can download CUPS-PDF for free, install it and set it up fast and easy, step-by-step.Step 1. Getting started with setting upTo get started, you first need to find Ubuntu Software Center in Application menu, like given on the screenshot. Method 2: Create Ubuntu PDF Virtual PrinterCreating your own virtual printer by manipulating your operative system carries some amenities with it along the way. Ubuntu has option which allows you to program and make PDF printing possible without having to download virtual printer app.

You can do it all by yourself, inside the system itself, by following few simple steps.Step 1. Creating your PDF printing optionsFirst, you need to open the terminal and type in the commands: sudo apt-get install cups-pdf.Step 2. Choosing PDF file typeWhen the installation is completed, you can move on further by System Settings and choosing Printer option. If everything went well with the installation, there should be a printer symbol called PDF.