Stop OpenOffice Writer HTML exporter from double spacing everything

So I have my text like this in OpenOffice Writer:

text
text
text

And after exporting it to HTML, it does this to the file

text

text

text




How do I stop it?

I can't go Shift-return for all the paragraphs because I have a super large document.
Unless, there is a way to do that easily on a large scale.

Thanks.


nvs_victorAsked:
Who is Participating?
 
xberryConnect With a Mentor Commented:
How did you export it ? Which version of OO ?
I've just tried exactly your 3 x text-test and then did File->Export with Filter xhtml
and opened the page then with firefrox and what can I say: Looks exaclty like I typed it in
OOffice-writer (version 2.3.0).
0
 
nvs_victorAuthor Commented:
OO version: 2.3.1

I did this:
File > Send > Create HTML Document

Saving it as XHTML gives me an error:

"Error saving the document untitled4:
Write Error.
The file could not be written."

0
 
xberryCommented:
>>> "Error saving the document untitled4:
Write Error.
The file could not be written."

Sounds like you have no write permissions to the directory you try to save to.
Did you check that all ?

Else, I also did browse for similiar problems on the net but found that standardly the
way to create html is by the way I did, meaning found no hint that explains how to prevent
it from throwing the spaces when you do it the way you did it - sorry:
Example: http://www.linuxjournal.com/article/6289 
0
2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

 
nvs_victorAuthor Commented:
Well. It exports well for PDF.

Let me ask, did you do this:
File > Export... > (change the file format to: XHTML) ?

Do you get the same effect that I do?
I started off with a Text document in Writer, simply typed the text WITHOUT pressing Shift-Enter, but instead Enter.
After you save it like how I did, do you get the same effect?
0
 
ltlbearand3Commented:
nvs_Victor,

To get this to format correctly in HTML you will need to replace the paragraph marks (Enter) with line breaks (Shift & Enter).  However, you mentioned that this is a large document.  OOo will sees the line break as part of a paragraph.  It has a limitation of 64,000 characters per paragraph.  

I do not know of a quick way to find & replace paragraph marks with line breaks in OOo and have not found one on the internet yet.  I will look some more in the next couple of days or see if I can make my own macro for you.

-Bear
0
 
nvs_victorAuthor Commented:
Thanks for coming in

The document already has lots of intentional separate paragraphs. It's just that it converts the single spacing text into double spacing text.

So you're right, we can't simply just search and replace <p> with  <br>  or else it will see everything as one paragraph.

I just want something like this:
text
text
text

text
text
text
_____________________________
instead of this

text

text

text



text

text

text

___________
It looks so ugly.

Microsoft Word easily does it's job, but it's html file size is really bloated and Word doesn't have a certain feature OpenOffice has.
0
 
ltlbearand3Connect With a Mentor Commented:
OK I did not find a good way to do this, but I did find a Macro that did part of the work.  I built off that code to create the following Macro.  This macro should replace any Paragraph Marks (Hard Return) with a Line Feed (Soft Return).  If it finds 2 or 3 Paragraph Marks in a row, it will only change the first one to a Line Feed.  I would make a copy of your document and run this macro on your copy to make sure it does what you need.

To use this Macro, in your OOo Writer Doc:

Goto the Menu  Tools | Macros | Organize Macros | OpenOffice.org basic (Or Alt-F11)
In the Macro From box expand the tree under you document name then click on Standard
Then Click the New button on the right and give this code a name
Then Cut and Paste the code into the OOo Basic Editor Window
Save Your File
Now Goto the Menu  Tools | Macros | Run Macro
Expand out your document window until you see the Macro  ConvertforHTML
Click Run



Option Explicit
Sub ConvertForHTML
	' Converts Paragraph Marks to Line Returns Unless 
	' two are found in a row
	' Note Chr(13) = Paragraph Mark
	' Note Chr(10) = Line Return
	On Error goto ErrorHandler
 
	Dim objDoc as object
	Dim oVC as object
	Dim strErrMsg as String
	dim dispatcher as object
	
	' Set Cursor Document
	objDoc = ThisComponent
	oVC = objDoc.CurrentController().getViewCursor()
	
	' Go to Start of Document
	oVC.gotoStart(false)
	
	' Skip over blank paragraphs at the beginning, if any.
	Do While oVC.goRight(1,true)
	 If Asc(oVC.String) = 13 OR Asc(oVC.String) = 10 then
	   oVC.collapseToEnd
	  Else oVC.collapseToStart : Exit Do
	 EndIf
	Loop
	
	' Go to the End of the First Line of found Text
	oVC.gotoEndOfLine(1,False)
	oVC.collapseToEnd
	
	' Loop through all Lines in Document
	Do While oVC.goRight(1,true)
		If Asc(oVC.String) = 13 then
		    oVC.String = Chr(10)
			oVC.goRight(1,False)
			If oVC.goRight(1,True) Then
	  			If Asc(oVC.String) = 13 then
					If oVC.goRight(2,False) Then 
						oVC.gotoEndOfLine(false)
					End If
				Else
					oVC.gotoEndOfLine(False)
				End If
			End If
		Else
			oVC.collapseToEnd
		End IF
	Loop
	Exit Sub
	ErrorHandler:
	If err <> 5 then
	 strErrMsg = "An unexpected error #" & err & " occurred in line " & erl & "."
	 strErrMsg = strErrMsg & Chr(13) & "The error message is:" & Chr(13) & Error$
	 MsgBox strErrMsg
	EndIf
	End
End Sub

Open in new window

0
 
nvs_victorAuthor Commented:
Dang. It works well when I create a new doc with
text
text
text.


But when I try to run it on my big document, it did its job but had terrible side-effects:
it formatted the headings 1,2,3,4 etc improperly. It made almost everything as heading 2.

xberry:
I tried to export to xhtml format and it works now, for some reason.  It also doesn't adds double space as you mentioned.


ltlbearand3:
I think the original question as been answered as a workaround. So I think I should close this question now.

I'm going to re ask this question but this time specifically for the
File > Send ... > Create HTML Document     feature.

Thanks.
0
 
nvs_victorAuthor Commented:
I want to use the File > Send ... > Create HTML Document  (feature) because it cuts up the document automatically into multiple html documents. Simply using xhtml won't do this, but it does take out the double spacing that I want. So the question was partially answered.
0
All Courses

From novice to tech pro — start learning today.