Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / September 2007

Tip: Looking for answers? Try searching our database.

Embedded Resource Files

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
online.identity.9@gmail.com - 25 Sep 2007 20:18 GMT
How can I access a Resource File via javascript in InfoPath 2003?    I
have a form in which I've attached a couple of additional documents,
these documents are of various types (Powerpoint, Word, etc).  I'd
like to be able to extract these documents from the form in javascript
and write them to the users temp directory, but I can't seem to find a
way of accessing the embedded files.  Any ideas?
S.Y.M. Wong-A-Ton - 26 Sep 2007 08:40 GMT
If you can manage to find code on the web with which you can convert a base64
encoded string to binary data, then you'll have a solution. Otherwise, the
only thing I can recommend is switching to .NET (see
http://support.microsoft.com/kb/892730).
---
S.Y.M. Wong-A-Ton

> How can I access a Resource File via javascript in InfoPath 2003?    I
> have a form in which I've attached a couple of additional documents,
> these documents are of various types (Powerpoint, Word, etc).  I'd
> like to be able to extract these documents from the form in javascript
> and write them to the users temp directory, but I can't seem to find a
> way of accessing the embedded files.  Any ideas?
online.identity.9@gmail.com - 26 Sep 2007 14:43 GMT
I have routines to encode and decode Base64 in javascript (though
javascript is SLOW, it takes 30 seconds to decode a 100K file).  My
issue is getting at Resource Files, not files imported by the user.
S.Y.M. Wong-A-Ton - 27 Sep 2007 01:37 GMT
Sorry, I misunderstood your question. Could you please post the javascript
code to encode/decode? Other people in the group might benefit from it...

Now onto your issue: Resource files are used in InfoPath to be able to
internally link to an HTML or XML file that you would typically use in a
custom task pane or through a data source. As far as I know, there are no API
methods to retrieve those resource files. But here's an idea you can try out:
Create an InfoPath form template that has an attachment control on it. Then
fill out forms and attach the documents you want to embed. Note: You could
use a repeating table containing an attachment control to embed all of the
documents in one form. Once you've done this, add the filled out form as a
resource file to your other InfoPath form template that uses resource files
and then create an XML document receive data connection that uses the
resource file you added. Then in code, you can use something like
XDocument.DataObjects["<your_datasource_name>"].DOM.selectSingleNode("//my:attachmentfield").text
to get the base64 encoded string of the attached document. Then you can use
your javascript code on this to convert it to a binary file and save it
locally.

I have not tried out what I've outlined above, so if you get stuck, let me
know. It's a cool scenario, BTW.
---
S.Y.M. Wong-A-Ton

> I have routines to encode and decode Base64 in javascript (though
> javascript is SLOW, it takes 30 seconds to decode a 100K file).  My
> issue is getting at Resource Files, not files imported by the user.
online.identity.9@gmail.com - 27 Sep 2007 15:06 GMT
I thought about that, it's just a little too convoluted for my tastes,
although I've done much much worse things to Infopath.  I think I'm
just going to have to post the documents in a publicly accessible
place and pull them down when needed.

Regarding the base64 stuff.  Here's a link to some javascript that
does encoding and decoding, http://www.webtoolkit.info/javascript-base64.html

A few things to worry about though, files embedded via the File
Attachment control contain more then just the file itself, they're
some metadata encoded in there also.  The File Attachment consists of
a bunch of \0 deliminated strings, so when you look at the decoded
data you might not see what you expect.

Because I generally only care about the attachment data itself, I use
a different decoding scheme where instead of storing the results in a
string, I store it in an array of strings where the last element
contains the decoded data.  This only works because the file
attachments I'm importing do not contain \0's
S.Y.M. Wong-A-Ton - 28 Sep 2007 07:34 GMT
Yes, it is a long road to take to arrive at what you want to achieve...

Thank you for listing the link and the issues you've had with this. I'm sure
others will benefit from your information.
---
S.Y.M. Wong-A-Ton

> I thought about that, it's just a little too convoluted for my tastes,
> although I've done much much worse things to Infopath.  I think I'm
[quoted text clipped - 15 lines]
> contains the decoded data.  This only works because the file
> attachments I'm importing do not contain \0's

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.