HOME

Products
The Arc
HTML to PDF

Free CollinsPDF.js
Free CollinsHTML.js
Free GIS

(on-line service)
CustomerCareSystem
Scripts
 
CollinsPDF FAQ More Examples How to Modify Reference Guide Sample Report
 
CollinsPDF.js  PDF Generator 

100% JavaScript (version 1.10)
Client or Server Side PDF creation

FREE DOWNLOAD

Updated July 20, 2010
addTextbox 

 

See also: Free Download CollinsHTML.js

A JavaScript Report Generator / PDF file creation object. Create PDF reports at the server or client side without the need for any extra software or libraries. The CollinsPDF.js handles many of the standard reporting functions (group header/footers, keep together, cell alignment), to produce an excellent Report with minimum coding.

You can produce PDF Reports on an ASP web server, or at the client. There is nothing to install, simply include the CollinsPdf.js file and begin calling its functions.

Other Capabilities:

  • Pagination
  • Portrait or Landscape
  • Word wrap
  • Font Name, Color, Size, Bold, Italic, Underline, Subscript, and Superscript
  • Text Displays, Render, Scale, Letter/Word Spacing, Skew
  • Page Margins
  • Bookmarks (multiple levels)
  • Page Header and Footer
  • Reporting (groups, group headers, group footers, keep together, details)
  • Rulers (columns, word wrap, truncate, justifications, borders, vertical alignment)
  • Landscape and Portrait
  • Graphics (Lines, Rectangles, Polygons, Circles, Cones,  Text, Symbols, Grid, Arcs, Pie Chart, Graphs)
  • Graphic Line Styles, Line Color, Fill Color
  • Symbols
  • Text Boxes
  • Download Images from
  • Watermarks
  • Hyperlinks
  • Run at Client or Server (ASP)
  • Write to file, send to client, send to server
  • Jpeg URL Images (add images as from a URL address, map servers such as Google-maps)
Client Side - Minimum Code:

<html><head>
<script src="CollinsPdf.js" language="JavaScript"></script>
<script>
function createPdf()
{
    pdf = pdf$();
    pdf.addText('Hello World');
    pdf.writeToFile('c:/temp/hello_world.pdf');
    window.open('file://c:/temp/hello_world.pdf');
}
</script>
</head><body>
<input type=button value="Create Pdf file" onClick=createPdf()>
</body></html>


Server Side - Minimum ASP Code:

<%@ language=JavaScript%>
<script SRC="CollinsPdf.js" language="JavaScript" runat="Server"></script>
<%
    pdf = new pdf$('SAMPLE');
    pdf.addText('The date is: ' + new Date());
    pdf.sendToClient('sample_asp.pdf');
%>



Google Maps Server Side Example:
 

var url,pdf;

url = "";
url += "http://maps.google.com/maps/api/staticmap?";
url += "center=Brooklyn+Bridge,New+York,NY&zoom=14";
url += "&size=512x512&maptype=roadmap";
url += "&markers=color:blue|label:S|40.702147,-74.015794";
url += "&markers=color:green|label:G|40.711614,-74.012318";
url += "&markers=color:red|color:red|label:C|40.718217,-73.998284";
url += "&format=jpg";
url += "&sensor=false&key=your-key-code";


pdf = new pdf$();
pdf.placeImage(2,2,url,5,0,0);

pdf.setFontSize(24);
pdf.setBold(true);
pdf.setItalic(true);
pdf.placeText(2,0.5,'Collins Software');
pdf.setFontSize(14);
pdf.placeText(2,1,'Googlemaps to PDF');

pdf.sendToClient('GoogleMaps.pdf');
delete pdf;


Adding Images as a Web URL (Client Side Example)

view: ICMap generated static image


var url,pdf;
 

pdf = new pdf$();

url = 'http://CollinsSoftware.com/icmap/ic_ecp/bin/ICMapIS.cgi';
url += "?name=ecp&height=600&width=600";
url += "&x=-95.48151&y=29.79966";
url += "&level=3&layers=states&format=jpg";
 

pdf.placeImage(2,2,url,3,0,0);

pdf.setFontSize(24);
pdf.setBold(true);
pdf.setItalic(true);
pdf.placeText(2,0.5,'Collins Software');
pdf.setFontSize(14);
pdf.placeText(2,1,'Url Image to PDF');

pdf.writeToFile('c:/temp/Sample_UrlImage.pdf');
delete pdf;

 

VBSCRIPT Server Side ASP Example, (using collinsPDF.js in VBSCRIPT)
Create an Invoice

<script SRC="collinsPDF.js" language="JavaScript" RUNAT="Server"></script>
<script SRC="collinsPDF.vb" language="VBScript" RUNAT="Server"></script>
<%
'************************************************************************
' Invoice.asp
' Author: Clif Collins Date: May 2010
'------------------------------------------------------------------------
'
' Copyright (c) 2010 Clifford L. Collins
' All rights are reserved
'
'************************************************************************

Response.Expires = -1
call Execute()

'=========================================================================
'                         Execute
'=========================================================================
Function Execute()

dim pdf,filename,text
dim po,dateOrdered,shipTo,shipType,phone,billTotal,billTax,billShipping
dim borderWidth

set pdf = vb_pdf()
pdf.setMargin 1,1,2,1
pdf.setFontSize(12)
set pdf.onPageHeader = GetRef("onPageHeader")
set pdf.onPageFooter = GetRef("onPageFooter")

pdf.setBold(true)
pdf.addText "Thank you for your purchase "
pdf.setBold(false)

pdf.lineBreak
pdf.lineBreak

'------------------ order details --------------------

CR = Chr(13) & Chr(10)

orderNumber = "10034"
dateOrdered = "May 5, 2010 3:31 pm"
shipTo = "Rachel Collins" & CR & "7710 Janak Drive" & CR & "Houston, TX 77055"
shipMethod = "Next Day Air"
phone = "(713) 682-1556"
billAmount = "$300.00"
billTotal = "$357.56"
billTax = "$45.56"
billShipping = "$12.00"

call orderDetail(pdf,orderNumber,dateOrdered,shipTo,shipMethod,_
                 phone,billAmount,billTotal,billTax,billShipping)

pdf.ruler.end()
pdf.lineBreak
pdf.lineBreak

'--------------------Items Ordered ----------------------

pdf.pageBreak

borderWidth = 1
pdf.setRuler "1,1.6W,5.5W,7",borderWidth
pdf.setBold(true)
TEXT = "QTY" & pdf.tabCharacter & "Product Name" & pdf.tabCharacter & "Price"
pdf.addReportText(text)
pdf.setBold(false)

' -------- Item 1 -----

item_qty = 1
item_name = "Common Groud 2000 CPU License"
item_total = "$100.00"

call orderItem(pdf,item_qty,item_name,item_total)


' -------- Item 2 -----

item_qty = 1
item_name = "ICMap CPU License"
item_total = "$200.00"

call orderItem(pdf,item_qty,item_name,item_total)

'--------------------------------------------------------

pdf.ruler.end()

text = "Thank you for the order"
pdf.setFontColor("Gray")
pdf.setFontSize(10)

pdf.centerText(text)

pdf.sendToClient

END Function
'================================================================
'                 onPageHeader
'================================================================
Function onPageHeader(page,total,pdf)

filename = Server.MapPath("./CollinsSoftwareInvoice.jpg")
pdf.placeImage 0.5,0.1,filename,1

End Function

'================================================================
'                 onPageFooter
'================================================================
Function onPageFooter(page,total,pdf)
dim text

text = "Page " & page & " of " & total
pdf.centerText(text)

End Function

'================================================================
'                 orderDetail
'================================================================
Function orderDetail(pdf,orderNumber,dateOrdered,shipTo,shipMethod,_
        phone,billAmount,billTotal,billTax,billShipping)
 

dim text

pdf.setRuler("1,3W,7")

TEXT = "Order Number:" & pdf.tabCharacter & orderNumber
pdf.addReportText(text)

TEXT = "Order Date:" & pdf.tabCharacter & dateOrdered
pdf.addReportText(text)

TEXT = "Ship to:" & pdf.tabCharacter & shipTo
pdf.addReportText(text)

TEXT = "Phone:" & pdf.tabCharacter & phone
pdf.addReportText(text)

TEXT = "Shipping Method:" & pdf.tabCharacter & shipMethod
pdf.addReportText(text)

TEXT = "Order Amount:" & pdf.tabCharacter & billAmount
pdf.addReportText(text)

TEXT = "Order State Tax (Texas):" & pdf.tabCharacter & billTax
pdf.addReportText(text)

TEXT = "Order Shipping:" & pdf.tabCharacter & billShipping
pdf.addReportText(text)

TEXT = "Order Total:" & pdf.tabCharacter & billTotal
pdf.addReportText(text)

End Function
'================================================================
'                 orderItem
'================================================================
Function orderItem(pdf,item_qty,item_name,item_total)

dim text,name,cr

TEXT = item_qty & pdf.tabCharacter & item_name & pdf.tabCharacter & item_total
pdf.addReportText(text)

END Function
%>