Link to home
Start Free TrialLog in
Avatar of klewlis
klewlis

asked on

activePDF Toolkit and php

Hi,

I'm trying to use the activePDF Toolkit with php on a windows box. I'm having a hard time getting it working because I'm not too familiar with COM objects in PHP. Does anyone have a code example to get this working? I'm trying to fill pdf form fields with data submitted from another pdf. The examples on the activePDF site are only asp and coldfusion!
Avatar of klewlis
klewlis

ASKER

more specifically, I need to figure out how to translate this into php:

------------------
Set TKIT = Server.CreateObject("APToolkit.Object")
FileName = TKIT.GetUniqueFileName()
r = TKIT.OpenOutputFile(Server.MapPath(FileName))
r = TKIT.OpenInputFile(Server.MapPath("Template.PDF"))

For Each FormItem in Request.Form
If FormItem <> "SUBMIT" Then
TKIT.SetFormFieldData FormItem, Request(FormItem),0
End If
Next


r = TKIT.CopyForm(0,0)
TKIT.CloseOutputFile
----------------------

it doesn't LOOK hard but I can't seem to get it right (or else something else is wrong and it's just not working...)
ASKER CERTIFIED SOLUTION
Avatar of Richard Quadling
Richard Quadling
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of klewlis

ASKER

that's pretty much what i tried first... just a straight translation. but for some reason
$xOutput = $objAPT->OpenOutputFile(somefunction(FileName));

returns an error every time, and even though the *input* line doesn't return an error, anything i try to do with the input file after that returns an error (or nothing at all).
Avatar of klewlis

ASKER

ps: the server.mappath is just to get the full directory path of the file rather than just the local path. i've tried it both with the full path and without, with no change...

i'm going to turn on that full error reporting and see if it helps.
What is the exact error? (Cut'n'paste rather than re-type).

A couple of things with the output file.

1 - Does PHP have permission to write to the directory that you is being used.
2 - If so, create an zero length file (right click in explorer, new text file, save and close) and then rename it to match the filename that is being used as the output file.

What does the "somefunction" do? I'm not familiar with ASP, so the Server.MapPath() function will need to be handled.

You could also use OLEView to make sure you are using the correct parameters and types. Do a search on Google for OLEView and Microsoft, download OLEView from MS. Then do a search for ipviewers.dll. This is a support file for OLEView which is not supplied! I use one called warex.dll (that's the name it came with). It works. And allows you to see the types and names and methods and objects in a COM library very clearly.

Richard.
IVIEWERS.DLL sorry, not IPVIEWERS.DLL

Also set the timelimit as some COM libraries may be a little slow, or the amount of time the script can run for on the server may be shorter than required.

Avatar of klewlis

ASKER

i think i'm going to die of shock. lol

i turned off all my die messages and just ran through the function.

it works.

as long as i don't include the "or die". it seems to be working *and* dying. what an odd thing. but i just got my first successful output file! yay! thanks for your help, rquadling. :)