Calling DLL within javascript

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

joeitaliano
User
Posts: 89
Joined: Wed Dec 29, 2010 8:50 am

Calling DLL within javascript

Post by joeitaliano »

Hello

I have a PDF file that was created with livecyle design. When an event occurs js code is executed that collects and concatenates the contents of all the form field separated with the tab character. The concatenated data then is converted to a barcode using PDF417.

The livecycle form is a xfa form but i have saved it as a static pdf form.

What i want to do is to created the barcode within the viewer or call an DLL fro the js that can create the barcode as a image file and then import to the PDF

I am not sure if js can call a DLL - does any one know

Is there any plans in v3 reader to have barcode support

many thanks

joe italiano
User avatar
John - Tracker Supp
Site Admin
Posts: 5223
Joined: Tue Jun 29, 2004 10:34 am

Re: Calling DLL within javascript

Post by John - Tracker Supp »

Hi Joe,

I'll leave the JS question to one of our JS/Viewer SDK specailists as - with regards bar codes we do already to some extent offer such support but V3 will extend this significantly - any chance you could provide a sample PDF (zipped) either here or direct to our support@ email address with a link back to this topic so we can be sure of supporting as you require ... ?

Thanks
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com
joeitaliano
User
Posts: 89
Joined: Wed Dec 29, 2010 8:50 am

Re: Calling DLL within javascript

Post by joeitaliano »

hi john

here is a zip file with a form. if you use acrobat pro you will see that as you enter text into the fields the barcode is updated. what i plan to di is to modify the code to collect the field data and then generate the barcode

thank joe
You do not have the required permissions to view the files attached to this post.
User avatar
Paul - PDF-XChange
Site Admin
Posts: 7362
Joined: Wed Mar 25, 2009 10:37 pm

Re: Calling DLL within javascript

Post by Paul - PDF-XChange »

Hi Joe,

thanks for the sample. When I open this in PDF-XChange Viewer, as you point out, the barcode does not change. When I enter values into the fields in Adobe Reader the barcode goes blank.

I'll be passing this on to the dev team to investigate. Given that they can look into the internals of the PDF document at a level I cannot, I'm confident they will be able to tell what is happening. For my own edification however I would be interested in knowing what kinds of values should, and do in Adobe Reader, produce a new bar code.

Can you send a second example with these fields filled out, working correctly in Adobe to produce a different bar code or is that part still incomplete? Is is good enough at present that entering data in the fields will blank the bar code in our Viewer as I'm seeing this example do in Adobe Reader?
Best regards

Paul O'Rorke
PDF-XChange Support
http://www.pdf-xchange.com
joeitaliano
User
Posts: 89
Joined: Wed Dec 29, 2010 8:50 am

Re: Calling DLL within javascript

Post by joeitaliano »

HI Paul

if you are using adobe free reader then it will not change the barcode because it needs the special reader extensions enabled which is enabled by livcecycle design when you pay adobe. if you use the acrobat pro which i purchased and it does do the barcode.

what i am trying to do is to somehow implement the barcode in your reader. i have been playing with a couple ofideas all of yesterday and i believe i have come across a solution.

if i modify the barcode event and concatenate the data pretty much the same way as they have already done then i can update the raw value of field that has been assigned as a barcode field. within your viewer i can detect when a field value has changed and if it is a barcode field i can call a dll within the viewer to produce the barcode

i was not sure if this would work or there is an easier way to do this - comments from your developers would be appreciated

one more inconsistency i have discovered. there is code in the pdf to convert all entered text to upper case. your viewer although it does execute the js for each field it does not convert to the text upper. not sure why. maybe you developers can check this out to correct when it is appropriate

thanks again

joe
User avatar
Paul - PDF-XChange
Site Admin
Posts: 7362
Joined: Wed Mar 25, 2009 10:37 pm

Re: Calling DLL within javascript

Post by Paul - PDF-XChange »

Hi Joe,

can you post the code you are using to convert the lower to upper case? Do you use toUpperCase(); or something else?
Best regards

Paul O'Rorke
PDF-XChange Support
http://www.pdf-xchange.com
joeitaliano
User
Posts: 89
Joined: Wed Dec 29, 2010 8:50 am

Re: Calling DLL within javascript

Post by joeitaliano »

hi paul

i have just got back from an overseas trip

the code in the form to convert the entered text to upper case is the function Upper()

in replacing it with the one you suggested does not work for either your viewer or adobe. the text is left as is

however i have played a bit more with this problem and i think the problem is that the exit function which there is one on each field so to force it to uppercase is not being executed

can your developer look at this please

many thanks

joe
User avatar
John - Tracker Supp
Site Admin
Posts: 5223
Joined: Tue Jun 29, 2004 10:34 am

Re: Calling DLL within javascript

Post by John - Tracker Supp »

Hi Joe,

before progresing this 'piece meal' and requesting developer assistance - can I ask that you please provide codes samples as requested so our dev team can check all items in one go to save both you and us unnecessary delays and repeated intervention - please ensure in any code posted that all license info is removed and if any files are attached they need to be 'zipped' or will not be posted.

thanks
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com
joeitaliano
User
Posts: 89
Joined: Wed Dec 29, 2010 8:50 am

Re: Calling DLL within javascript

Post by joeitaliano »

hi john

previously have sent one but its almost midnight so i will send tomorrow

many thanks again

joe
User avatar
John - Tracker Supp
Site Admin
Posts: 5223
Joined: Tue Jun 29, 2004 10:34 am

Re: Calling DLL within javascript

Post by John - Tracker Supp »

Hi Joe,

OK please have a good sleep and send the app as soon as convenient and we will take a look - please dont forget to remove any license info if attaching here zipped.

thanks
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com
joeitaliano
User
Posts: 89
Joined: Wed Dec 29, 2010 8:50 am

Re: Calling DLL within javascript

Post by joeitaliano »

Hi john

could i have an email address for me to send you the pdf file rather then putting it on this forum

thanks

joe
joeitaliano
User
Posts: 89
Joined: Wed Dec 29, 2010 8:50 am

Re: Calling DLL within javascript

Post by joeitaliano »

hi john

i have just noticed that i have already place on this forum the zip version of the pdf so no point me asking you for an email address to send it

run the pdf using adobe and viewer and compare the following. ignore for now the barcode not being generated

if you go to any of the fields say on the first page and enter text in lowercase when you see that when you step out of the field that the text is converted and replaced with the uppercase

there is code in the exit function for every fields as follows

$.rawValue = Upper($.rawValue);

from what i can see your viewer is not executing the exit function of these fields.

so i think there is possibly an issue here that needs investigating so that adobe and viewer work the same way

many thanks

joe italiano
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3586
Joined: Thu Jul 08, 2004 10:36 pm

Re: Calling DLL within javascript

Post by Ivan - Tracker Software »

Script $.rawValue = Upper($.rawValue) is not executed because this form uses FormCalc as script language, not JS. We have FormCalc implemented but this feature will be available in V3.
PDF-XChange Co Ltd. (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
joeitaliano
User
Posts: 89
Joined: Wed Dec 29, 2010 8:50 am

Re: Calling DLL within javascript

Post by joeitaliano »

hi john/ivan/team

thanks for getting back to me

for now i can add some code in the viewer to trap each time we exit a field and convert to upper

one other thing i have picked up. if you look at that same pdf there is js code at the start of each page where the barcode is generated eg:

RegistrationForms.TOLPage1.PaperFormsBarcode1::calculate - (JavaScript, client) - page 1

RegistrationForms.TOLPage1.PaperFormsBarcode2::calculate - (JavaScript, client) - page 2

i have put a app.alert("page1") on page 1 and app.alert("page2") on page 2 etc. what i have noticed is that when using adobe changing the field on page1 it alerts with the page1 message and on page 2 the page2 message.

however with the viewer whatever field i have changed on whatever page i am on it always reports the page1 message

just letting you know. seems to me the v3 is my easy option

do you have a time table for v3 release

i am keen to be a tester for V3 if you are looking for any

will v3 offer barcoding support as per abobe?

many thanks

joe
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3586
Joined: Thu Jul 08, 2004 10:36 pm

Re: Calling DLL within javascript

Post by Ivan - Tracker Software »

Thanks for the info. I will check what is wrong with handing these scripts.

P.S. about barcodes - even current version of the viewer supports wide range of different barcodes (see attached file). problems are only with scipts.
You do not have the required permissions to view the files attached to this post.
PDF-XChange Co Ltd. (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
joeitaliano
User
Posts: 89
Joined: Wed Dec 29, 2010 8:50 am

Re: Calling DLL within javascript

Post by joeitaliano »

ivan

pdf417 is what i am wanting to generate

can the viewer generate the barcode or do i need to write some code in the viewer to call a dll to create the barcode

many thanks
joe
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3586
Joined: Thu Jul 08, 2004 10:36 pm

Re: Calling DLL within javascript

Post by Ivan - Tracker Software »

The viewer generates barcode. you just have to provide data. For PDF417 often scripts are used to compose data for barcode based on form fields values.
PDF-XChange Co Ltd. (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
joeitaliano
User
Posts: 89
Joined: Wed Dec 29, 2010 8:50 am

Re: Calling DLL within javascript

Post by joeitaliano »

ivan do you have any samples on how this is done
joeitaliano
User
Posts: 89
Joined: Wed Dec 29, 2010 8:50 am

Re: Calling DLL within javascript

Post by joeitaliano »

hi ivan

in the pdf file i sent you there is this code which is called after we loose the focus on every field.

i have put some app.alert to figure out why it deos not work and have tracked it down the line to this line

var nodes = collection.evaluate();

the rest of the function i have included at the end of the body

not being a js expert it would seem the number of fields/nodes in this page is not returning the correct amount. it returns 0 instead of 47

many thanks as always

joe

RegistrationForms.TOLPage1.PaperFormsBarcode1::calculate - (JavaScript, client)
//{{Start Generated Content//
/*{{<name>delimCollection</name>}}*/
var includeFieldNames = false;
var includeLabel = true;
var labelID = "Label";
var is705ViewerRequired = false;
var collection = Page1;
var delimiter = '\t';
//End Generated Content}}//

// Initialize the barcode content
this.rawValue = " ";

// Encoding data into the barcode
var fieldNames = new Array();
var fieldValues = new Array();

function encode(node)
{
app.alert("encode");
var barcodeLabel = this.caption.value.text.value;
app.alert(barcodeLabel);
if (includeLabel == true && barcodeLabel.length > 0)
{
fieldNames.push(labelID);
fieldValues.push(barcodeLabel);
}

if(collection != null)
{
// Create an array of all child nodes in the form
var entireFormNodes = new Array();
if(includeFieldNames == true)
collectChildNodes(xfa.datasets.data, entireFormNodes);

// Create an array of all nodes in the collection
var collectionNodes = new Array();
var nodes = collection.evaluate();
app.alert(nodes.length);
for(var i = 0; i < nodes.length; ++i)
{
collectChildNodes(nodes.item(i), collectionNodes);
}

// If the form has two or more fields sharing the same name, the names of the
// parents of these fields, as well as the subscript numbers of the fields and
// their parents, will be used to differentiate them. However, since we want
// to take as little space in the barcode as possible, we only use such extra
// data in the object names only when necessary.
if(includeFieldNames == true)
resolveDuplicates(collectionNodes, entireFormNodes, fieldNames);

for(var j = 0; j < nodes.length; ++j)
{
// Go through the collection and accumulate the value of each form object
accumulateFieldValues(nodes.item(j));
}

// Forcing dependency (only if the viewer version is 8.00 or older)
if(xfa.host.version <= 8.00)
{
app.alert("8");
// Create a collection of the selected form objects, but in the form model context
var formModelNodeList = new Array();

var dataNodes = collection.evaluate();
for(var i = 0; i < dataNodes.length; ++i)
{
formModelNodeList.push(xfa.form.formNodes(dataNodes.item(i)));
}

// Now, force a dependency between the barcode and its form model nodes in its
// collection
while(formModelNodeList.length > 0)
{
var nodeList = formModelNodeList.pop();
for(var i = 0; i < nodeList.length; ++i)
{
depends(nodeList.item(i));
}
}
}
}
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3586
Joined: Thu Jul 08, 2004 10:36 pm

Re: Calling DLL within javascript

Post by Ivan - Tracker Software »

Sorry for the long delay with an answer.

The Viewer experiences a few problems with your XFA form when trying to calculate the barcode value.

The first problem is with the Page 1 and Page 2, ... variables - they contain SOM expressions used to resolve the nodes used in calculations, but these expressions use undocumented 'dataNode' properties of the Form DOM nodes - not entirely 'unique' in regards Adobe's willingness to use such undocumentented functionality - but causes any 3rd party party developer such as ourslves huge problems as we have to 'reverse engineer' support for such features without knowing the required syntax and construction !

The Second problem is handling the calculation event - it is not obvious when the calculation object in the barcode fields should be activated, as it is not on the same level as other fields used for calculations as would usually be expected.

However, we have made some workaround's in the viewer and now your form is calculated as expected.

This fix will be available in the next build of the viewer 2.0196 - available in 10-14 days.

Once again - your patience is appreciated for the delay !
PDF-XChange Co Ltd. (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
joeitaliano
User
Posts: 89
Joined: Wed Dec 29, 2010 8:50 am

Re: Calling DLL within javascript

Post by joeitaliano »

hi ivan

not a problem that it has take you all this time and always appreciated

can you tell me if the 196 build fixes both the barcode and the node problem or just one of them

does it fix the formcalc otherwise i can change this code code to use js functions instead. my other alternative is to wait for V3 which i understand does include support for formcalc

thanks again

joe
User avatar
John - Tracker Supp
Site Admin
Posts: 5223
Joined: Tue Jun 29, 2004 10:34 am

Re: Calling DLL within javascript

Post by John - Tracker Supp »

Hi Joe,

this resolves both items :)
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com
joeitaliano
User
Posts: 89
Joined: Wed Dec 29, 2010 8:50 am

Re: Calling DLL within javascript

Post by joeitaliano »

hi john

just checking if 196 has been released

all the best and thanks

joe
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19885
Joined: Mon Jan 12, 2009 8:07 am

Re: Calling DLL within javascript

Post by Stefan - PDF-XChange »

Hello Joe,

I think I saw Paul in another post say 10-14 days, so if it is not by the end of next week it will probably be shortly after that.

Best,
Stefan
joeitaliano
User
Posts: 89
Joined: Wed Dec 29, 2010 8:50 am

Re: Calling DLL within javascript

Post by joeitaliano »

hi steffan

in my rush i missed calculated the dates - silly of me

sorry about that

thanks again

joe
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19885
Joined: Mon Jan 12, 2009 8:07 am

Re: Calling DLL within javascript

Post by Stefan - PDF-XChange »

You are welcome Joe!

Cheers,
Stefan
joeitaliano
User
Posts: 89
Joined: Wed Dec 29, 2010 8:50 am

Re: Calling DLL within javascript

Post by joeitaliano »

hi stefan

any news on the release

thanks joe
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19885
Joined: Mon Jan 12, 2009 8:07 am

Re: Calling DLL within javascript

Post by Stefan - PDF-XChange »

Hello Joe,

I am afraid that there is still no specific release date announced.

Best,
Stefan
joeitaliano
User
Posts: 89
Joined: Wed Dec 29, 2010 8:50 am

Re: Calling DLL within javascript

Post by joeitaliano »

many thanks
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19885
Joined: Mon Jan 12, 2009 8:07 am

Re: Calling DLL within javascript

Post by Stefan - PDF-XChange »

Thanks for the understanding Joe,

Best,
Stefan