IF you still want to know the specifics of what works in Chrome's PDF viewer you'd need to ask Google. If they tell you, please share!
That's very interesting, but isn't it the PDF Viewer in FireFox, rather than Chrome? It mentions an extension for Chrome PDF Viewer - Chrome Web Store, but I'd expect that to be different from Google's built in viewer (since that requires no extension to be separately installed). cf Comparison Between Firefox PDF Viewer (PDF.js) and Chrome PDF Viewer | Techdows
That is possible, I probably got my "causing me and my customers nothing but headaches" PDF viewers in browsers mixed up
pdf.js is the PDF viewer of Firefox.
Basically, what I'm trying to do is: the user have to type the date and the number of days he wants to add to this date, and then the form will return the final date in a specific format (dd/mm/yyyy) in the field "dateConverted.
number of days: 30
This is what I did:
var numberOfDays = this.getField("numberOfDays").value;
var startDate = this.getField("startDate").value;
var numberOfDaysMS = 24 * 60 * 60 * 1000 * numberOfDays;
var startDateMS = util.scand("dd/mm/yyyy",startDate).getTime();
var milliseconds = numberOfDaysMS + startDateMS;
var date = util.printd("dd/mm/yyyy", new Date(milliseconds));
this.getField("dateConverted").value = date;
var numberOfDays = this.getField("numberOfDays").value; var startDate = this.getField("startDate").value; var newDate = util.scand("dd/mm/yyyy", startDate); newDate.setDate(newDate.getDate() + numberOfDays); this.getField("dateConverted").value = util.printd("mm/dd/yyyy", newDate);
However, I doubt that this will work in Chrome either.
I think the problem is with the util.scand method. I seem to recall it sets the time differently than Acrobat/Reader does, but I'd have to go back and check my notes. But you can revise the code so that it's not needed, you just lose the convenience it provides. The code Karl provided might work, but since util.scand behaves differently, you'll want to do some testing.
I did just a bit of testing and it looks like the getTime method isn't implemented, but there are alternatives for what you're doing as Karl pointed out.
Thanks, George and Karl!
I tried to do the way Karl pointed out but the result is just the same. The "dateConverted" field keeps returning the current date in Chrome's pdf viewer but It works perfectly in Adobes Acrobat Pro DC. Maybe I should try other ways to make the form more user friendly...
Thank you, anyway!
I just tested with the latest version of Chrome, and now it looks like there's a problem with util.printd, where there wasn't before. I'll post again if I find anything useful.