Page 1 of 2

mobilecomposemail pdf attachment

Posted: Wed Feb 17, 2021 11:42 am
by drunblut
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

Re: mobilecomposemail pdf attachment

Posted: Wed Feb 17, 2021 12:08 pm
by Klaus
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

Re: mobilecomposemail pdf attachment

Posted: Wed Feb 17, 2021 1:09 pm
by drunblut
Hallo Klaus,

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

Grets Andreas

Re: mobilecomposemail pdf attachment

Posted: Wed Feb 17, 2021 1:29 pm
by Klaus
Hi Andreas,

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


Best

Klaus

Re: mobilecomposemail pdf attachment

Posted: Thu Feb 18, 2021 9:59 am
by drunblut
Hi again,

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

Grets Andreas

Re: mobilecomposemail pdf attachment

Posted: Thu Feb 18, 2021 6:58 pm
by jacque
This sounds like it might be a LC issue. I'd submit a bug report at quality.livecode.com and see what they think.

Re: mobilecomposemail pdf attachment

Posted: Fri Feb 19, 2021 12:26 pm
by drunblut
Hi Jacque,

thanks a lot, i will follow the bug report.

Grets Andreas

Re: mobilecomposemail pdf attachment

Posted: Fri Feb 19, 2021 12:57 pm
by drunblut
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

Re: mobilecomposemail pdf attachment

Posted: Fri Feb 19, 2021 2:48 pm
by drunblut
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

Re: mobilecomposemail pdf attachment

Posted: Wed Feb 24, 2021 10:43 pm
by PaulDaMacMan
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.

Re: mobilecomposemail pdf attachment

Posted: Mon Oct 24, 2022 5:16 pm
by trevix
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

Re: mobilecomposemail pdf attachment

Posted: Mon Oct 24, 2022 6:41 pm
by jacque
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.

Re: mobilecomposemail pdf attachment

Posted: Tue Oct 25, 2022 8:36 am
by trevix
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

Re: mobilecomposemail pdf attachment

Posted: Tue Oct 25, 2022 5:43 pm
by jacque
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.

Re: mobilecomposemail pdf attachment

Posted: Tue Oct 25, 2022 5:57 pm
by trevix
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