Sample code for 30+ languages & platforms
Classic ASP

PDF File Encoding to Base64

See more Base64 Examples

Demonstrates how to encode a PDF file to base64, and then decode.

Chilkat Classic ASP Downloads

Classic ASP
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0

set pdfData = Server.CreateObject("Chilkat.BinData")

success = pdfData.LoadFile("qa_data/helloWorld.pdf")
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( "failed to load PDF file.") & "</pre>"
    Response.End
End If

' Encode the PDF to base64
' Note: to produce base64 on multiple lines (as it would appear in the MIME of an email),
' pass the string "base64_mime" instead of "base64".
b64 = pdfData.GetEncoded("base64")
Response.Write "<pre>" & Server.HTMLEncode( b64) & "</pre>"

' Decode from base64 PDF.
set pdfData2 = Server.CreateObject("Chilkat.BinData")
success = pdfData2.AppendEncoded(b64,"base64")
success = pdfData2.WriteFile("qa_output/helloWorld2.pdf")
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( "failed to write PDF file.") & "</pre>"
    Response.End
End If


%>
</body>
</html>