Forum How do I...?

getting errors when I try to add timestamp

tomjohnson1492
I'm trying to add a timestamp to the header of my PDF, but I'm getting errors that say

error: TypeError: null value is not an object


Here are the steps I took:

1. I added this script in one of my html pages:

<script>
Prince.addScriptFunc("datestamp", function() {
    return (new Date()).toString();
});
</script>


2. I added this to my CSS:

@page {
    @top {
	content: prince-script(datestamp)
    }
}


Is there anything else I should do? `
mikeday
It works for me with the attached document (edit: the document pasted below):
<!DOCTYPE>
<html>
<head>
<script>
Prince.addScriptFunc("datestamp", function() {
    return (new Date()).toString();
});
</script>
<style>
@page {
    @top {
	content: prince-script(datestamp)
    }
}
</style>
</head>
<body>
<p>timestamp should appear in header</p>
</body>
</html>

Perhaps you have some other scripts being applied?

Edited by mikeday

tomjohnson1492
where do I see the attachment?
mikeday
Sorry, I just pasted it literally instead of attaching it. :)
tomjohnson1492
sorry, but I still don't see the attachment . am i looking in the wrong place?
mikeday
Here:
  1. doc.html0.3 kB
tomjohnson1492
Thanks. I was downloaded the file and ran this:

prince --javascript princedoc.html -o result.pdf


It worked well. But then I added a CDN script reference to jQuery:

<!DOCTYPE>
<html>
<head>
 <script src="//code.jquery.com/jquery-1.11.2.min.js"></script> 
<script>
Prince.addScriptFunc("datestamp", function() {
    return (new Date()).toString();
});
</script>
<style>
@page {
    @top {
	content: prince-script(datestamp)
    }
}
</style>
</head>
<body>
<p>timestamp should appear in header</p>
</body>
</html>


And got this error:

prince: //code.jquery.com/jquery-1.11.2.min.js: error: can't open input file: No such file or directory


I downloaded jQuery locally and didn't get the error.

Is there a restriction on CSS stylesheet locations? Can I not use remotely located stylesheets?

Tom

Edited by tomjohnson1492

mikeday
You will need to specify "http://..." in the URL. If the URL just begins with "//" and your file is a local file, then it will be trying to load jQuery as a local file also.
tomjohnson1492
Thanks. I fixed that, but now I'm getting a different error:

prince: https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js:2: error: TypeError: null value is not an object
undefined
tomjohnson1492
I stripped out all the javascript references from my site. i still get this error:
TypeError: value is not an object
mikeday
Strange, it has to be coming from somewhere. Perhaps you could email me (mikeday@yeslogic.com) a document that triggers the problem?
tomjohnson1492
It turns out I had an auto-toc generator that was still included. When I stripped away this javascript, I didn't run into any more errors and the timestamp printed properly. Thanks!