Get integer from metadata variable

Post Reply
matb
Newbie
Posts: 8
Joined: Thu Jul 15, 2010 11:53 am

Get integer from metadata variable

Post by matb »

I have this line taken from PDFspy metadata;



[Metadata.Text:Path="/pdfattrs/page[1]/boxes/TrimBox/@height * 0.352777778",Dataset="Pdf",Model="XML"] mm x [Metadata.Text:Path="/pdfattrs/page[1]/boxes/TrimBox/@width * 0.352777778",Dataset="Pdf",Model="XML"] mm



And the result is (eg);



356.001179113142 mm x 599.999929266842 mm



Is it possible to get just the integer (not the decimal points)?
mattbeals
Member
Posts: 59
Joined: Fri Oct 29, 2010 2:49 am
Location: Edmonds, WA
Contact:

Get integer from metadata variable

Post by mattbeals »

No, I don't think so. Have you tried emailing Apago support?
I'm just a dude. Anything I say has nothing to do with any other person or company.
dkelly
TOP CONTRIBUTOR
Posts: 658
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

Get integer from metadata variable

Post by dkelly »

Hello, you should be able to use XPath's math operators for rounding floating point numbers to integers.



floor(v)- maps to largest previous integer

ceiling(v) - maps to smallest following integer

round(v) - rounds to closest integer



floor(2.1) = 2

floor(2.5) = 2

ceiling(2.1) = 3

ceiling(2.6) = 3

round(2.1) = 2

round(2.6) = 3



--

Dwight Kelly

Apago, Inc.

dkelly@apago.com
manupapet
Newbie
Posts: 15
Joined: Sun Mar 04, 2012 11:08 am

Get integer from metadata variable

Post by manupapet »

Hello, i have make the same thing of you without PDFSpy but with the function stats :



function convert() {

var TBWpt = job.getVariableAsNumber( "[Stats.TrimBoxWidth]" );

var TBHpt = job.getVariableAsNumber( "[Stats.TrimBoxHeight]" );

var TBWmm = Math.round( TBWpt * 0.35277 ).toString();

var TBHmm = Math.round( TBHpt * 0.35277 ).toString();

return TBWmm + "x" + TBHmm + "mm-" + PWmm + "x" + PHmm + "mm"

}

convert();



I'm French and I'm sorry for my english.



--------------

Emmanuel MARTIN

Printer

manupapet@yahoo.fr
dkelly
TOP CONTRIBUTOR
Posts: 658
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

Get integer from metadata variable

Post by dkelly »

That will work; however, Switch variables only give the page boxes for a single page whereas PDFspy gives the page boxes for every page.
Post Reply