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

conversion of first page or 5 pages of doc to pdf

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


Joined: 26 Oct 2006
Posts: 18

PostPosted: Fri Oct 27, 2006 2:03 am    Post subject: conversion of first page or 5 pages of doc to pdf Reply with quote

Hello,

How to convert the first page or the first 5 pages of a doc to a pdf document from command line Question

I have been successful to convert it to pdf using the "writer_pdf_Export" filter in the macro and then calling the macro from the command line.

But, I am not sure how to just convert the first page or first 5 pages alone to pdf rather than all the pages.

Thanks in advance Very Happy
Mohan
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 Oct 27, 2006 5:50 am    Post subject: Re: conversion of first page or 5 pages of doc to pdf Reply with quote

Delete all the other pages. [Do not resave, of course]. Then form the PDF from there.

David.
Back to top
View user's profile Send private message
mohanmg
General User
General User


Joined: 26 Oct 2006
Posts: 18

PostPosted: Sun Oct 29, 2006 6:19 pm    Post subject: Re: conversion of first page or 5 pages of doc to pdf Reply with quote

Thanks a lot David for the reply.

As it has to be done from the command line, can you please provide me a hint of some macro code snippet, that can guide me

how to write code to navigate to pages and then delete them.

or

call some delete/delete pages method provided by the Document model.

Thanks again,
Mohan
Back to top
View user's profile Send private message
mohanmg
General User
General User


Joined: 26 Oct 2006
Posts: 18

PostPosted: Mon Oct 30, 2006 1:18 am    Post subject: Reply with quote

I found that there is com.sun.star.text.XPageCursor has jumpToPage(int) method. But, I don't know how to get the XPageCursor from the document controller.

For getting XPageCursor, I understand that the document cannot be opened in hidden mode. So, I open it in non hidden mode.

oDoc = StarDesktop.loadComponentFromURL( cURL, "_blank", 0, Array( ) )

After this, I get the controller.

docController = oDoc.currentController

But, I am not able to get the pagecursor from the docController. Any ideas would help. Actually, if I could get the pageCursor, then I can use

jumpToPage method and then select the contents until the end, cut the selection, save to pdf and then close the original document.

I have an idea to select until the end from the current cursor position using the code. Hope it is correct! Smile

'create a dispatcher
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

'select the contents from the current cursor position to end of the document
dispatcher.executeDispatch(document, ".uno:EndOfDocumentSel", "", 0, Array())

'Now cut the information from page 2 to the end of the document
dispatcher.executeDispatch(document, ".uno:Cut", "", 0, Array())

Any help would be greatly appreciated.

Thanks in advance Smile
Mohan
Back to top
View user's profile Send private message
mohanmg
General User
General User


Joined: 26 Oct 2006
Posts: 18

PostPosted: Mon Oct 30, 2006 1:48 am    Post subject: how to delete the contents from a given page? Reply with quote

Some progress has been made.

I am able to jump to a particular page, by being able to get the view cursor.

oDoc = StarDesktop.loadComponentFromURL( cURL, "_blank", 0, Array( ) )

docController = oDoc.currentController

viewCursor = docController.getViewCursor()

'jumpto Page number 2!!! Smile
viewCursor.jumpToPage(2)


Once I jump to page 2, I thought that the following selection code would be able to select text until the end of document.

'create a dispatcher
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

'select the contents from page 2 to end of the page
dispatcher.executeDispatch(oDoc, ".uno:EndOfDocumentSel", "", 0, Array())

The above statement, results in run time error. An illegal argument exception.

Any help would be greatly appreciated.

Thanks in advance,
Mohan
Back to top
View user's profile Send private message
mohanmg
General User
General User


Joined: 26 Oct 2006
Posts: 18

PostPosted: Mon Oct 30, 2006 2:03 am    Post subject: cutting the page contents, still entrie file gets exported Reply with quote

Ok, I found the mistake. I need to get the document and pass it to the event dispatcher.
The code executed without any errors after that. But, the resulting pdf file is still the whole document rather than the required contents.

David, you told me to delete all the other pages.

I did a cut of all the contents from the pages I do not want. There were no errors.

But, finally, the pdf document is having all the contents. Can you please tell me what might be wrong?

Thanks,
Mohan
Back to top
View user's profile Send private message
David
Super User
Super User


Joined: 24 Oct 2003
Posts: 5668
Location: Canada

PostPosted: Mon Oct 30, 2006 4:11 am    Post subject: Re: cutting the page contents, still entrie file gets export Reply with quote

mohanmg wrote:
David, you told me to delete all the other pages.

I did a cut of all the contents from the pages I do not want. There were no errors.

But, finally, the pdf document is having all the contents. Can you please tell me what might be wrong?

Thanks,
Mohan


You sent me the code, but I have no experience there. If you delete the un-needed pages, then Save the "new" document As another filename, you would surely have only the material you need to form the PDF you need. You will have more experience than I do with use in the command line, rather than by more direct effort. I wassuggesting that you simply form another document and work with that.

David.
Back to top
View user's profile Send private message
mohanmg
General User
General User


Joined: 26 Oct 2006
Posts: 18

PostPosted: Mon Oct 30, 2006 6:33 pm    Post subject: thanks I was able to do it Reply with quote

Instead of a "cut" option, if I use ":unoDelete" and then do a "storeAsURL" I am able to export the required pages only to pdf. After expoting I am able to close my origianl document without any dialogs and the original file is intact.

Another interesting thing that I found was that, the document can be opened in hidden mode and still I am able to work with view cursors for jumping to a particular page. The options provided by OOo are amazing.

Thanks again David for providing an initial pointer. Smile
Mohan
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