Example code is for an older version of WebGrabber, newer code is available.
<!-- Copyright (c) 2021 ActivePDF, Inc. -->
<!-- ActivePDF WebGrabber WBE 2010 -->
<!-- Example generated 03/06/21 -->
<!-- Example uses the .NET DLL which requires -->
<!-- Coldfusion 8 or above -->
<CFSCRIPT>
// Get current path
strPath = ExpandPath(".") & "\";
// Instantiate Object
// For WebGrabber in ColdFusion you must use a proxy DLL
oWG = CreateObject(".NET", "APWebGrabberProxy.APWebGrabber", "C:\Program Files\activePDF\WebGrabber WBE\bin\APWebGrabberProxy.dll");
// Add a header and footer to the PDF output
// The header and footer will be from URL containing HTML
// Calling HeaderHTML or FooterHTML will overwrite HeaderURL & FooterURL respectively
oWG.Set_HeaderURL("http://examples.activepdf.com/system/files/51/original/wghead.html");
oWG.Set_FooterURL("http://examples.activepdf.com/system/files/50/original/wgfoot.html");
// Enable extra logging - c:\windows\activepdf\logs
// Logging should be disabled during production
oWG.Set_Debug(true);
// Fast web view
oWG.Set_LinearizeDocument(true);
// Time to wait for conversion to complete (in seconds)
oWG.Set_Timeout(30);
// Margins (Top, Bottom, Left, Right) 1.0 = 1"
oWG.SetMargins(0.75, 0.75, 0.75, 0.75);
// 0 = Portrait, 1 = Landscape
oWG.Set_Orientation(0);
// Convert HTML fields to PDF fields
oWG.Set_PreserveButtons(false);
oWG.Set_PreserveCheckBoxes(false);
oWG.Set_PreserveDropDowns(false);
oWG.Set_PreserveRadioButtons(false);
oWG.Set_PreserveTextBoxes(false);
// Convert links
oWG.Set_PreserveLinks(true);
// Enable flash conversion
oWG.Set_EmbedFlash(true);
// PDF output location and filename
oWG.Set_OutputDirectory(strPath);
oWG.Set_NewDocumentName("WG-new.pdf");
// Save the HTML text into a file before conversion
oWG.Set_HTMLTextToFile(true);
// HTML to convert
oWG.Set_CreateFromHTMLText("<html><body>");
oWG.Set_CreateFromHTMLText("Hello World!");
oWG.Set_CreateFromHTMLText("</body></html>");
// Perform the HTML to PDF conversion
intDoPrint = oWG.DoPrint("127.0.0.1", 54545);
if(intDoPrint != 0) {
Error("DoPrint", intDoPrint);
}
// Cleans up all internal string variables used during conversion
// By default variables are deleted 3 minutes after the conversion
oWG.CleanUp("127.0.0.1", 54545);
// Release Object
oWG = 0;
// Process Complete
WriteOutput("Done!");
// Error Handling
Function Error(method, outputCode) {
WriteOutput("Error in " & method & ": " & outputCode);
}
</CFSCRIPT>