error "Impossible de convertir \" 651.968017578125\" en type real." number -1700 from " 651.968017578125" to real

MacBook Pro with Retina display, iOS 12.1

Posted on Nov 27, 2018 7:25 AM

Reply
3 replies

Nov 27, 2018 10:12 AM in response to VikingOSX

What I really meant to provide:


Consider changing clear text 29 to (29 as number) in:


set pHeight to iFIELD / (29 as number)

else if iTAG contains "kMDItemPageWidth" then

set pWidth to iFIELD / (29 as number)


Use the following in the Python trimit function:


print(\"{:.2f} x {:.2f}\".format(r.size.width / 29L, r.size.height / 29L))


and your trimbox dimensions will be returned as ww.ww x hh.hh.


If you want to round your AppleScript variables to n places, add another function:


on roundit(n, decimals)

set x to 10 ^ decimals

set y to (((n * x) + 0.5) div 1) / x

return y as number

end roundit


and your process_PDF function now uses:

do shell script "echo " & fileName & space & nPages & space & my roundit(pWidth, 2) & " x " & my roundit(pHeight, 2) & space & my trimbox_(quoted form of POSIX path of f) & return & " >> $HOME/Desktop/List.txt"


And for a one-page, Letter PDF:


p51.pdf 1 21.10 x 27.31 21.10 x 27.31


Also, in your process_PDF function, the following will avoid considerable text string manipulation in If/else:


set t to paragraphs of (do shell script "mdls -name kMDItemFSName -name kMDItemNumberOfPages -name kMDItemPageHeight -name kMDItemPageWidth " & x & " | awk '{print $3}'")



set {fname, nPages, pHeight, pWidth} to t

logfname

"p51.pdf"

lognPages

1

logpHeight

792

logpWidth

612

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

error "Impossible de convertir \" 651.968017578125\" en type real." number -1700 from " 651.968017578125" to real

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.