Skip to main content
Known Participant
December 14, 2012
Question

Functionality spec - is this possible to achieve?

  • December 14, 2012
  • 8 replies
  • 932 views

I have a request from a client for an app that requires certain functionality I am unsure is possible. I am happy to learn how to do it if it is possible but just wanted to get a yay or a nay as to whether this should be possible to implement.

App is for iPad only.

The app is to be used by Health & Safety inspectors and needs to generate and email a report (ideally in pdf format) to a designated recipient.

The app will consist primarily of a form where each form field requires the inspector to enter a value

The inspector can include a photo associated with any of the form fields (the photo can be taken using the iPad camera or one chosen from the photo library on the iPad.

Once the form has been completed clicking on a Submit button will send the data to an external server and the server will deal with creating the pdf and emailing it.

I have created PDF files on the fly before using PHP so I know that in theory this is possible but I just need to get some reassurance that I will be able to implement the entire process described above.

I am not looking for a ready made solution - just really some reassurance this is technically possible without too many headaches. If you can spot any problematic elements please let me know.

Thanks

Paul

This topic has been closed for replies.

8 replies

Colin Holgate
Inspiring
December 14, 2012

If you think about a worse case, an inspector might have lined up ten 8 megapixel images, and that final post could take quite a while. Could you design the form as a series of pages, where at the end of each entry you post that page's worth of data?

Doing it that way would mean you could call one PHP script that cues up the many pages to make the PDF, then on the last screen you call a different PHP that combines the previously uploaded images, and sends them as a PDF to the specified email address.

I don't think it would be easy to make that final PDF have editable text, it would just be a series of images.

As for the creating and sending of the image, you can image a movieclip that is a template of the page in question. When the form is filled in you do a draw() of the movieclip to create the bitmap you need to submit, and then you call the PHP with the bitmap data.

Here's a function from something I made recently, that is able to send a bitmapdata as a png or jpg to various PHPs:

public function sendflake(bmd:BitmapData,type:String="save",format:String = "png",fromname:String = "",toemail:String = ""){

          var t:int = getTimer();

          var byteArray:ByteArray = new ByteArray();

          if(format=="png"){

                    bmd.encode(new Rectangle(0,0,bmd.width, bmd.height), new PNGEncoderOptions(), byteArray);

          trace("png",getTimer()-t);

          }else{

                    bmd.encode(new Rectangle(0,0,bmd.width, bmd.height), new JPEGEncoderOptions(), byteArray);

          trace("jpg",getTimer()-t);

          }

          var loader:URLLoader = new URLLoader();

          var path:String = host+"saveimage.php"

          if(type=="print"){

                    path = host+"printimage.php"

          }

          if(type=="email"){

                    path = host+"emailimage.php"

          }

          var url:String = path + "?name=" + fromname + "&email=" + toemail;

          var req:URLRequest = new URLRequest(url);

          req.requestHeaders =  new Array(new URLRequestHeader("Content-type","application/octet-stream"));

          req.method = URLRequestMethod.POST;

          req.data = byteArray;

          loader.addEventListener(Event.COMPLETE,sent);

          loader.load(req);

}

The gettimer parts are just to make sure the PHP URL is not still cached, and the various PHPs are used to either send the image to a playback AIR app, to a print server, or to email to someone.

Colin Holgate
Inspiring
December 14, 2012

Just reread that script. In this case I was only using gettimer to see how long the encoding took. It other versions I have used the value to make sure the online data was not cached.

P StevenAuthor
Known Participant
December 14, 2012

Thank you Colin for your reply. I hadn't considered the iPad photos to be that large I guess because any photos I have taken with my iPad 2 have looked so awful I assumed they were fairly low res. This app needs to be used on site and as such will rely on whatever connection is available over the air. I would therefore be concerned at the thought of sending that much data even if it was broken down into stages. I do not suspect my client would require the images to be high res and therefore wonder if it would be possible for the app to resize the images prior to sending them - so for example they could be resized to say 800 x 600 pixels 72DPI which would only be a few hundred KB - is this possible within the app?

I thought when I had previously created PDF files using PHP (FPDF) that it was able to add editable text but could be mistaken as it was several years ago.

Thank you for the script - that is really helpful.

I hope that it is possible to resize the images prior to sending the image data to the server.