tags:

views:

183

answers:

4

hi there,

i would like to have a printer friendly function in PDF format for my website. I'm using asp classic. how can i do that? need advice. thanks..

A: 

What is a "printer friendly function in PDF format"? If you mean printer friendly format that allows people to print or export/print to PDF, then you just need to use some CSS. It's all client side programming and not related to your server side language.

Jim W
+1  A: 

If your content is static, just link to a PDF
If your content is dynamic, you can:

  • Add a link that render the same content as the original page, but with reduced style and graphic information. Then simply add the following script in the page:

    <script language='javascript' type='application/javascript'>
    window.onload = function() {window.print();};
    </script>

  • Install a PDF Writer in the server, and make PDF Versions of the page. This will perform seriously bad as every request to the "printer friendly" version will launch the component and make the printing. If you still need to do this, I can recommend bioPDF. Just take the HTML text you generated, save it as a file on the server, and then run bioPDF from its ActiveX interface to generate a PDF version from the html file.

Rodrigo
+1  A: 

You can use ABCpdf (free with the linkBack program) to generate your PDF from an HTML page (look for the ASP classic version).

In my case, I change the CSS to a more printer/PDF friendly version before the export.

Here is the code I use:

function CrearPDF( URL, FileName )
    dim theDoc, theID, iAux
    on error resume next

    set theDoc = Server.CreateObject("ABCpdf4.Doc")
    theDoc.Rect.Inset 20, 10

    theID = theDoc.AddImageUrl(URL, True, 0, False)

    do
     If (theDoc.GetInfo(theID, "Truncated") <> "1") Then Exit Do

     theDoc.Page = theDoc.AddPage()
        theID = theDoc.AddImageToChain(theID)
    loop

    For iAux = 1 To theDoc.PageCount
        theDoc.PageNumber = iAux
        theDoc.Flatten
    Next

    theDoc.Save Server.MapPath("../temp/") + "\" + FileName

    Set theDoc = Nothing

    if err.number <> 0 then
     CrearPDF = false
    else
            CrearPDF = true
     Call OutputFile( Server.MapPath("../temp/"), nombreArchivo  )
    end if
end function
Eduardo Molteni
A: 

Where I'm writing book-like content -- user manuals, for example -- and want both HTML and PDF, I use DocBook. This is an XML language similar to HTML, from which you can get HTML, PDF and other such output formats. There are many available toolchains. DocBook is best suited to highly structured content without a lot of fancy formatting.

If your site is heavy on the graphic design, the stock DocBook stylesheets won't be very useful, as they're geared toward plain vanilla formatting. But, you can write your own stylesheets using XSLT. Getting from XML to HTML is straightforward. For the PDF side, you could use a page layout program like InDesign, which knows how to import XML, parsing it and pouring the content into an existing layout. I recently heard from someone that did this very thing, so they could change the text of their site in one place and then generate the HTML and PDF versions.

Warren Young