Dypso Backoffice
Dypso Backoffice

Download Products


DypsWebCapture : Capture Web page as thumbnail image

Documentation
Example
Download
Buy

New release with embed IE and Firefox rendering engine !



DypsFTP : Manage a FTP site from your script

Documentation
Buy


DypsImg2SWF : Protect and save your image as SWF/Flash format!

Documentation
Example
Download
Buy


DypsXLS for ASP: Générateur de fichier Excel

New features!
Documentation
Exemple d'utilisation
Download
Buy


DypsMetaGrabber : get Meta Tag from any web page!

Documentation
Example
Download
Buy


DypsAntiSpam for ASP

Features
Exemple d'utilisation
Download
Buy

DypsoPRank for ASP

Features
Exemple d'utilisation
Download
Buy

Pop3 Checker for ASP

Features
Exemple d'utilisation
Download
Buy

SVG Pie chart Maker for ASP

Features
Exemple d'utilisation
Download

DypsRTF for ASP

Features
Exemple d'utilisation
Download
Buy

What's New ?


Mise en ligne du premier outil gratuit pour générer des fichiers Excel depuis ASP : DypsXLS !
[Lire la suite]

Et un forum Le site se dote d'un forum pour vous permettre de partager toujours plus.
[Rejoigner nous]

Annuaire de scripts ! Un annuaire de scripts et de liens utiles vers des ressources pour le développement
[Lire la suite]

Création d'un outil gratuit pour retrouver ses mails : Pop3 Checker for free !
[Lire la suite]

Création d'un outil gratuit pour générer des graphiques vectoriels à la volée: Free SVG Pie chart Maker !
[Lire la suite]
Print the script

Create PDF Files with HTMLDoc

Techniques

This section makes it possible to gather a whole of techniques or scripts which have the originality to manage to solve a difficulty with the least effort or which are particularly effective...


Techniques / PDF

  •  Convert HTML files in PDF files

It can be useful to produce files pdf since a dynamic page, to generate the files with stolen for example in order to creating states of the mass mailing type, listings or even a form to be filled. Several solutions is offered then to you according to the language used. A practical and free method, usable by all the languages can be to transform files HTML into pdf. There exists for that several techniques. One of it rests on the use of a free utility: HTMLDoc . HTMLDoc is achievable which makes it possible to convert one or more files HTML into file pdf. It is used normally with a graphic interface but can also be called from command line.

Advantages on a Web server:

  • It is easy to generate a HTML file to be transformed.
  • It is one of the fastest and more reliable methods for simple files pdf.
  • Many formats of images are supported: BMP, GIF, JPEG, and png.
  • The contents can be created automatically

Disadvantages:

  • # HTMLDOC does not manage yet CSS style sheets.
  • It is less easy to generate too complex documents HTML (For example: there is a limitation in the number of overlap of table HTML).
  • The compression of the files is not optimal, also it would be necessary to avoid the generation of too bulky file pdf.
  • It is difficult to have a precise formatting of the generated files

File HTML can be converted into file pdf with a command line under DOS:

htmldoc -t pdf --quiet -webpage -f fichier.pdf fichier.html

On the other hand since a dynamic site, if you must generate files pdf with stolen since ASP or PHP, for example, it is necessary for you to write a file HTML which will be to transform via the line of order carried out since the Web server. This call can be expensive in processing times.


Generate a PDF file on the fly from ASP :

'Sample script provided as is 
'by Dypso BackOffice: http://dypso.free.fr
'Please keep this link when using the script


' ****** The command line

CmdeHTMLDOC=chr(34)&"C:\Program Files\HTMLDOC\htmldoc.exe"&_
chr(34)& "  -t pdf --quiet "& _
"  --webpage -f "



' By consulting the file of documentation of HTMLDOC 
' you will realize 
' that numbers of parameters can also 
' be specified, as the font weight, its size, the compression 
' of the final document, etc. For example: '
' CmdeHTMLDOC = chr(34)& _
' "C:\Program Files\HTMLDOC\htmldoc.exe" & _
' chr(34) & "  --compression=1 --no-toc " & _
' " --pagemode document  "& _
' " --textfont Arial "& _
' " --fontsize 8 "& _
' " --header ... --footer ...  "& _
' " --size a4 --left 1.5cm "& _
' " --right 1.5cm "& _
' " --fontspacing 2 --webpage -f "



' ******* create a HTML file on the disk
Set FSO =   Server.CreateObject("Scripting.FileSystemObject") 
name_fileHTML= "fichier.html"
dir = Server.MapPath(name_fileHTML)
set inF = FSO.OpenTextFile(dir,2,true) 
	
inF.write "<html><body>"_
  "<table border=""1"" width=""90%"">"_
  "<tr><th>Employé</th><th>Salaire</th></tr>"_
  "<tr><td>Smith</td><td>1 000 euros</td></tr>"_
  "</table>"_
  "</body></html>"
	
'Close the HTML file
inF.close
			
	
	
' ******* generate the PDF file
set wshell=Server.CreateObject("wscript.shell")

' ******* Command line with the path to the exe
' ******* + the path to the HTML and to the PDF files

fic_html = dir
fic_pdf = Server.MapPath("fichier_test.pdf")

wpath= CmdeHTMLDOC &chr(34)& _
fic_pdf &chr(34)&" "& chr(34)& fic_html &chr(34)

' *******Run the command line
wshell.Run wpath, SW_SHOWNORMAL,true
Set wshell=nothing

' ******* The PDF document can now be opened
' ******* with JavaScript :

Response.write "<script>window.document.location.href='"&_
	 	Server.MapPath("fichier_test.pdf") & _
		"';</script>"
		
' ******* But it is also possible
' *******  to make a redirection on the PDF
' ******* file from the server (Response.redirect)
' ******* End of script
Response.End
Comment the article