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

Is it possible to batch print?

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Writer
View previous topic :: View next topic  
Author Message
dreadnought
General User
General User


Joined: 20 Aug 2004
Posts: 10

PostPosted: Fri Aug 20, 2004 10:35 am    Post subject: Is it possible to batch print? Reply with quote

I would like to print a folder full of documents .. in this particular case, I would like to print @ 150 HTML files to Adobe Distiller. Is this possible with the lattest version of OpenOffice? I'm also curious if I can batch convert all the files to Adobe Acrobat format first, and then batch print them?

Thanks for the advice!
Back to top
View user's profile Send private message
David
Super User
Super User


Joined: 24 Oct 2003
Posts: 5668
Location: Canada

PostPosted: Fri Aug 20, 2004 3:07 pm    Post subject: Re: Is it possible to batch print? Reply with quote

dreadnought wrote:
I would like to print a folder full of documents .. in this particular case, I would like to print @ 150 HTML files to Adobe Distiller. Is this possible with the lattest version of OpenOffice? I'm also curious if I can batch convert all the files to Adobe Acrobat format first, and then batch print them?

Thanks for the advice!


Will this answer your question?

http://www.pdfstore.com/details.asp?ProdID=39

David.
Back to top
View user's profile Send private message
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Sat Aug 21, 2004 7:52 am    Post subject: Re: Is it possible to batch print? Reply with quote

dreadnought wrote:
I would like to print a folder full of documents .. in this particular case, I would like to print @ 150 HTML files to Adobe Distiller.


Would it help to be able to just convert an entire folder (and all sub folders) of html documents directly to PDF?

Code:
Sub Main
   '----------
   ' CHANGE ME !!!
   ' Pathname must be that of a FOLDER not a FILE.
   '
   cSourceFolder = "C:\Documents and Settings\dbrewer\Desktop\Test"
   '
   '----------
   

   ' Convert from pathname into a URL.
   cSourceFolderUrl = ConvertToUrl( cSourceFolder )

   oSimpleFileAccess = createUnoService( "com.sun.star.ucb.SimpleFileAccess" )
   If Not oSimpleFileAccess.isFolder( cSourceFolderUrl ) Then
      MsgBox( "You must specify a folder to convert, not a file." )
      Exit Sub
   EndIf
   
   ' Convert a folder full of HTML into PDF.
   ' All sub-folders are also processed, so beware of passing
   '  the root of your hard drive, as all HTML files on your entire
   '  drive would be processed.
   DoFolder( oSimpleFileAccess, cSourceFolderUrl )
End Sub



Sub DoFolder( oSimpleFileAccess, cFolderUrl )
   
   ' Get an array of the names of items in this folder.
   aFolderItems = oSimpleFileAccess.getFolderContents( cFolderUrl, True )
   
   ' Now iterate over each item in this folder.
   For i = LBound( aFolderItems ) To UBound( aFolderItems )
      ' Get the name of an item in this cFolderUrl.
      cFolderItemUrl = aFolderItems( i )
      
      ' Is this item a sub folder?
      If oSimpleFileAccess.isFolder( cFolderItemUrl ) Then
         ' Process a sub-folder
         DoFolder( oSimpleFileAccess, cFolderItemUrl )
      Else
         ' Process a file.
         DoAFile( cFolderItemUrl )
      EndIf
   Next
End Sub




Sub DoAFile( cSourceDocUrl )

   ' Open Html as a Writer document
   ' The Hidden property causes the document window to be invisible
   '  so that you don't see a bunch of windows suddenly pop up and then disappear.
   ' If you open the documents invisible then BE SURE to close them again!
   ' (See below for the close step.)  Otherwise, you end up with a bunch of
   '  open documents, but they are invisible and the user is unable to close
   '  the invisible windows!
   oDoc = StarDesktop.loadComponentFromURL( cSourceDocUrl, "_blank", 0,_
         Array( MakePropertyValue( "FilterName", "HTML (StarWriter)" ),_
               MakePropertyValue( "Hidden", True ) ) )


   ' Save as SXW
   ' Same as cSourceDoc, but different extension
   cDestDoc = Left( cSourceDocUrl, Len( cSourceDocUrl ) - 4 ) + ".sxw"
   
   oDoc.storeToURL( cDestDoc, Array() )


   ' Save as DOC (i.e. EvilWord)
   ' Same as cSourceDoc, but different extension
   cDestDoc = Left( cSourceDocUrl, Len( cSourceDocUrl ) - 4 ) + ".doc"

   oDoc.storeToURL( cDestDoc,_
         Array( MakePropertyValue( "FilterName", "MS Word 97" ) ) )


   ' Save as PDF
   ' Same as cSourceDoc, but different extension
   cDestDoc = Left( cSourceDocUrl, Len( cSourceDocUrl ) - 4 ) + ".pdf"
   
   oDoc.storeToURL( cDestDoc,_
         Array( MakePropertyValue( "FilterName", "writer_pdf_Export" ) ) )


   ' Save as TXT
   ' Same as cSourceDoc, but different extension
   cDestDoc = Left( cSourceDocUrl, Len( cSourceDocUrl ) - 4 ) + ".txt"
   
   oDoc.storeToURL( cDestDoc,_
         Array( MakePropertyValue( "FilterName", "Text (encoded)" ) ) )
   
   
   ' Close the document
   ' If you don't do this, then you end up with a whole bunch of open
   '  documents in the office.
   oDoc.close( True )
End Sub


Function MakePropertyValue( Optional cName As String, Optional uValue ) As com.sun.star.beans.PropertyValue
   oPropertyValue = createUnoStruct( "com.sun.star.beans.PropertyValue" )
   If Not IsMissing( cName ) Then
      oPropertyValue.Name = cName
   EndIf
   If Not IsMissing( uValue ) Then
      oPropertyValue.Value = uValue
   EndIf
   MakePropertyValue = oPropertyValue
End Function

_________________
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
dreadnought
General User
General User


Joined: 20 Aug 2004
Posts: 10

PostPosted: Sun Aug 22, 2004 8:24 am    Post subject: Re: Is it possible to batch print? Reply with quote

David wrote:
dreadnought wrote:
I would like to print a folder full of documents .. in this particular case, I would like to print @ 150 HTML files to Adobe Distiller. Is this possible with the lattest version of OpenOffice? I'm also curious if I can batch convert all the files to Adobe Acrobat format first, and then batch print them?

Thanks for the advice!


Will this answer your question?

http://www.pdfstore.com/details.asp?ProdID=39

David.


Hi David,

Thanks for the link .. that would definitely help in my current situation, but I'm also looking for a solution that fits the bigger picture. Batch printing, batch converting, basically batch operations of any kind from the OpenOffice GUI. It doesn't look like batch features are currently available? I hope they are on the roadmap. Wink
Back to top
View user's profile Send private message
dreadnought
General User
General User


Joined: 20 Aug 2004
Posts: 10

PostPosted: Sun Aug 22, 2004 8:27 am    Post subject: Re: Is it possible to batch print? Reply with quote

DannyB wrote:
dreadnought wrote:
I would like to print a folder full of documents .. in this particular case, I would like to print @ 150 HTML files to Adobe Distiller.


Would it help to be able to just convert an entire folder (and all sub folders) of html documents directly to PDF?

Code:
Sub Main
   '----------
   ' CHANGE ME !!!
   ' Pathname must be that of a FOLDER not a FILE.
   '
   cSourceFolder = "C:\Documents and Settings\dbrewer\Desktop\Test"
   '
   '----------
   <snip>


Hi Danny!

I'm an OpenOffice newbie .. not sure where I would run/compile that code? But yes, simply batch converting a folder and all subfolders from HTML to PDF would be great.

Thanks!
Back to top
View user's profile Send private message
dreadnought
General User
General User


Joined: 20 Aug 2004
Posts: 10

PostPosted: Mon Aug 23, 2004 8:20 am    Post subject: Re: Is it possible to batch print? Reply with quote

DannyB wrote:
dreadnought wrote:
I would like to print a folder full of documents .. in this particular case, I would like to print @ 150 HTML files to Adobe Distiller.


Would it help to be able to just convert an entire folder (and all sub folders) of html documents directly to PDF?

Code:
Sub Main
   '----------
   ' CHANGE ME !!!
   ' Pathname must be that of a FOLDER not a FILE.
   '
   cSourceFolder = "C:\Documents and Settings\dbrewer\Desktop\Test"
   '
   '----------


Hi All,

Sorry for being spastic, but I really want to give this code a shot .. I'm just not sure where to put it. Browsing through the OpenOffice menu options I don't see a place to paste this code in? Unless this would be considered a macro?

Thanks for the newbie help!
Back to top
View user's profile Send private message
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Mon Aug 23, 2004 8:35 am    Post subject: Reply with quote

Here's how to run that code.

1. File --> New --> Drawing
(create a new drawing)

2. Tools --> Macros --> Macro...
(Macro dialog box appears)

3. In the left hand side of the dialog box, see the "Macro From" list. The first entry is "soffice". Scroll down in the list until you see your drawing, it probably has a name such as "Untitled34".

Underneath of Untitled34 you will see a macro library named "Standard". Click on Standard.
(Standard under Untitled34 is now highlighted.)

4. Near the right hand side of the Macro dialog, click the New button.
(The "New Module" dialog box appears on top of the Macro dialog box.)

5. Just accept the default name Module1 by clicking OK.
(Both the Macro dialog and the New Module dialog box disappear. They are replaced by a new window which is the Basic IDE. IDE=Integrated Development Environment.)

6. The first line says....
REM ***** BASIC *****

Select all of the text in the window, starting with the REM line, all the way to the last End Sub line, and delete all of that text.

7. In the now empty Basic IDE window, Paste in the entire program that I gave you above.

Be careful of lines that wrap around. When you copy code from a web site, one Basic statement might inadvertently wrap around on your screen onto a second line. This might cause a syntax error. (You might try stretching your web browser window real wide to possibly avoid this.)

Also note that some really long statements are on purpose continued onto a second/third line. Lines like this end with an underscore (_) as the last character of the line. Be sure that on lines ending with an underscore, like this....
Code:
   oDoc = StarDesktop.loadComponentFromURL( cSourceDocUrl, "_blank", 0,_
         Array( MakePropertyValue( "FilterName", "HTML (StarWriter)" ),_
               MakePropertyValue( "Hidden", True ) ) )

that the underscore really is the last character on the line.

One last thing, you might want to take this opportunity to change the line that is marked CHANGE ME so that it has a pathname of your choosing. Don't worry, you can always get back to the Basic IDE again in the future.

8. Close the Basic IDE window.

9. On your Drawing document, look at the left hand edge of the window. See a tall vertical toolbar.

Right click on an empty space in the toolbar.
RightClick --> Visible Buttons
make sure that the "Show Form Functions" button has a checkmark in the Visible Buttons submenu.

10. On the toolbar, click the Form Functions button, and tear off the form functions window. This is a small window with two rows of form function icons.

11. Make sure that the form is in design mode. All of the little form function icons should be enabled. To toggle the design mode on or off click on the icon whose tooltip says "Design mode on/off". This is the fourth icon from the right, on the bottom row.

12. With form design mode on (i.e. most Form Functions icons enabled), click on the Push Button icon. (Second button from left on top row.)

13. Move the pointer into the drawing. It changes to a crosshair. Click and drag a rectangle, then release the mouse button.
You just drew a button on the form. It should have little green handles around it which you can use to resize the button if you drew it too small.

14. Right click on your button and pick Control.....
RightClick --> Control....
(A Properties window appears.)

15. The Properties window has two tabs "General" and "Events". Click the Events tab.

16. The second row says "When Initiating", to the far right of "When Initiating" there is a small square button with three dots. Click that button.
(The Assign Macro dialog box appears.)

17. In the lower left of the dialog box, find your Untitled34 document. It probably says something like....
+ OpenOffice.org BASIC Macros
+ Untitled34 BASIC Macros

Unfold the plus sign next to Untitled34.

18. Under Untitled34, you now see another plus sign that says Standard. Unfold that plus sign to reveal Module1. (This is the module name you first saw in step 5 above. If you had changed the name from Module1 to, say, "Fred", then you would see "Fred" under Standard.)

Click on the Module1 that is under Standard, that is under Untitled34 Basic Macros.

Immediately to the right of where you clicked, a panel now shows the name of the functions. It is titled "Existing macros in Module1".

19. Click on the function named "Main".

20. Click the Assign button.

In the top of the Assign Macro dialog, you see that When Initiating is hilighted, and under Assigned Macro, Main( Standard, Module1) now appears.

21. Click OK.

22. On the Form Functions toolbar window (which you tore off in step 10), turn Design Mode off. (Similar but opposite to what you did in step 11). You do this by clicking on the Design Mode ON/Off button, which is the fourth button from the right on the bottom row.

23. File --> Save As....
(Save your drawing to disk, give it a filename.)


You now have a drawing macro document. Any time you open it and click on your button, it will run the macro. Note that the pathname of the folder was hardcoded into the macro.

Hope this helps.
_________________
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
dreadnought
General User
General User


Joined: 20 Aug 2004
Posts: 10

PostPosted: Mon Aug 23, 2004 8:37 am    Post subject: Awesome! Reply with quote

Thanks Danny! I'll try this now.
Back to top
View user's profile Send private message
dreadnought
General User
General User


Joined: 20 Aug 2004
Posts: 10

PostPosted: Mon Aug 23, 2004 10:40 am    Post subject: Reply with quote

DannyB wrote:
Here's how to run that code.

1. File --> New --> Drawing
(create a new drawing)

2. Tools --> Macros --> Macro...
(Macro dialog box appears)

<snip>

Hope this helps.


Hi Danny,

Your code was working great .. about half of @ 150 HTML documents converted perfectly. Eventually though, OpenOffice crashed. It gave me the option of sending feedback, which I declined until I can try the operation again after lunch.

On a somewhat related note .. how would I configure the OO PDF engine to do all conversions in landscape instead of portrait? I didn't see a parent option for "PDF" under the OO options.
Back to top
View user's profile Send private message
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Mon Aug 23, 2004 12:01 pm    Post subject: Reply with quote

Sorry to hear about OOo crashing. I wonder if the documents are getting closed?

You could try converting smaller batches?

In order to do landscape mode, the Writer documents would need to be changed to landscape mode. This is probably a page style change. I'm not familiar with it in Writer as much as in Draw. It can definitely be done. It is not something that I know right off the top of my head like I knew how to do the batch conversion where I can just whip up the code instantly.

Maybe someone can post how to programmatically change Writer into landscape?
_________________
Want to make OOo Drawings like the colored flower design to the left?
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 Writer 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