| View previous topic :: View next topic |
| Author |
Message |
vwenger General User

Joined: 08 Jun 2007 Posts: 13
|
Posted: Sat Aug 21, 2010 7:16 am Post subject: How do I print a pdf file from Shell command? |
|
|
Have the following code which will open a pdf file, but I cannot figure out how to print it and then close it.
| Code: | Sub OpenDOC_PDF
Dim fileType, filterType as string
Dim oSvc as Object
oDoc = ThisComponent
On Error Goto ExitSub
fileType=".pdf"
filePath="/home/user/Files/"
fileName = "pdf file"
PathName = ConvertToURL( filePath & fileName & fileType )
Shell("kpdf " + PathName )
ExitSub:
End Sub |
I am using Debian and OpenOffice.org 3. I do not know much at all about using Shell or commands. Any help would be appreciated. Thanks |
|
| Back to top |
|
 |
Robert Tucker Moderator


Joined: 16 Aug 2004 Posts: 3367 Location: Manchester UK
|
Posted: Sat Aug 21, 2010 9:06 am Post subject: |
|
|
Can you not use the lpr commend? _________________ LibreOffice 3.6.6 on Fedora 18, LibreOffice 4.0.2 on Ubuntu 13.04 (Double Boot) |
|
| Back to top |
|
 |
vwenger General User

Joined: 08 Jun 2007 Posts: 13
|
Posted: Mon Aug 23, 2010 6:19 am Post subject: |
|
|
Thanks for the reply. I have tried:
| Code: | | Shell("lpr " + PathName ) |
instead of
| Code: | | Shell("kpdf " + PathName ) |
If that is what you mean, then "No," that did not work. |
|
| Back to top |
|
 |
Robert Tucker Moderator


Joined: 16 Aug 2004 Posts: 3367 Location: Manchester UK
|
Posted: Mon Aug 23, 2010 12:33 pm Post subject: |
|
|
Sorry I was thinking you just wanted to print from the command line.
I don't have a printer connected to my home computer, but I think you need something like:
| Code: | | lpr -P <printername> PathName |
Incidentally I found that your macro didn't work for me until I removed the ConvertToURL, i.e.
| Code: | Sub PDFprint
Dim fileType, filterType as string
Dim oSvc as Object
oDoc = ThisComponent
On Error Goto ExitSub
fileType=".pdf"
filePath="/home/username/"
fileName = "test"
PathName = filePath & fileName & fileType
Shell("acroread " + PathName )
ExitSub:
End Sub |
_________________ LibreOffice 3.6.6 on Fedora 18, LibreOffice 4.0.2 on Ubuntu 13.04 (Double Boot) |
|
| Back to top |
|
 |
vwenger General User

Joined: 08 Jun 2007 Posts: 13
|
Posted: Mon Aug 23, 2010 5:33 pm Post subject: |
|
|
I believe the ConvertToURL is needed in my case since my folder name contains spaces.
The lpr and the lp command really does not do anything. No error, nothing printed or spooled. Maybe it is because I am trying to print a PDF document and not a text document.
I am using a Brother HL 2140 printer which is using a postscript driver.
Any other ideas? Anyone? |
|
| Back to top |
|
 |
Robert Tucker Moderator


Joined: 16 Aug 2004 Posts: 3367 Location: Manchester UK
|
|
| Back to top |
|
 |
Robert Tucker Moderator


Joined: 16 Aug 2004 Posts: 3367 Location: Manchester UK
|
Posted: Tue Aug 24, 2010 6:39 am Post subject: |
|
|
Have you tried the lpr command simply at the command line with just say a simple text file? _________________ LibreOffice 3.6.6 on Fedora 18, LibreOffice 4.0.2 on Ubuntu 13.04 (Double Boot) |
|
| Back to top |
|
 |
|