PDF-ShellTools > Ideas/Suggestions

DOC into PDF

(1/2) > >>

Hi Rui,

Not sure if this is at all possible, put a great feature would be turning DOC files into PDF's, like you have for the JPG files.
I imagine it is probably not possible, as pictures can just be embedded in but DOC's would almost need to be printed to a PDF.

Hi Luke,
Such a tool is by itself a big project.
A direct Doc to PDF can only be done by a tool that fully understand, and correctly renders, the format, so the best approach is definitively the print to PDF solution. Such tools usually automate (or require user intervention) the MS Word or Word Previewer, to print to the postscript format (using a postscript printer driver), and then use a postscript to PDF converter, such as the AFL-GhostScript. Even the Adobe Acrobat tools use this method, complemented by additional processing to add hyperlinks, bookmarks, etc..
I could use such methods in PDF-ShellTools, but using third party solutions is not the spirit of the tools, so that's something not workable right now.

The Open Office Writer is able to do a direct conversion, so you can use it to open a .doc and then export it to a PDF. And this tool can be automated, so I suppose you can easily create a script and add it to the Shell context menu. ;)

Thanks for the response. I thought this might be the case, but thought I'd ask just in case there was a way.

I'll have a look into the Open Office Writer idea though ;) Thanks!

So I took your advise.
I went with LibreOffice and came up with the following in a batch file, which I have in my Send To folder:

ECHO off
cd %~p1
soffice -headless -convert-to PDF %1

I'm now just trying to get it to be able to run on multiple selected files. Unfortunately, you can't use "/folder/*.doc" as the -convert-to doesn't allow wildcards in Windows :(
The only way I can see would be a loop in the batch, with a pause to wait for each conversion to take place.

Can't make that command line work here, so can't test possible solutions to accomplish that.
But I was talking about the more powerful COM Automation.
I digged a bit about this subject, and I coded this little script in VBScript.

--- Code: ---Option Explicit

Sub SaveAsPDF(filename)
' ********************************
' Save an existing document as PDF
' ********************************
Dim oDoc
Dim OpenParam(0)
Dim SaveParam(0)
Dim sUrl

Set OpenParam(0) = MakePropertyValue("Hidden", True)  ' Open the file hidden
sURL = "file:///" & Replace(filename, "\" , "/")
Set oDoc = oDesk.loadComponentFromURL(sURL, "_blank", 0, OpenParam)

set SaveParam(0) = MakePropertyValue("FilterName", "writer_pdf_Export")
sURL = left(sURL,InStrRev(sURL,"."))+"pdf"
Call oDoc.storeToURL(sURL, SaveParam)

Set oDoc = Nothing
End Sub

Public Function MakePropertyValue(cName, uValue)
Dim oStruct
    Set oStruct = oSM.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
    oStruct.Name = cName
    oStruct.Value = uValue
    Set MakePropertyValue = oStruct
End Function

Dim oSM, oDesk
Set oSM = CreateObject("com.sun.star.ServiceManager")
Set oDesk = oSM.createInstance("com.sun.star.frame.Desktop")

Dim i
for i=0 to WScript.Arguments.count-1               

--- End code ---

Just place it in a .vbs file, in the "send to" folder, and you have now a powerful toPDF converter, that's able to convert any of the file formats the OOo Writer can read, into the PDF format ;)
This uses the OOo ActiveX control, so make sure you install it when installing the OpenOffice.
I just tested it with the OpenOffice.org, so I have no idea if it also works with LibreOffice.


[0] Message Index

[#] Next page


Go to full version