![]() | Register | FAQ | Members | Social Groups | User Map | Calendar | Search | Today's Posts | Mark Forums Read |
| | | LinkBack | Thread Tools | Search Thread | Language |
| Sponsored Links |
| | #1 |
![]() Join Date: Apr 2006 Location: UK
Posts: 484
Thanks: 8
Thanked 6 Times in 5 Posts
Rep Power: 7 | The problem i am finding is that many of the scripts - Perl, php etc do not support CSS very well E.g. Floats, inline style and tables Obviously I could improve/degrade my HTML and CSS but this is not an option. Does anyone have any idea how i might go about this? It needs to be an automated process which will allow a bulk job of documents created in HTML/CSS to be converted to PDF on the fly. ... |
| |
| | #2 |
![]() Join Date: Aug 2005 Location: London
Posts: 1,100
Thanks: 1
Thanked 113 Times in 98 Posts
Rep Power: 29 | Not sure what you want to do this on but if you can use Internet Explorer on Windows then you coudl install PDFCreator as a printer driver and then use a script like the one below (make sure the PDFCreator is set as default printer first) Basically, it sets a few variables so that the PDF Creator will print without prompting for filenames etc and then it loads each file named in the list at c:\temp\urls.txt (just a plain text file, 1 URL per line). Once the page is loaded it gets printed. You don't have any control over things like fitting to page etc (although I suspect you could - this is left as an exercise for the reader :-)) but it basically works. Code: const OLECMDID_PRINT = 6
const OLECMDEXECOPT_DONTPROMPTUSER = 2
const PRINT_WAITFORCOMPLETION =2
Const HKEY_CURRENT_USER = &H80000001
Initialise
set oShell=createobject("wscript.shell")
set OFSO=createobject("scripting.filesystemobject")
set oFile=ofso.opentextfile("c:\temp\urls.txt")
do while not ofile.atendofstream
sURL=ofile.readline
PrintPage sURL
loop
oFile.close
sub PrintPage(sURL)
Set oIE= CreateObject("InternetExplorer.Application")
Do While (oIE.Busy)
Wscript.Sleep 250
Loop
oIE.visible=true
oIE.ToolBar = false
oIE.StatusBar = false
oIE.Resizable = false
oIE.Navigate (sURL)
Do While (oIE.Busy)
Wscript.Sleep 250
Loop
wscript.sleep 1000 'just so you can see the page
sFilename=replace(sURL,"/","-")
sFileName=replace(sURL,":","-")
oShell.regwrite "HKCU\Software\PDFCreator\Program\AutoSaveFileName",sFileName
Oie.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, PRINT_WAITFORCOMPLETION,0
oIe.quit
end sub
Sub Initialise
Set oReg = GetObject("winmgmts://./root/default:StdRegProv")
sPath = "Software\PDFCreator\Program"
lRC=oReg.SetDwordValue(HKEY_CURRENT_USER,sPath,"ShowAnimation",0)
lRC=oReg.SetDwordValue(HKEY_CURRENT_USER,sPath,"UseAutoSave",1)
lRC=oReg.SetDwordValue(HKEY_CURRENT_USER,sPath,"UseAutoSaveDirectory",1)
lRC=oReg.SetStringValue(HKEY_CURRENT_USER,sPath,"AutoSaveDirectory","c:\temp")
lRC=oReg.SetDwordValue(HKEY_CURRENT_USER,sPath,"AutoSaveStartStandardProgram",0)
end sub
|
| |
| | #3 |
![]() Join Date: Apr 2006 Location: UK
Posts: 484
Thanks: 8
Thanked 6 Times in 5 Posts
Rep Power: 7 | The problem i have is that the pages to be printed are dynamic. The system is basically a way of recording staff CPD, with a number of sheets attached. The system produces a HTML/CSS template report based on this data. I would like 'reviewers' to view the reports on screen but at a certain point in time teacher are not allowed to access the system and make changes, I lock the system at this point. But at the same time I need to output all the reports to PDF on the fly... So no files names or URLs just data output to a html page... Help please lol |
| |
| | #4 |
![]() Join Date: Aug 2005 Location: Alton, Hampshire
Posts: 1,385
Thanks: 119
Thanked 92 Times in 87 Posts
Rep Power: 28 | Have you tried XSLT:FO, a transforms language for transforming XML into PDF? Have a look at Apache Xalan, see if that is appropriate to what you are trying to do. I assume you've already had a look at the PDF writing library for whatever language you're developing in? The above idea really doesn't sound bad at all - use a browser engine to render your page, then print that rendered page out to a temporary PDF document - you can easily delete that PDF documents again as soon as you've sent it to the user. -- David Hicks |
| |
| | #5 |
![]() Join Date: Aug 2005 Location: London
Posts: 1,100
Thanks: 1
Thanked 113 Times in 98 Posts
Rep Power: 29 | Not sure I understand?? How do you look at the pages now? Do they just come up on a screen as part of an application (ie not rendered in a normal browser window)?? |
| |
| | #6 |
![]() Join Date: Apr 2006 Location: UK
Posts: 484
Thanks: 8
Thanked 6 Times in 5 Posts
Rep Power: 7 | Yes they are rendered in a browser window, but dynamically... E.g the address for every page generated is http://localhost/report.cgi but the contents of each page is different depending on what users report is selected. |
| |
| | #7 | |
![]() Join Date: Aug 2005 Location: Alton, Hampshire
Posts: 1,385
Thanks: 119
Thanked 92 Times in 87 Posts
Rep Power: 28 | Quote:
-- David Hicks | |
| |
| | #8 | |
![]() Join Date: Aug 2005 Location: London
Posts: 1,100
Thanks: 1
Thanked 113 Times in 98 Posts
Rep Power: 29 | Quote:
1 - render a report for each possible input 2 - convert that to PDF Assuming that you can't just do something like: http://localhost/report.cgi?code=1 http://localhost/report.cgi?code=2 http://localhost/report.cgi?code=3 etc then I think you're stuck. | |
| |
| | #9 |
![]() Join Date: Apr 2006 Location: UK
Posts: 484
Thanks: 8
Thanked 6 Times in 5 Posts
Rep Power: 7 | Can anyone tell me how to go about using the below code? Combile etc.... or atleast what language this is? Code: sub PrintPage(sURL)
Set oIE= CreateObject("InternetExplorer.Application")
Do While (oIE.Busy)
Wscript.Sleep 250
Loop
oIE.visible=true
oIE.ToolBar = false
oIE.StatusBar = false
oIE.Resizable = false
oIE.Navigate (sURL)
Do While (oIE.Busy)
Wscript.Sleep 250
Loop
wscript.sleep 1000 'just so you can see the page
sFilename=replace(sURL,"/","-")
sFileName=replace(sURL,":","-")
oShell.regwrite "HKCU\Software\PDFCreator\Program\AutoSaveFileName",sFileName
Oie.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, PRINT_WAITFORCOMPLETION,0
oIe.quit
end sub
Sub Initialise
Set oReg = GetObject("winmgmts://./root/default:StdRegProv")
sPath = "Software\PDFCreator\Program"
lRC=oReg.SetDwordValue(HKEY_CURRENT_USER,sPath,"ShowAnimation",0)
lRC=oReg.SetDwordValue(HKEY_CURRENT_USER,sPath,"UseAutoSave",1)
lRC=oReg.SetDwordValue(HKEY_CURRENT_USER,sPath,"UseAutoSaveDirectory",1)
lRC=oReg.SetStringValue(HKEY_CURRENT_USER,sPath,"AutoSaveDirectory","c:\temp")
lRC=oReg.SetDwordValue(HKEY_CURRENT_USER,sPath,"AutoSaveStartStandardProgram",0)
end sub
|
| |
| | #10 | |
![]() Join Date: Aug 2005 Location: Alton, Hampshire
Posts: 1,385
Thanks: 119
Thanked 92 Times in 87 Posts
Rep Power: 28 | Quote:
-- David Hicks | |
| |
| | #11 |
![]() Join Date: Mar 2008 Location: London
Posts: 173
Thanks: 8
Thanked 12 Times in 11 Posts
Rep Power: 4 | I feel your pain. html2ps and html2pdf - Convert HTML to PostScript or PDF. Supports over 500 HTML and CSS tags and properties. dompdf - The PHP 5 HTML to PDF Converter FPDF PHP: PDF - Manual Listed a few in case they weren't all on your list. |
| |
| The Following User Says Thank You to kesomir For This Useful Post: | danIT (31-07-2008) |
| | #12 | |
![]() Join Date: Aug 2005 Location: London
Posts: 1,100
Thanks: 1
Thanked 113 Times in 98 Posts
Rep Power: 29 | Quote:
It's vbscript - it'll run on any machine as long as you've got internet explorer and a PDF driver installed (actually, it'll print to the default printer but the original request was for PDF) as you say, save it as <filename>.vbs Create a text file c:\temp\urls.txt containing addresses of pages you want printing then open a command prompt and type <filename> to get the web pages loaded in turn and then printed. | |
| |
| | #13 |
![]() Join Date: Aug 2005 Location: Alton, Hampshire
Posts: 1,385
Thanks: 119
Thanked 92 Times in 87 Posts
Rep Power: 28 | |
| |
| |
| | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Wiki Site which teaches html, css and php | My220x | Coding | 1 | 04-07-2008 10:17 PM |
| html/ javascript help | strawberry | Coding | 2 | 02-07-2008 11:22 AM |
| HTML Help | Shrimpersfan | Windows | 6 | 25-04-2008 01:56 PM |
| HTML Help with Outlook | robbied69 | Coding | 4 | 29-02-2008 05:37 PM |
| HTML Editor | alan-d | Web Development | 7 | 17-04-2007 07:56 AM |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search Thread |
|
|








