OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

How do I print a pdf file from Shell command?

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
vwenger
General User
General User


Joined: 08 Jun 2007
Posts: 13

PostPosted: Sat Aug 21, 2010 7:16 am    Post subject: How do I print a pdf file from Shell command? Reply with quote

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
View user's profile Send private message
Robert Tucker
Moderator
Moderator


Joined: 16 Aug 2004
Posts: 3407
Location: Manchester UK

PostPosted: Sat Aug 21, 2010 9:06 am    Post subject: Reply with quote

Can you not use the lpr commend?
_________________
OpenOffice 4.0.0 and LibreOffice 4.x.x on Fedora 20, Ubuntu 13.10, Windows 8.1 Preview (Triple Boot)
Back to top
View user's profile Send private message
vwenger
General User
General User


Joined: 08 Jun 2007
Posts: 13

PostPosted: Mon Aug 23, 2010 6:19 am    Post subject: Reply with quote

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
View user's profile Send private message
Robert Tucker
Moderator
Moderator


Joined: 16 Aug 2004
Posts: 3407
Location: Manchester UK

PostPosted: Mon Aug 23, 2010 12:33 pm    Post subject: Reply with quote

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

_________________
OpenOffice 4.0.0 and LibreOffice 4.x.x on Fedora 20, Ubuntu 13.10, Windows 8.1 Preview (Triple Boot)
Back to top
View user's profile Send private message
vwenger
General User
General User


Joined: 08 Jun 2007
Posts: 13

PostPosted: Mon Aug 23, 2010 5:33 pm    Post subject: Reply with quote

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
View user's profile Send private message
Robert Tucker
Moderator
Moderator


Joined: 16 Aug 2004
Posts: 3407
Location: Manchester UK

PostPosted: Tue Aug 24, 2010 2:28 am    Post subject: Reply with quote

I think I read somewhere that CUPS "understands" PDF.

These post suggests that the lpr command should work for PDF's:

http://h30434.www3.hp.com/t5/Other-printing-questions/Printing-PDFs-using-LPR-command/m-p/45520

http://www.phwinfo.com/forum/linux-debian-user/211137-printing-kpdf-does-not-work.html

Information on command line printing using Acrobat on Windows is here:

http://support.adobe.com/devsup/devsup.nsf/docs/52080.htm

I can't find anything similar for KPDF – I'm thinking maybe it's because lpr and CUPS is supposed to be able to handle it.
_________________
OpenOffice 4.0.0 and LibreOffice 4.x.x on Fedora 20, Ubuntu 13.10, Windows 8.1 Preview (Triple Boot)
Back to top
View user's profile Send private message
Robert Tucker
Moderator
Moderator


Joined: 16 Aug 2004
Posts: 3407
Location: Manchester UK

PostPosted: Tue Aug 24, 2010 6:39 am    Post subject: Reply with quote

Have you tried the lpr command simply at the command line with just say a simple text file?
_________________
OpenOffice 4.0.0 and LibreOffice 4.x.x on Fedora 20, Ubuntu 13.10, Windows 8.1 Preview (Triple Boot)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group