Showing posts with label Server. Show all posts
Showing posts with label Server. Show all posts

Thursday, 25 September 2008

Add a Convert to PDF Button to a web page





ProductVersion


  • WebGrabber


  • 3.8


NB You need activePDF Server installed to use activePDF Webgrabber

The following ASP example demonstrates the process of adding a Convert to PDF button to a webpage. Once pressed, the button initiates an activePDF WebGrabber script that converts the page to PDF.

NOTE: This example is also available for ColdFusion®. Choose from the Code Sampleslist above to display the download link and information for the script appropriate for you environment.

This example follows these necessary steps:This example includes the following files:
  • button.asp - Script to create Convert to PDF button. (Code detail provided below.)
  • index.asp - Sample page containing script. (Code detail provided below.)
  • convert.asp - Conversion script run when Convert to PDF is pressed. (Code detail provided below.)
Click here to download this example (includes listed files)



button.asp










The
script controlling the display of the button.

NOTE: This script is designed to exclude the button from the output.

<%

' Get URL of page to convert

varURL = "http://" & request.servervariables("SERVER_NAME")
&_

request.servervariables("SCRIPT_NAME") & "?button=0&"
&_

request.servervariables("QUERY_STRING")


' Collect post data for the new session

PostData = ""

For Each x in Request.Form

If varPostData = "" Then

varPostData = x & "=" & Request.Form(x)

Else

varPostData = varPostData & "&" & x & "="
& Request.Form(x)

End If

Next


' Output the form to the screen

Response.Write("<FORM NAME='PrintToPDF' METHOD='POST' ACTION='convert.asp'>")

Response.Write("<INPUT TYPE='HIDDEN' NAME='PDFURL' VALUE='"
& varURL & "'>")

Response.Write("<INPUT TYPE='HIDDEN' NAME='PDFPOST' VALUE='"
& varPostData & "'>")

Response.Write("<INPUT TYPE='SUBMIT' NAME='SUBMIT' VALUE='Convert
to PDF'>")

Response.Write("</FORM>")

%>


index.asp











The
script added to the page.
<%
' Add the button to the
page

' Check to make sure querystring button is not set
to hide


If Request.QueryString("button") = "" Then

%><!-- #include file="button.asp" --><%

End If

%>

<html>

<head>

<title>activePDF.com - WebGrabber Convert to PDF Button Example</title>

</head>



<body>

This page contains the Convert to PDF button.</body>


</html>


convert.asp





The conversion script run when the button is clicked.






The
conversion script run when the button is clicked.

<%

' Define Variables

' Get the URL to convert

varURL = Request.Form("PDFURL")



' If the URL is empty go back to default page

If varURL = "" Then

%><SCRIPT LANGUAGE="JavaScript">history.go(-1)</SCRIPT><%

End If

' Get the post data

varPostData = Request.Form("PDFPOST")



' PDF Output Folder

varPath = Server.MapPath(".")


' EngineToUse (1=IE, 0=Native)

varEngine = 0


' Timeout for various calls

varTimeout = 60



' For local machine use these defaults

varIP = "127.0.0.1"

varPort = "64320"


' Set ASP Script Timeout

Server.ScriptTimeout = varTimeout + 1


' Instantiate Objects

Set WG = Server.CreateObject("APWebGrabber.Object")

Set APS = Server.CreateObject("APServer.Object")


' Set activePDF Server properties

APS.OutputDirectory varPath

APS.PDFTimeout = varTimeout


' Must call before DoPrint to pass server settings to WG

WG.Prt2DiskSettings = APS.ToString()


' Set WebGrabber properties

WG.EngineToUse = varEngine

WG.URL = varURL

WG.HTTPPostData = varPOSTData

WG.TimeOut = varTimeout

WG.PrinterTimeout = varTimeout

If varEngine = 0 Then

WG.PrintBackgroundColors = 1

WG.TopBottomMargin = 150

WG.LeftRightMargin = 150

End If


' Start the conversion process

varReturn = WG.DoPrint(varIP, varPort)

If varReturn <> 0 Then Error("DoPrint") End If


' Wait for conversion result

varReturn = WG.Wait(varIP, varPort, varTimeout, "")

If varReturn <> 19 Then Error("Wait") End If


' Run WG CleanUp

WG.Cleanup varIP, varPort


' Get New PDF filename

Call APS.FromString(WG.Prt2DiskSettings)

varPDFName = APS.NewUniqueID


' Clear Objects

Set WG = Nothing

Set APS = Nothing


' Send the PDF to the browser

%>

<SCRIPT LANGUAGE="JavaScript">

document.location.href="<% Response.Write(varPDFName &
".PDF") %>"

</SCRIPT>

<%

' Error Handling

Sub Error(Method)

Response.Write "'" & Method & "' failed with
a '" & varReturn & "'<br>"

Response.Write "<a href='http://www.activepdf.com/"

Response.Write "support/knowledgebase/viewKb.cfm?id=10033&tk=ts'>"

Response.Write "WebGrabber Return Codes KB Article</a>"

Set WG = Nothing

Set APS = Nothing

Response.End

End Sub

%>


Tuesday, 19 August 2008

The Manual Removal of activePDF Server

In certain situations, it may become necessary to perform a manual removal of activePDF Server. We strongly suggest that you contact the Greatstone International support team at support@greatstone.co.uk , prior to following these instructions. Symptoms that may preclude the need for manual removal of activePDF Server may include, but are not limited to the following:

Server is still installed after attempting removal.
Server remains in services.
Server files still on disk.

You have been asked to remove the software by the Greatstone International Support team.Unless a Greatstone Representative has instructed you to manually remove activePDF Server, we strongly recommend that you attempt to remove Server using the Windows Add or Remove Programs feature using the following instructions:
Log on as the Local Administrator or a User account with administrative rights on the local machine.
Click Start > Run, type services.msc /s, and then click OK.
Right-click the Print Spooler service, and then click Stop. NOTE: Stopping the Print Spooler service will stop all system printing processes.
Click Start>Run, type Control Panel, and then click OK.
Double-click Add or Remove Programs.
Locate activePDF Server, and then click Remove.
Click Start > Run, type services.msc /s, and then click OK.
Right-click the Print Spooler service, and then click Restart.
Restart the machine. If activePDF Server remains on your machine, you can use the following instructions to manually remove the software.

Details

The manual removal of activePDF Server requires that you edit the Windows Registry. Please read through the instructions carefully before attempting a manual removal of our software. Manually uninstalling activePDF Server requires that you edit the Windows Registry.
CAUTION: We strongly recommend that you back up the registry before making any changes. Incorrect changes to the registry may result in permanent data loss or damaged files. Make sure that you modify only the keys specified. For additional information on editing the registry, refer to you Microsoft® Windows documentation before proceeding.
Log on as the Local Administrator.
Click Start>Run, type services.msc /s, and then click OK.
Right-click the Print Spooler service, and then click Stop. NOTE: Stopping the Print Spooler service will stop all system printing processes.
Right-click Start, and then click Explore.
Navigate to the activePDF folder. If applicable, click Show all files in this folder to display any hidden files. By default, the location of this folder is X:\Program Files\activePDF. NOTE: The following steps provide instructions for removing activePDF Server items from your machine. If the item is currently in use by a system process, you will need to restart your machine before deleting these files. Depending on your current implementation of our software, some of these items may not be present. If the indicated item is not found, proceed to the next item or step.
Right-click the Server folder, point to Delete, and then click OK to confirm deletion.
Click Start>Run, type control printers, and then click OK.
Locate the following printers. For each printer, right-click, point to delete Delete, and then click OK to confirm deletion.
ActivePDF-9
activePDF Postcript (4) Printer
activePDF Shadow Printer
Any printer with activePDF in the name that you did not create yourself.
Navigate to the X:\WINDOWS\SYSTEM32\ or X:\WINNT\SYSTEM32\ folder, depending on your currently installed Windows OS.
Locate the following files. For each file, right-click, point to delete Delete, and then click OK to confirm deletion.
APServer.exe
APServer.OCX
WSPTPDF.EXE
Navigate to the X:\WINDOWS or X:\WINNT folder, depending on your currently installed Windows OS.
Locate the following items. For each item, right-click, point to delete Delete, and then click OK to confirm deletion.
activePDF Server folder
activePDF folder
activePDF Server Uninstall Log.txt
activePDFdebug.log
ap-pool.log
apspdf.log
Click Start>Run, type regedit, and then click OK.
Locate the following keys. For each key, right-click, point to delete Delete, and then click OK to confirm deletion. NOTE: Depending on your current implementation of our software, some of these keys may not be present. If the indicated key is not found, proceed to the next file or step.
HKEY_LOCAL_MACHINE\SOFTWARE\activePDF\activePDFServer
HKEY_LOCAL_MACHINE\SOFTWARE\activePDFServer
HKEY_LOCAL_MACHINE\SOFTWARE\activePDF, Inc.\activePDF Server
Locate the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall key.
Locate a subkey with with a name similar to {5B09844C-B342-4C9E-A16F-DA7032C7B417}. This subkey will contain the following String Value entries >> Data values:
DisplayName >> activePDF Server
LogFile >> X:\Program Files\...
UninstallString >> RunDll32 X:\PROGRA~1\....
After verifying the String Values are present, right-click the subkey, point to Delete, and then click Yes to confirm deletion.
Click Start>Run, type services.msc /s, and then click OK.
Right-click the Print Spooler service, and then click Restart.
Restart the machine.
NOTE: If you still require additional assistance, please contact Greatstone International at suppoprt@greatstone.co.uk .