Solved

Stop OpenOffice Writer HTML exporter from double spacing everything

Posted on 2008-06-24
10
1,125 Views
Last Modified: 2013-12-26
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.


0
Comment
Question by:nvs_victor
  • 5
  • 2
  • 2
10 Comments
 
LVL 14

Accepted Solution

by:
xberry earned 200 total points
ID: 21863362
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
 

Author Comment

by:nvs_victor
ID: 21866662
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
 
LVL 14

Expert Comment

by:xberry
ID: 21867144
>>> "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
 

Author Comment

by:nvs_victor
ID: 21867845
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 20

Expert Comment

by:ltlbearand3
ID: 21881122
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
 

Author Comment

by:nvs_victor
ID: 21887059
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
 
LVL 20

Assisted Solution

by:ltlbearand3
ltlbearand3 earned 200 total points
ID: 21888855
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
 

Author Comment

by:nvs_victor
ID: 21902169
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
 

Author Closing Comment

by:nvs_victor
ID: 31470354
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

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Microsoft Word is a program we have all encountered at some point, but very few of us have dug deep into its full scope of features, let alone customized it to suit our needs. Luckily making the ribbon (aka toolbar, first introduced in Word 2007) wo…
We have come a long way with backup and data protection — from backing up to floppies, external drives, CDs, Blu-ray, flash drives, SSD drives, and now to the cloud.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now