2011年12月7日 星期三

製作 6" PDF for Kindle 3

1. 先做一個 x.doc, 放在 /tmp
版面設定 : 寬 10cm 長 12cm, 上下左右邊界 : 0.5 cm, 直書

2. 加 macro
打開 OpenOffice, 新增一個巨集, 在 Standard Module1 之下
Sub ConvertWordToPDF

Dim oPropertyValue As New com.sun.star.beans.PropertyValue
oPropertyValue.Name = "Hidden"
oPropertyValue.Value = True
oDoc = StarDesktop.loadComponentFromURL("file:///tmp/x.doc", "_blank", 0, Array(oPropertyValue, ))

oPropertyValue.Name = "Filter"
oPropertyValue.Value = "Text (encoded)"
oCursor = oDoc.Text.createTextCursor
oCursor.insertDocumentFromURL("file:///tmp/x.txt", Array(oPropertyValue, ))

rem Save the document using a filter.
oPropertyValue.Name = "FilterName"
oPropertyValue.Value = "writer_pdf_Export"
oDoc.storeToURL("file:///tmp/x.pdf", Array(oPropertyValue, ))
oDoc.close(true)

End Sub



3. toPDF.sh :

cat $1 | sed 's/“/「/g' | sed 's/”/」/g' | sed 's/-/--/g' | sed 's/(/(/g' | sed 's/)/)/g' > x.txt
oowriter -invisible "macro:///Standard.Module1.ConvertWordToPDF()"

4. 成果放在 /tmp/x.pdf