Hi,
I'm not sure you receive my emails cause you don't reply to my last questions.
I have a problem using htmltopdf
[cid:image001.png@01CD6337.392BB810]
I think it's a security option with ie but don't know which one.
Thanks.
=====================================
Please run following command line with administrator privilege to register pdfout.dll into your system first,
"c:\windows\syswow64\regsvr32.exe" pdfout.dll
Then you can run html2pdf.exe on your 64bit Windows Server 2008 R2 to convert documents to PDF files without any problem now,
VeryPDF
=====================================
thanks, it works now, can you give more explanations about to use the differents components, their usage and their dependances ? it's not very clear in my mind,
=====================================
pdfout.dll is a 32bit COM, you can only use it in 32bit application, the COM name for pdfout.dll file is "PdfOut.PdfCreator",
Set PdfCreator = CreateObject("PdfOut.PdfCreator")
ConvertHTMLToPDF1 PdfCreator, "https://www.google.com/", "google001.pdf
ConvertHTMLToPDF2 PdfCreator, "https://www.google.com/", "google002.pdf"
'Convert MS Word document to PDF file
ConvertWordToPDF pdfCreator,"test1.doc","test1.pdf"
'ConvertWordToPDF pdfCreator,"test2.doc","test2.pdf"
'ConvertWordToPDF pdfCreator,"test3.doc","test3.pdf"
'ConvertWordToPDF pdfCreator,"test4.doc","test4.pdf"
set PdfCreator = nothing
function ConvertHTMLToPDF1(byval PdfCreator, strHTMLFile, strPDFFile)
'The first method to create a PDF file from HTML file
Set fso = CreateObject("Scripting.FileSystemObject")
strFolder = fso.GetParentFolderName(wscript.ScriptFullName)
strPDFFile = strFolder & "\" & strPDFFile
dim strCommandLine
strCommandLine = """" + strHTMLFile + """"
strCommandLine = strCommandLine + " "
strCommandLine = strCommandLine + """" + strPDFFile + """"
strCommandLine = strCommandLine + " "
strCommandLine = strCommandLine + """" + "paperType=6" + """"
MsgBox "HTML To PDF Command Line1 is: " & strCommandLine
PdfCreator.Doc2PDFCommandLine(strCommandLine)
end function
function ConvertHTMLToPDF2(byval PdfCreator, strHTMLFile, strPDFFile)
'The second method to create a PDF file from HTML file
Set fso = CreateObject("Scripting.FileSystemObject")
strFolder = fso.GetParentFolderName(wscript.ScriptFullName)
strPDFFile = strFolder & "\" & strPDFFile
PdfCreator.html2PDF= strHTMLFile
PdfCreator.fileName = strPDFFile
PdfCreator.paperType = 6
pdfCreator.headersFooters = "on"
pdfCreator.htmlHeaders="&w&bPage&p/&P"
pdfCreator.htmlFooters="&u&b&d"
pdfCreator.margin_left = 100.0
MsgBox "HTML To PDF Command Line2 is: " & strHTMLFile & " ==> " & strPDFFile
result = PdfCreator.Doc2PDFViaSocket()
end function
function ConvertWordToPDF(byval PdfCreator, strWordFile, strPDFFile)
Set fso = CreateObject("Scripting.FileSystemObject")
strFolder = fso.GetParentFolderName(wscript.ScriptFullName)
strPDFFile1 = strFolder & "\" & strWordFile
strPDFFile2 = strFolder & "\" & strPDFFile
strCommand = """" & strPDFFile1 & """"
strCommand = strCommand & " " & """" & strPDFFile2 & """"
MsgBox "WordToPDF Command Line is: " & strCommand
PdfCreator.Doc2PDFCommandLine(strCommand)
end function
DocConverterCOM_win64.exe is support both 32bit and 64bit applications, the COM name is ("DocConverterCOM.pdfout"). You can use DocConverterCOM_win64.exe by following sample code,
-----------------------------------------------------
Set PdfCreator = CreateObject("DocConverterCOM.pdfout")
ConvertHTMLToPDF1 PdfCreator,"http://www.google.com","google001.pdf"
'Convert MS Word document to PDF file
ConvertWordToPDF pdfCreator,"test1.doc","test1.pdf"
'ConvertWordToPDF pdfCreator,"test2.doc","test2.pdf"
'ConvertWordToPDF pdfCreator,"test3.doc","test3.pdf"
'ConvertWordToPDF pdfCreator,"test4.doc","test4.pdf"
set PdfCreator = nothing
function ConvertHTMLToPDF1(byval PdfCreator, strHTMLFile, strPDFFile)
'The first method to create a PDF file from HTML file
Set fso = CreateObject("Scripting.FileSystemObject")
strFolder = fso.GetParentFolderName(wscript.ScriptFullName)
strPDFFile = strFolder & "\" & strPDFFile
dim strCommandLine
strCommandLine = """" + strHTMLFile + """"
strCommandLine = strCommandLine + " "
strCommandLine = strCommandLine + """" + strPDFFile + """"
strCommandLine = strCommandLine + " "
strCommandLine = strCommandLine + """" + "paperType=6" + """"
MsgBox "HTML To PDF Command Line1 is: " & strCommandLine
PdfCreator.Doc2PDFCommandLine(strCommandLine)
end function
function ConvertWordToPDF(byval PdfCreator, strWordFile, strPDFFile)
Set fso = CreateObject("Scripting.FileSystemObject")
strFolder = fso.GetParentFolderName(wscript.ScriptFullName)
strPDFFile1 = strFolder & "\" & strWordFile
strPDFFile2 = strFolder & "\" & strPDFFile
strCommand = """" & strPDFFile1 & """"
strCommand = strCommand & " " & """" & strPDFFile2 & """"
MsgBox "WordToPDF Command Line is: " & strCommand
PdfCreator.Doc2PDFCommandLine(strCommand)
end function
-----------------------------------------------------
VeryPDF
pdfcreator COM is a 32bit COM interface, it can only be called from 32bit EXE application, 64bit EXE can’t call pdfcreator COM directly.
On the 64bit system, you can use DocConverterCOM_win64.exe to instead of pdfcreator COM, please run a CMD window with administrator privilege, and run following command line in this CMD window to register DocConverterCOM_win64.exe,
—————————————–
DocConverterCOM_win64.exe /regserver
—————————————–
Launch doc2pdf_service.exe application to work as a conversion monitor,
—————————————–
start doc2pdf_service.exe -exe
—————————————–
DocConverterCOM_win64.exe is support both 32bit and 64bit applications, the COM name is (“DocConverterCOM.pdfout”). You can use DocConverterCOM_win64.exe by the sample code included in this article.