mobilecomposemail pdf attachment

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

drunblut
Posts: 19
Joined: Mon Jun 15, 2020 10:29 pm

mobilecomposemail pdf attachment

Post by drunblut » Wed Feb 17, 2021 11:42 am

Hi,

i printed the content of a card into pdf-file in specialfolderpath("documents"), no problems.

Code: Select all

global dbid, sql, tergebnis, tdatei

on mouseUp pMouseButton
   local tAttachment
   open stack "printpdf" of stack "Logbuch"
   
   put specialFolderPath....
   
   open printing to pdf tPDFPath
   set printpaperorientation to "landscape"
   
   if the result is "Cancel" then
      ## The user has cancelled printing
      exit mouseUp
   else
      ## Print the card into the printable area
      print card "cardprintpdf" of stack "printpdf" of stack "Logbuch" into 10,50,812,547
   end if
   go to card "cardprintpdf" of stack "printpdf" of stack "Logbuch"
   close printing
   close stack "printpdf" of stack "Logbuch"
end mouseUp
Then i wanted to send the file by mail.

Code: Select all

if the environment is "mobile" then
      put "mypdffile" into tAttachment["name"]
      put "xxx" into tsubject
      put "mymailaddress" into temail
      put "yyy" into tbody
      put specialFolderPath("documents") & "/" & mypdffile into tAttachment["file"]
      put "application/pdf" into tAttachment["type"]--
      mobileComposeMail tsubject, temail, , , tBody, tAttachment
   end if
The mail is sent correctly but the attached pdf file is stretched. It seems that the visible (on android mobile) part of the file is stretched to 10,50,812,547.

Has anyone got an idea how to manage this? I already tried snapshot but got also only the visible part in the png-file.

Grets Andreas

Klaus
Posts: 13793
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: mobilecomposemail pdf attachment

Post by Klaus » Wed Feb 17, 2021 12:08 pm

HI Andreas,

welcome to the forum!
This is the ANNOUNCEMENT forum, so I will move thit thread to the "Talking Livecode" forum. 8)


Best

Klaus

drunblut
Posts: 19
Joined: Mon Jun 15, 2020 10:29 pm

Re: mobilecomposemail pdf attachment

Post by drunblut » Wed Feb 17, 2021 1:09 pm

Hallo Klaus,

sorry, didn`t get that. Thanks for moving my post. Have you got any ideas?

Grets Andreas

Klaus
Posts: 13793
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: mobilecomposemail pdf attachment

Post by Klaus » Wed Feb 17, 2021 1:29 pm

Hi Andreas,

no, I don't develop for mobile, don't even own a cellphone. :-)


Best

Klaus

drunblut
Posts: 19
Joined: Mon Jun 15, 2020 10:29 pm

Re: mobilecomposemail pdf attachment

Post by drunblut » Thu Feb 18, 2021 9:59 am

Hi again,

is there nobody with an idea for solving my problem? Thanks in advance for any hint!

Grets Andreas

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7210
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: mobilecomposemail pdf attachment

Post by jacque » Thu Feb 18, 2021 6:58 pm

This sounds like it might be a LC issue. I'd submit a bug report at quality.livecode.com and see what they think.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

drunblut
Posts: 19
Joined: Mon Jun 15, 2020 10:29 pm

Re: mobilecomposemail pdf attachment

Post by drunblut » Fri Feb 19, 2021 12:26 pm

Hi Jacque,

thanks a lot, i will follow the bug report.

Grets Andreas

drunblut
Posts: 19
Joined: Mon Jun 15, 2020 10:29 pm

Re: mobilecomposemail pdf attachment

Post by drunblut » Fri Feb 19, 2021 12:57 pm

Hi Jacque,

for better understanding i attach the file "pdffile" which is created in lc correctly and file "mailedpdffile".

Thanks for your help.

Grets Andreas
Attachments
pdffile.gif
mailedpdffile.gif

drunblut
Posts: 19
Joined: Mon Jun 15, 2020 10:29 pm

Re: mobilecomposemail pdf attachment

Post by drunblut » Fri Feb 19, 2021 2:48 pm

Hi Jacque,

another hint. I tried it with snapshot. The mailed jgp file shows only the visible part of the card (on android screen).

Grets Andreas
Attachments
Toerndaten.jpg

PaulDaMacMan
Posts: 616
Joined: Wed Apr 24, 2013 4:53 pm
Contact:

Re: mobilecomposemail pdf attachment

Post by PaulDaMacMan » Wed Feb 24, 2021 10:43 pm

Stretching a rect to fill another rect of a different size is the behavior I would expect. Is your card size the same as the area of the rect you're printing into? Maybe you can lock screen and make it that size temporarily if needed?

Have you checked out the other printing keywords in the LC dictionary?
These look like they might help:
get the printRectangle
get the printPaperRectangle
set the printMargins to left, top, right, bottom
set the printPaperScale to number
set the printPaperSize to width, height
get/set the printScale to ratio
get/set the formatForPrinting of stack to {true | false}
get/set the printPaperOrientation to {"portrait" | "landscape" | "reverse portrait" | "reverse landscape"}
get/set the printGutters to columnSpace, rowSpace
get the printerSettings
set the printerSettings to string

I don't do any printing from Android so I don't really have definite answers here, just suggestions.
My GitHub Repos: https://github.com/PaulMcClernan/
Related YouTube Videos: PlayList

trevix
Posts: 950
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: mobilecomposemail pdf attachment

Post by trevix » Mon Oct 24, 2022 5:16 pm

Hello.
This conversation never really ended, since drumblut did not say if he found a solution...

I have the same problem on Android.
Here is my code and the image resulting (that is clearly distorted, with half of it missing and that should be a A4 pdf).
The size of the Pdf stack is 594,840
Any suggestion?

Code: Select all

 go card tCardname of stack "r_PDFStack"
set the printPaperOrientation to "portrait"
set the printPaperScale to 1
set the printPaperSize to "594,840"
set the printScale to 1
open printing to pdf tPath
if the result is "Cancel" then
   ## The user has cancelled printing
       exit to top
   else
   ## Print the card into the printable area
       print card tCardname of stack "r_PDFStack" into 0,0,594,840 --the size of the card = A$ vertical
end if
close printing
close stack "r_PDFStack"
Schermata 2022-10-24 alle 18.11.04.png
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7210
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: mobilecomposemail pdf attachment

Post by jacque » Mon Oct 24, 2022 6:41 pm

I haven't printed from Android either, but have done it on desktop apps. LC supplies default margins if you don't specify any and it looks like that's happening. Also, since your stack is the same size as the paper, you don't need to print into a rectangle, which is generally only used for scaling.

I'd try setting the printmargins to 0 or maybe just a bit more. Set up the printing card so controls are away from the card edges, since LC will print the entire card including empty space. The position of the controls will supply visual margins. Also, most printers won't print less than half an inch from the top of the paper, so place the top controls close to the top of the stack if you want a half inch top margin, or half an inch down for a 1 inch top margin.

Remove the code that prints into a rectangle and just use "print this card". If none of the above works, take another screenshot and let us know.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

trevix
Posts: 950
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: mobilecomposemail pdf attachment

Post by trevix » Tue Oct 25, 2022 8:36 am

Somehow writing the margins removed the streching of the page (I guess on Android the default is not 72,72,72,72). Thanks
But some part of the page is still missing, as you can see in the 2 attachments.

The correct one is from OSX and iOS, with the code below.
The second one is from Android 10 hardware, with the same code.
Schermata 2022-10-25 alle 09.30.14.png
Schermata 2022-10-25 alle 09.30.49.png

Code: Select all

go card tCardname of stack "r_PDFStack"
set the printPaperOrientation to "portrait"
set the printPaperScale to 1
set the printPaperSize to "594,840"
set the printScale to 1
set the printMargins to 15,15,15,15
open printing to pdf tPath
if the result is "Cancel" then
   ## The user has cancelled printing
         exit to top
   else
         ## Print the card into the printable area
        print card tCardname of stack "r_PDFStack" --into 0,0,594,840 --the size of the card = A$ vertical
end if
close printing
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7210
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: mobilecomposemail pdf attachment

Post by jacque » Tue Oct 25, 2022 5:43 pm

I'm out of my depth now since I've never printed from Android, but it does look like only the visible part of the card is printed. Does the height of the printed portion seem to match the width of your Android device?

Experimental: On Android you may have to rotate the print layout 90° and/or set the printOrientation to landscape. And maybe go back to printing into a rectangle matching landscape dimensions.

I'm just guessing. Printing is a long series of trial and error. I charge more for stacks that require printing. It's a long process.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

trevix
Posts: 950
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: mobilecomposemail pdf attachment

Post by trevix » Tue Oct 25, 2022 5:57 pm

Oh my...never thought that orientation could be to blame (bizarre...)
The Pdf stack is vertical, reflecting the size of an A4, while the rest of the stacks are landscape.
I tried to print to pdf keeping the phone vertically, to no avail.
Clearly there is an inconsistency between iOS (which print fines) and Android.
Will try to handle your suggestionswith scripts and see what happens

Thanks for your help
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

Post Reply

Return to “Talking LiveCode”