error "Impossible de convertir \" 651.968017578125\" en type real." number -1700 from " 651.968017578125" to real
MacBook Pro with Retina display, iOS 12.1
MacBook Pro with Retina display, iOS 12.1
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
Thank you ! It works !
Use this:
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.
error "Impossible de convertir \" 651.968017578125\" en type real." number -1700 from " 651.968017578125" to real