I'm using iTextSharp in C# to read the pdf and fill values for text fields in it and based on one text field value, I'm trying to run javascript action to fill two other fields before saving the document.
I can see the script store in the pdf but it is not executing. Is there a better way to run the scripts in iTextSharp or in adobe?
As far as I know, iText does not have an Acrobat JavaScript engine.
In order to run (Acrobat) JavaScript in your form, you will have to open it in Acrobat/Reader, and provide a trigger to execute the scripts. Depending on which event the scripts are attached, you would either just have to run them (for example in the pageOpen event of the page on which the document opens), or using this.calculateNow() (again) in the pageOpen event of the page on which the document opens. If you have a multi-page document, you may also add a mechanism which runs those scripts only once (how to do that has been explained many times in many places (here on stackoverflow, but also in the Adobe forums, the AcrobatUsers forums (rest in peace), PlanetPDF etc.).
Related
I'm just not sure how to approach this. I have a blank select tag in my HTML with JS handling click events. I then have a addon built that builds some objects from other sources each containing an unique identifying string.
How would I go about filling in the select tag from the data in the addon?
I can't find a way to fill it in the C++ addon, but I also can't think of a clean way to have the Javascript call a single function to fill it in completely.
I am trying to copy paste some stuff from some website which I want to automate. Here is my manual workflow:
There is a master webpage which contains set of links.
When I click on one of those links it opens another (say topic page) page with set of tabs.
I click on one specific of those tabs which loads a page containing several buttons with same html-css applied to them.
On click events of those botton calls a javascript function passing four integer parameters.
The function results in generating a separate popup window with some small content which I then print as pdf.
The issue is that the website blocks right click and text selection. And the popup window contains a image which I print as pdf by right clicking on titlebar and selecting print as pdf. When I checked the source of popup, I found that it uses
"data:image/png;base64,<source for image>"
as value for src of <image>.
Now the big question can I write some script which can run when either master page or topic page to automatically click on buttons on them and get those images saved either directly as png or pdfs? I am good at programming languages java, groovy, python, C#... Also explored javascript a lot. But that's many years ago and really lost in touch with JS. Can I do this with say greasemonkey or any other way. Any pointers (possibly detailed) will be helpful...Or even some small pseudocode which I can paste in console of topic page which will do all clicking of buttons and saving image from the popup, so that I don't have to do button-clicking-&-saving-image manually. This will also serve a lot since there are more buttons per topic page instead of number of topic pages themselves.
Update
Well I know this question is not at all specific, so here is my initial hurdles, since I have started to try it out:
given that I am programmatically call all those function on onclick events, how can I get hold of popups in source? That is, how can I reference the popup that is opened by function call in js?
I have an application that runs to print documents. there is a tree view and grid control in the page. The treeview is enabled with the check box. there is another checkbox in the grid. based on the selection i create pdf using itextsharp and want print , download email etc.
i did it but when it down loads , I need the controls to be cleared. this is not happening even i wrote the code to clear. i think the issue may be with the usage of memory stream. So what i am doing is create pdf and saved to a location. So how can I do it with javascript (the download function). My ultimate aim is to clear the controls.
Regards,
Sivajith S.
I cannot manage to make asmall piece of javascript working in a lotus notes 6.5 email.
I'm building a html, send it by mail as a html, and inside I would like to have some links to hide/show a few div.
I try to use document.getElementById but when I click on the link I have the following error:
"document.getElementById is not a function".
I'm thinking using a document.getElementById(id).style.display='none'; to hide it (if I can manage the div).
Any ideas how to show/hide my div?
The HTML engine in Lotus Notes is not anything like you'd get in a browser. I'm fairly certain the error message is correct when it says "document.getElementById is not a function" - there is little to no support for javascript in Notes emails.
If you need to have something hide/show in Notes, you will have to create a Notes form with actions and hide formulas to get the same effect. Then emails can be sent with the form embedded into the email, and when received the email will open that form instead of a typical memo form.
Note, it is unlikely most email clients (Outlook, etc) will support javascript due to the security holes it would open. You might have better luck sending a link to users and then having them open up a Web page or Notes database where you have more control over how things are presented to them.
The root of the problem is that Notes doesn't display HTML*. In order to display an HTML-formatted MIME email (or any other rich text field whose contents are stored as MIME and HTML), the content must first be converted to Notes Rich Text (composite data, or CD) format. The conversion of static HTML has improved a lot over the years, but once the conversion is completed, there is no HTML document to modify. Obviously, your link/action was properly translated to its Notes equivalent, but there are no hooks for DOM methods in the Notes client. JavaScript is pretty much restricted to manipulating field values (through the document.forms[0].LiteralFieldName method of access), swapping images (through the document.images collection) and a small subset of the window object's methods.
*One can view pure web pages in the Notes client, but that uses the IE ActiveX control in the full tab -- it's not available natively for rendering a part of a document.
it may not fit your HTML needs but might help you hide / show content:
In a new mail, select the content you want to hide / show
Click on Create / Section
You can also define a name for this section within section's properties
(works in Lotus Notes 8.5)
In Google Reader, you can use a bookmarklet to "note" a page you're visiting. When you press the bookmarklet, a little Google form is displayed on top of the current page. In the form you can enter a description, etc. When you press Submit, the form submits itself without leaving the page, and then the form disappears. All in all, a very smooth experience.
I obviously tried to take a look at how it's done, but the most interesting parts are minified and unreadable. So...
Any ideas on how to implement something like this (on the browser side)? What issues are there? Existing blog posts describing this?
Aupajo has it right. I will, however, point you towards a bookmarklet framework I worked up for our site (www.iminta.com).
The bookmarklet itself reads as follows:
javascript:void((function(){
var e=document.createElement('script');
e.setAttribute('type','text/javascript');
e.setAttribute('src','http://www.iminta.com/javascripts/new_bookmarklet.js?noCache='+new%20Date().getTime());
document.body.appendChild(e)
})())
This just injects a new script into the document that includes this file:
http://www.iminta.com/javascripts/new_bookmarklet.js
It's important to note that the bookmarklet creates an iframe, positions it, and adds events to the document to allow the user to do things like hit escape (to close the window) or to scroll (so it stays visible). It also hides elements that don't play well with z-positioning (flash, for example). Finally, it facilitates communicating across to the javascript that is running within the iframe. In this way, you can have a close button in the iframe that tells the parent document to remove the iframe. This kind of cross-domain stuff is a bit hacky, but it's the only way (I've seen) to do it.
Not for the feint of heart; if you're not good at JavaScript, prepare to struggle.
At it's very basic level it will be using createElement to create the elements to insert into the page and appendChild or insertBefore to insert them into the page.
You can use a simple bookmarklet to add a <script> tag which loads an external JavaScript file that can push the necessary elements to the DOM and present a modal window to the user. The form is submitted via an AJAX request, it's processed server-side, and returns with success or a list of errors the user needs to correct.
So the bookmarklet would look like:
javascript:code-to-add-script-tag-and-init-the-script;
The external script would include:
The ability to add an element to the DOM
The ability to update innerHTML of that element to be the markup you want to display for the user
Handling for the AJAX form processing
The window effect can be achieved with CSS positioning.
As for one complete resource for this specific task, you'd be pretty lucky to find anything. But have a look at the smaller, individual parts and you'll find plenty of resources. Have a look around for information on modal windows, adding elements to the DOM, and AJAX processing.