Friday 17 October 2008

Accessing Toolkit 4.0 as a reference via COM Interop in .NET

ProductVersion   
Toolkit Lite
Toolkit Std
Toolkit Pro
4.0
 
Description
 
In certain implementations, you may not be able to instantiate Toolkit in .NET using the provided APToolkitNET.dll. It is possible to access Toolkit using a COM Interop in these situations.
 
Details
 

Referencing the APToolkit 4.0 Type Library

You must add a reference to the APToolkit 4.0 Type Library to use Toolkit as a COM interop in .NET. If the reference is incorrect or missing, the resultant script will cause a missing type or namespace error. Use the following steps to a reference to the type library:

 

  1. Start Visual Studio® .NET.
  2. In the Solution Explorer, right-click Reference, and then select Add Reference.
  3. In the Add Reference dialog, click COM.
  4. On the COM tab, select the APToolkit 4.0 Type Library, and then click OK


Instantiating the Objects in C#

You can instantiate the objects via COM interop after referencing the APToolkit 4.0 Type Library in the project. The following instructions provide the necessary steps for C#:

NOTE: These instructions cover the instatiation of the Toolkit 4.0 Professional Edition objects. These objects may not be available in the Standard or Lite editions.


 

  1. Add the following line to the beginning of your .NET code:
  2.  

    using APTOOLKITLib;

     

  3. Add one of the following declarations depending on your implementation:
    •  

    • Global Scope
    •  

      public static APTOOLKITLib.APToolkitClass TK = newAPTOOLKITLib.APToolkitClass();

       

    • Local
    •  

      APTOOLKITLib.APToolkitClass TK = newAPTOOLKITLib.APToolkitClass();
  4. Instantiate the object, using the syntax that pertains to the object you are using:
  5. NOTE: The following instructions assume you are using a Local declaration

       

    • To instantiate the Toolkit object:
    •  

      // Instantiate Toolkit object.
      APTOOLKITLib.APToolkitClass TK = newAPTOOLKITLib.APToolkitClass();

       

    • To instantiate the FieldInfo object:
    •  

      long r;
      // Instantiate Toolkit object.
      APTOOLKITLib.APToolkitClass TK = newAPTOOLKITLib.APToolkitClass();
      // A valid PDF must be opened as input
      r = TK.OpenInputFile("input.pdf");
      // Instantiate FieldInfo Sub-object. 
      // Must specify name and instance of field.
      PDFFieldInfo FIO = TK.FieldInfo("fieldname", 1);

       

    • To instantiate the Text2PDF object:
    •  

      // Instantiate Text2PDF Sub-object.
      Text2PDF T2P = new Text2PDF

       

    • To instantiate the ListItems object:
    •  

      long r;
      // Instantiate Toolkit object.
      APTOOLKITLib.APToolkitClass TK = newAPTOOLKITLib.APToolkitClass();
      // A valid PDF must be opened as input
      r = TK.OpenInputFile("input.pdf");
      // Instantiate FieldInfo Sub-object. 
      // Must specify name and instance of field.
      PDFFieldInfo FIO = TK.FieldInfo("fieldname", 1);
      // Instantiate ListItems Sub-object. 
      ListItems LST = FIO.ListItems();

       

    • To instantiate the Explorer object:
    •  

      long r;
      // Instantiate Toolkit object.
      APTOOLKITLib.APToolkitClass TK = newAPTOOLKITLib.APToolkitClass();
      // A valid PDF must be opened as input
      r = TK.OpenInputFile("input.pdf");
      // Instantiate Explorer Sub-object.
      TKExplorerObject EXP = TK.Explorer();

       

    • To instantiate the Barcode object:
    •  

      // Instantiate Barcode object.
      APTKBarcodeObject BCD = new APTKBarcodeObject

       

    • To instantiate the Flash object:
    •  

      // Instantiate Flash object.
      TKFlashObject FLSH = new TKFlashObject


Additional Considerations


 

If you are using C# as the scripting language on an ASPX page, you will need to use aCodebehind property. More information can is available in the Microsoft® knowledge base article located at http://support.microsoft.com/default.aspx?scid=kb%3ben-us%3b321748.

CAUTION: The information provided by this source is not regulated or guaranteed by activePDF, and is subject to change without notice. We strongly recommend that you read all posted warnings and cautions provided by this source, prior to implementing any recommend changes.

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

%>


Thursday 21 August 2008

DocConverter Simple GUI for File Conversion

The following VB.NET example demonstrates a basic GUI implementation of activePDF DocConverter. The interface provides an easy way for the user to convert a file to PDF and specify the location for DocConverter's common setup requirements.

Required Components

NOTE: You must reference the APDocConvNET.DLL in order to run the example. Refer to KB #9 for instructions.

Click here to download this example (does not include DLL).





Figure 1.1: DocConverter Example GUI.

The GUI has these required settings:

  • File to Convert: The full path to the file to convert to PDF.
    NOTE: The corresponding DocConverter Processors must be installed for best conversion quality.
  • Folder to Place PDF: The full path for the location to place the output PDF.
  • Folder to Place Error Files: The full path where any files that are unable to convert are placed.
  • Folder to Place Original Document: The full path to store the original input file after conversion.
  • IP of DocConverter Machine: The IP address for the machine where DocConverter is installed (Defaults to 127.0.0.1).
  • Port (0 for Default): The port assigned to the Submit and CheckStatus methods (Defaults to 0 for 53540).
  • Timeout (Seconds): The timeout in seconds (Defaults to 30).

Support Tools Reports Evaluation Expired or No License Found on Production System (Device Mismatch)

Description

activePDF Support Tools displays the message Evaluation Expired or No License Found on Production System (Device Mismatch), though a valid license has been installed.

Cause

A change has been made to the system on which the activePDF product is run that has caused the calculated Machine ID to have changed. As all activePDF licenses are registered using a specific Machine ID, the system's Machine ID must match the license for the product to run properly.

Resolution

This issue can be resolved by simply re-activating the product license(s).To re-activate the license:
Launch the activePDF License Administrator utility by clicking Start, pointing to All Programs, activePDF, and then clicking activePDF License Administrator.
Select the product activation key displaying a Device Mismatch state.
From the menu bar, select Activation and click Re-activate.
NOTE: License Administrator may require several seconds to complete requested action.
Repeat steps starting with step #2 until all licenses displaying Device Mismatch status have been re-activated.

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 .