von jessi » Do, 07.02.2008 13:31
Hallo,
ich möchte Html-Dokumente in PDF-Dokumente umwandeln.
Dafür habe ich ein Makro erstellt, dass die Html-Dokumente in den Writer/Web lädt und anschließend als PDF abspeichert.
Die Tabellen aus den Html-Dokumenten sehen in dem PDF aber nicht gut aus, da unerwünschte Zeilenumbrüche in den Spalten auftreten.
Wenn ich per Hand Folgendes mache, habe ich das Problem nicht:
1. File -> Open 'Html-Dokument laden
2. File -> SaveAs 'Grund: die Html-Dokumente werden als Read-only geladen. Wenn ich einmal abspeicher, kann ich sie verändern.
3. Table -> Select -> Table
4. Table -> Autofit -> Distribute Columns Evenly
5. Table -> Autofit -> Optimal Columns Width
6. Als PDF abspeichern
Weiß jemand, wie ich die Schritte 1-5 in mein Makro einbauen kann?
Mein Makro sieht bislang so aus:
Sub GeneratePDF(source As String, target As String)
'This macro loads an html-file into OpenOffice, converts it into a pdf-file and stores it as pdf.
Dim sourceURL, targetURL
Dim oDoc
Dim documentType
Dim documentFilter
Dim FileProperties(0) As New com.sun.star.beans.PropertyValue
FileProperties(0).Name = "Hidden"
FileProperties(0).Value = TRUE
documentFilter = "writer_web_pdf_Export"
documentType = Ucase( Right( source, 4 ) )
If documentType = ".ODT" Then
documentFilter = "writer_pdf_Export"
End If
sourceURL = ConvertToURL( source ) 'converts path into a OpenOffice conform path
targetURL = ConvertToURL( target ) 'converts path into a OpenOffice conform path
oDoc = StarDesktop.loadComponentFromURL(sourceURL, "_blank", 0, FileProperties()) 'loads source-file into OpenOffice
Dim SaveArgs(0) As New com.sun.star.beans.PropertyValue 'necessary argument for storeToURL-function
SaveArgs(0).Name = "FilterName"
SaveArgs(0).Value = documentFilter
oDoc.storeToURL(targetURL, SaveArgs()) 'stores loaded component to targetURL
Stardesktop.terminate()
End Sub
Hallo,
ich möchte Html-Dokumente in PDF-Dokumente umwandeln.
Dafür habe ich ein Makro erstellt, dass die Html-Dokumente in den Writer/Web lädt und anschließend als PDF abspeichert.
Die Tabellen aus den Html-Dokumenten sehen in dem PDF aber nicht gut aus, da unerwünschte Zeilenumbrüche in den Spalten auftreten.
Wenn ich per Hand Folgendes mache, habe ich das Problem nicht:
1. File -> Open 'Html-Dokument laden
2. File -> SaveAs 'Grund: die Html-Dokumente werden als Read-only geladen. Wenn ich einmal abspeicher, kann ich sie verändern.
3. Table -> Select -> Table
4. Table -> Autofit -> Distribute Columns Evenly
5. Table -> Autofit -> Optimal Columns Width
6. Als PDF abspeichern
Weiß jemand, wie ich die Schritte 1-5 in mein Makro einbauen kann?
Mein Makro sieht bislang so aus:
Sub GeneratePDF(source As String, target As String)
'This macro loads an html-file into OpenOffice, converts it into a pdf-file and stores it as pdf.
Dim sourceURL, targetURL
Dim oDoc
Dim documentType
Dim documentFilter
Dim FileProperties(0) As New com.sun.star.beans.PropertyValue
FileProperties(0).Name = "Hidden"
FileProperties(0).Value = TRUE
documentFilter = "writer_web_pdf_Export"
documentType = Ucase( Right( source, 4 ) )
If documentType = ".ODT" Then
documentFilter = "writer_pdf_Export"
End If
sourceURL = ConvertToURL( source ) 'converts path into a OpenOffice conform path
targetURL = ConvertToURL( target ) 'converts path into a OpenOffice conform path
oDoc = StarDesktop.loadComponentFromURL(sourceURL, "_blank", 0, FileProperties()) 'loads source-file into OpenOffice
Dim SaveArgs(0) As New com.sun.star.beans.PropertyValue 'necessary argument for storeToURL-function
SaveArgs(0).Name = "FilterName"
SaveArgs(0).Value = documentFilter
oDoc.storeToURL(targetURL, SaveArgs()) 'stores loaded component to targetURL
Stardesktop.terminate()
End Sub