WebDev help: Web Form + PDF

Started by RickJ, Wed 14/03/2012 00:20:50

Previous topic - Next topic

RickJ

I want to make a webpage where sub-contractors can signup by filling out a web form and submitting it.  The information they provide needs to be inserted into a number of government pdf forms and faxed to a government agency.   Some of the information that goes on the government forms is privileged and so would not be appropriate for the sub-contractors to view.    

I have found a fax service that offers an api that allows a number of file formats to be faxed through their service.   Their API provides the capability of combining a number of documents in to one fax.  It can also directly fax HTML pages.

The part I need help with is inserting the information into the PDF documents.  The obvious and first  thing to come to my mind is to display the pdf as a background image in an HTML page and then format the HTML to display the data at the proper positions.  It sounds too easy to be true.

I was just wondering if any of you super duper web guys have any experience or ideas about this?

Thanks
Rick

P.S. For anyone interested in the fax service I mentioned here is a link below.   Are there better fax services out there?
http://www.interfax.net/en

Khris

Quote from: RickJ on Wed 14/03/2012 00:20:50The obvious and first  thing to come to my mind is to display the pdf as a background image in an HTML page and then format the HTML to display the data at the proper positions.  It sounds too easy to be true.

Why? That's exactly what I'd do.
Code: ags
  <div style="position: relative; background-image: url(document.png);">
    <div style="position: relative; left: 210px; top: 432px;">John Doe</div>
    ...
  </div>

Eric

I would caution from experience that, before you fully code it, it might be worth a trial run to ensure that the API doesn't discard the background image when it formats the HTML.

RickJ

#3
@Khris:  Yeah, it seems that all of the online converters do this, so I guess it would be OK.

@Eric:  Like I said it seems too easy and that something would not work correctly.  I was of the mind that alignments may get screwed up but not rendering the background and other images sounds like it may be a problem.

Apparently Acrobat 9 will export directly to HTML but I would rather not pay.  I found a free alternative called PdfEdit (link below).  It runs under Linux and the beta version also runs under windows so I'll give it a try and see what kind of HTML it can produce..  
 
http://pdfedit.cz/en/index.html

[edit]
Not sure if PdfEdit does the export to HTML.  Found this pdfkit that does a fair job.  Output looks pretty good but the underlying auto generated html looks like crap.  It uses an image to draw the lines etc so why not just use an image of the whole thing just like I thought from the beginning? 

Here's the link in case anyone is interested.
http://www.pdfkit.com/

Khris

Does PDF even have to go into the equation at all?
Couldn't you just convert the form into a png image and use exclusively HTML?
If background images don't work, put the image in the HTML using the IMG tag and position the data using "position: absolute;".

Another way would be to generate the final image using PHP. It should be possible to print text onto a loaded image that way.

Snarky

It sounds like the government forms are something you need to care about but that your subcontractors shouldn't have to care about. Is that right?

If so, I wouldn't put the government forms online at all. Just create your own HTML form asking only the information you need, then when they submit it, your system fills in the government form on the back-end (i.e. it lays it out in a blank document, and uses the fax service to overlay it on the government form). You could even save their information in a database and associate it with an account they make, in case you need to fill out more forms about the same subcontractors in the future.

RickJ

@Khris: That  was exactly my first thought.  I then looked around a bit, found a bunch of online pdf->html converters.  They pretty much do the same thing, which tells me this is a common and ok technique.  I'm now back where I started but with more confidence.

@Snarky: You are absolutely right .  This is exactly what I had in mind.  The subcontractors would never see the actual fax that gets sent out.  The information would be entered on a separate web form, saved into a database, and then used to generate the appropriate documents to be faxed.   A copy of the generated documents would also be retained as a record of the application.   

The company books appointments with the subcontractors for the state government.  The state pays the company for the services the sub-contractors provide and the company pays the sub-contractors.   The company must send in an application, consisting of several documents, to the state for each sub-contractor.  These documents contain information about the sub-contractor's credentials and the company's tax-id number and other non-public details about the company.

SMF spam blocked by CleanTalk