0
Answer

Export div to pdf

Mayur  Gujrathi

Mayur Gujrathi

12y
2k
1
Dear All
 
I have user control in which i export div to excel using javascript..
 
In the same i want to export div to pdf..
 
My vbscript is as follows
 

function goExportExcel()
 
        ON ERROR RESUME NEXT
        if Isobject(document.getElementById("divrpt")) = false then EXIT FUNCTION
        DIM sHTML, oExcel, fso, filePath
        sHTML = document.all.item("divrpt").outerhtml
        sHTML = replaceMe(sHTML)
        alert(sHTML)
        StripHTMLwithnoclass = Replace(Replace(Replace(sHTML,"class=bordergrey","style='background-color: #CCCCCC;'"),"class=commontablebg","style='background-color:#FBF8F8;'"),"class=clsborder","style='BORDER-RIGHT: #F5F5F5 1px solid;BORDER-TOP: #F5F5F5 1px solid;BORDER-LEFT: #F5F5F5 1px solid;BORDER-BOTTOM:#F5F5F5 1px solid;'")
        SET fso = CreateObject("Scripting.FileSystemObject")
        filePath = fso.GetSpecialFolder(2) & "\tmpdata.xls"
        fso.CreateTextFile(filePath).Write(sHTML)
        err.Clear()
        SET oExcel = CreateObject("Excel.Application")
        IF err.number>0 OR oExcel =NULL THEN
            msgbox("You need to have Excel Installed and Active-X Components Enabled on your System.")
            EXIT FUNCTION
        END IF
        oExcel.Workbooks.open(filePath)
        oExcel.Workbooks(1).WorkSheets(1).Name = "D-Mat Data"
        oExcel.Visible = true
        Set fso = Nothing
End function
 

divrpt is my div id
 

Please help me out for exporting to pdf..
 
I cant use any server side code because to make changes in each and every page will not be feasible ..for the same reason i need same in VBSCRIPT or any scripting language..