Page 1 of 2
Snapshot of card to email print or photo album
Posted: Thu Apr 25, 2013 7:51 pm
by FireWorx
Hi I have a card that contains several fields, a few buttons, a couple groups, and a couple images. The Card is a form letter that needs to be emailed to a client. Not sure what the best way to do this is. I tried this.
on mouseUp
export snapshot from this cd to file pictvar as JPEG
mobileExportImageToAlbum pictVar
end mouseUp
I only get bits and pieces of the card (like the IOS keyboard if its up or the empty background if its not) to export to the album. I also tried
on mouseUp
put specialFolderPath("documents") & "/Letters/" into TFilePath
set the defaultfolder to TFilePath
export snapshot from rect "0,41,768,974" to file "Inspector.jpg" as JPEG
end mouseUp
The file does end up in the folder (i verified that) but when I try to import them back into an existing image in the stack. (To see if they contain the image of the card ) with the script below well then the image I am trying to import them into disappears. poof.
on mouseUp
put specialFolderPath("documents") & "/Letters/Inspector.jpg" into TFilePath
put url("binfile:" & TFilePath) into image"Fire" of this card
end mouseUp
How should I go about this?
Thanks
Dave
Re: Snapshot of card to email print or photo album
Posted: Thu Apr 25, 2013 8:01 pm
by Dixie
Dave
Code: Select all
put specialFolderPath("documents") & "/Letters/Inspector.jpg" into TFilePath
set the filename of image "fire" to TFilePath
Dixie
Re: Snapshot of card to email print or photo album
Posted: Thu Apr 25, 2013 8:48 pm
by FireWorx
I have uploaded a stack so you can see that it is not working and possibly come up with some ideas.
I would like to take a snapshot of the screen and email it.
There is a hidden image on the card that is the same size as the card. I would like to take a snapshot of the card (which in real life is an official looking document and save it to a folder as a JPG. And then switch it out with a hidden image on the card and send it to the photo album so I can email it. If there is a better way to do it I am all ears.
This is failing though.
Here is the example stack dixie perhaps you can take a look.
Dave
Re: Snapshot of card to email print or photo album
Posted: Thu Apr 25, 2013 10:55 pm
by FireWorx
Ok I have the snapshot taking a picture of the card ok. But I still cant get it to the Photo album. I am using the script below and getting the error message. "Not a Supported format". I made sure I had at least 1 photo in the album as specified in the bottom of the notes in the dictionary.
on dothesnap
put the number of images of this card into tImages
put the rect of card 1 into tRect
import snapshot from rect tRect
put timages + 1 into timages
put the long ID of image timages into tImageID ## a very long Simulator ID & didn't work
##put word 1 to 3 of tImageID into tImageID ## I tried this to shorten the ID to "Image ID 1042" but still no luck
##answer tImageID ## this returns
mobileExportImageToAlbum tImageID ## returns"Not a Supported format with both of the above"
put the result into tresult
answer tresult
end dothesnap
Re: Snapshot of card to email print or photo album
Posted: Fri Apr 26, 2013 9:15 am
by FireWorx
Ok still working on this. I think a better way to go is take a snap shot of the card and just e-mail it as an attachment with the mobilecomposemail command.
So funny enough if I take the snap shot BEFORE i take it into the simulator the image is email able as an attachable from IOS. But if I take the snapshot of the card from within the simulator or devise it is not.
Here is an example stack. load it into the simulator and press the "mail It" button. Notice the image pop up as an attachment. Now click the "Take snap shot of card and move it down" button. It takes a screen shot but when you click the "email it" button again. No attachment pops up.
Can anyone help with this? I have spent a full day trying to take a snap shot of a card and email it in IOS. I have a form letter I need to get off the iPads and into the hands of clients.
There may be other options and I am open to ideas and code snippets.
Thabnks,
Dave
Re: Snapshot of card to email print or photo album
Posted: Fri Apr 26, 2013 9:11 pm
by FireWorx
Ok just thought I would report back. I feel like I am a little closer but not there yet. I am thinking the best way to get a screen shot of the card or a portion of the card and email it to a client is by using the "print to PDF" command.
Here is my code.
Captures the screen and saves it to a PDF file. I can retrieve the PDF using Monte's external mergeReader so I know its capturing the screen ok. Then I email it. The problem must be in my email code. The PDF gets e-mailed but there is just one line of text in the PDF.
"/var/mobile/Applications/339D0561-23FB-4DEA-9E94-3E727DD73F9E/Documents/Inspection.pdf.
2 days and nights working on this and only one two line response from the user group. Thanks Dixie. Am I breaking trail here? Give me something guys !
on printPDF
-- PDF Printing
put specialFolderPath("documents") & "/Inspection.pdf" into tFilePath
lock screen
open printing to pdf tFilePath
if the result is "Cancel" then exit printPDF
print card "MyCard" of stack "Snapshot Example" into 0,0,320,460
print break
close printing
if there is a file tFilePath then answer "yes the file exists" ##Yahoo it exists !!!
------------ Now email it-----------
put specialFolderPath("documents") & "/Inspection.pdf" into tFilePath
put tFilePath into tAttachment["data"]
put "pdf" into tAttachment["type"]
put "Inspection" into tAttachment["name"]
mobileComposeMail "Image Example", "
kitethewind@gmail.com",,,, tAttachment
put the result into tresult
answer tresult
end printPDF
Re: Snapshot of card to email print or photo album
Posted: Sat Apr 27, 2013 12:28 am
by Simon
OK I have looked at your stack and yer just hurting yourself.
Take a snap
Code: Select all
on mouseup
if the environment is "development" then
set the defaultfolder to specialFolderPath("desktop")
else
set the defaultfolder to specialFolderPath("documents")
end if
--if there is an image "myimage" then delete image "myImage"
put "" into img "MyImage"
put the rect of card 1 into tRect
--import snapshot from rect tRect
export snapshot from rect tRect to file "Inspector.jpg" as JPEG
--put the id of last image into tImageID
-- set the name of image id tImageID to "myImage"
--set the top of image "myImage" to 150
end mouseup
That has saved the image to the documents folder on iOS, desktop IDE.
mail it.
Code: Select all
on mouseUp
if the environment is "development" then
set the defaultfolder to specialFolderPath("desktop")
else
set the defaultfolder to specialFolderPath("documents")
end if
put url("binfile:Inspector.jpg") into tData --This might not be needed
put tData into tAttachment["data"]--try replacing tData with "Inspector.jpg"
put "image/jpg" into tAttachment["type"]
put "Inspection" into tAttachment["name"]
mobileComposeMail "Image Example", "kitethewind@gmail.com",,,, tAttachment
put the result into tresult
answer tresult
end mouseUp
Give that a try!
I think I have a couple of this wrong in there because I'm not sure how you are using this. But you can work it out.
Simon
Re: Snapshot of card to email print or photo album
Posted: Sat Apr 27, 2013 1:16 am
by Simon
Just thought of something else:
Code: Select all
on mouseUp
put the imageData of image "MyImage" into tData
put tData into tAttachment["data"]
put "image/gif" into tAttachment["type"]
put "Inspection" into tAttachment["name"]
....
Just that change might get you what you want.
Simon
Re: Snapshot of card to email print or photo album
Posted: Sat Apr 27, 2013 4:15 am
by FireWorx
Thanks Simon,
I'll report back. Looking through the posts I see you helping a lot of people in the trenches. Thanks for your support and may you have divine enlightenment and a constant flow of good karma. =)
Dave
Re: Snapshot of card to email print or photo album
Posted: Sat Apr 27, 2013 6:37 am
by FireWorx
Works great Simon on my single card no frills stack. I am still having some issues with it in the stack that contains 4 cards and the card in question has an IOS input field, 1 hidden group, and 1 hidden image on it. I will duplicate the stack and be careful to keep the original stack out of memory as I strip away the controls one by one until I find out what the conflict is.
Thanks again. It's a handy combo. Just snap and shoot. I like it!
Dave
Re: Snapshot of card to email print or photo album
Posted: Sat Apr 27, 2013 7:09 am
by Simon
Glad it's working for you so far.
One of the difficult parts of answering questions correctly is figuring out what is it's end point is and giving a helpful answer. A problem of public forums.
But, what you have said so far I think might be cool.
Suppose it was a system of pressuring your local government.
If you see a pothole, put a pound coin next to it and take a picture, combined with the email of your local MP. Nice.
In "settings" just place the MP's email address in and in little time you've done the community a service.
Crap, I've become a Socialist.
Simon
Re: Snapshot of card to email print or photo album
Posted: Sun Apr 28, 2013 7:54 am
by FireWorx
So I ran down the conflict. It was the Tactile Media script that gets loaded in if you use there objects to auto adjust to normal vs retina. To be fair to TM it could have been the one line of TM code I commented out so my app would open up full screen on retina iPads. oops. oh well
Hey by the way is there away to check to see what the image source of an image object is? I am loading pics of John Hancock style signatures into a signature image box on the form. Before I let the user email it off I want to check to make sure they didn't forget to sign the form. I want to check to see if the image source is special folder path/documents/blank.jpg or /somebodySignature.jpg.
Dave
Re: Snapshot of card to email print or photo album
Posted: Sun Apr 28, 2013 8:21 pm
by Simon
Hi Dave,
Not sure about your question. Rather than blank.jpg wouldn't you make sure there was a file named somebodySignature.jpg? If that did not exist then they hadn't made one yet.
Other than that an empty image has nothing in it's imageData.
Simon
Re: Snapshot of card to email print or photo album
Posted: Mon Apr 29, 2013 4:45 pm
by FireWorx
Sorry Simon I should have been more clear. I have two procedures. The image "Sig Block" gets filled with a signature with the AddSignature procedure below. Then cleared with the blankOutSignature procedure. So I would like to check to see which jpg image is the source of "Sig Block" so I can remind the user to sign the form if it is blank. The "Sig Block" name never changes just the image it contains.
I could keep track some other way like say in the AddSignature handler ad a line -- put "yes" into globalVarSignedStatus--- and then check the status with... on checkSigStatus I guess using global vars and clearing them on close card is not too bad but thought perhaps there is an easier and more sano way to check the status.
on checkSigStatus
if globalVarSignedStatus is "yes" then
go ahead with the snap and shoot
else
answer "Please remember to sign the document below before mailing it."
end if
end checkSigStatus
on AddSignature
## check the global var that should be created at password log on for the sesh and add the appropriate signature
##but for now
put "Dave Herndon" into gSignature
put specialFolderPath("engine") & "/signatures/" & gSignature & ".JPG" into TFilePath
put url("binfile:" & TFilePath) into image "Sig Block" of this card
end AddSignature
on blankOutSignature
put specialFolderPath("engine") & "/signatures/Blank.JPG" into TFilePath
put url("binfile:" & TFilePath) into image "Sig Block" of this card
end blankOutSignature
Re: Snapshot of card to email print or photo album
Posted: Mon Apr 29, 2013 8:59 pm
by Simon
Hi Dave,
One easier thing:
Code: Select all
on blankOutSignature
--put specialFolderPath("engine") & "/signatures/Blank.JPG" into TFilePath
--put url("binfile:" & TFilePath) into image "Sig Block" of this card
set the fileName of image "Sig Block" to empty
end blankOutSignature
So I would like to check to see which jpg image is the source of "Sig Block" so I can remind the user to sign the form if it is blank
You can use the opposite here:
Code: Select all
if the fileName of image "Sig Block" = empty then
answer "Please remember to sign the document below before mailing it."
etc.
But there is nothing "wrong" with the way you are doing it.
Simon