Click here to Skip to main content
Click here to Skip to main content

Tagged as

How to fetch an image document from FileNet for a known Document ID

, 18 Dec 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
How to fetch an image document from FileNet for a known Document ID

Prerequisite: FileNet IDM Desktop should be installed in the client machine. Add fnnfo.tbl as reference from "C:\Program Files\FileNet\idm\fnnfo.tbl".

Tips:

  1. The Document object's GetCachedFile function is the best function to use for this purpose. It returns the path to the document after it is retrieved to the local cache. Please refer to the IDM Desktop and Web Services Toolkit Help file for more details on its usage.
  2. Be aware that since the file resides in the local cache, you should copy it as soon as possible, because the Cache Manager may delete it to make room for other documents.
  3. Also make sure to copy the file - never move or delete, since this will probably cause an abort with the Cache Manager.
  4. You also need to know which product you are using and where it is running. If you are using IdmWs, the local cache is on the web server box. If using IdmDesktop, the local cache is on the client. This confuses many people.
  5. Lastly, a program like this can quickly overwhelm your system. Make sure your ephemeral ports are set to maximum. If you start experiencing errors after processing a large quantity of documents, this is usually an indicator that you have exhausted your system's resources. The only solution is to slow your code loop down.

Below is a simple application which takes the document ID from a textbox and saves the image retrieved from the FileNet Image server to c:\temp for that corrosponding document ID.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
 
namespace fileNet
{
    public partial class Form1 : Form
    {
        public static Object objMissing = System.Reflection.Missing.Value;
        public static IDMObjects.Neighborhood fnNebHood;
        public static IDMObjects.Library fnLibrary;
 
        public static IDMObjects.GenericObject fnGenericObj;
        public static IDMObjects.Document fnDoc;
        public static IDMObjects.idmObjectType fnObjectType;
        public static string fnCache ;
 
        public Form1()
        {
            InitializeComponent();
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            Boolean fnLogon;
            string fnUid = "your filenet userid";
            string fnPwd = "your filenet password";
 
            fnLibrary = new IDMObjects.Library();
            try
            {
                // Must logon to FileNet using IDMObjects.idmLibraryLogon.idmLogonOptNoUI
                // so that the logon is not cached.
                // If the logon is cached, then the FileNet cache is not cleared when logoff is executed
                if (!fnLibrary.GetState(IDMObjects.idmLibraryState.idmLibraryLoggedOn))
                    fnLogon = fnLibrary.Logon(fnUid, fnPwd, objMissing, 
                                IDMObjects.idmLibraryLogon.idmLogonOptNoUI);
                else
                    fnLogon = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "FileNet Login Error");
            }
            string docID = textBox1.Text;
 
            SaveDoc(docID);
 
            fnLibrary.Logoff();
        }
 
        public void SaveDoc(string argDocid)
        {
 
            fnObjectType = IDMObjects.idmObjectType.idmObjTypeDocument;
 
            try
            {
                fnGenericObj = fnLibrary.GetObject(fnObjectType, argDocid, 
                                         objMissing, objMissing, objMissing);
                fnDoc = (IDMObjects.Document)fnGenericObj;
                int pagec = fnDoc.PageCount;
            }
 
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
 
            //' Write the file out to cache
            //' fileNm = the location of the file in cache
            //' To configure, the cache directory, use the IDM Configuration Tool
            //' Dim fileNm As String = fnDoc.GetCachedFile(0, "", 
            //'            idmGetCachedFileOptions.idmDocGetOriginalFileName)
            string fileNm = fnDoc.GetCachedFile(0, "",
                   IDMObjects.idmGetCachedFileOptions.idmDocGetOriginalFileName);
            string name = fnDoc.Name;
            fnDoc.Launch(IDMObjects.idmDocLaunchOption.idmDocLaunchIDMViewer);
 
            string onlyName = fnDoc.Name;
            string destFile = "C:\\Temp\\" + name + "_1.tif";
 
            File.Copy(fileNm, destFile,true);
            File.SetAttributes(destFile, FileAttributes.Normal);
        }
    }
}

If your document is a multiple page .tif image, then set the first argument of
GetCachedFile() to the page number which you want to fetch. Else you can loop that function for the pageCount to retrieve all the images.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

SwarnenduDas
Technical Lead
United States United States
No Biography provided

Comments and Discussions

 
QuestionThis program is wrong PinmemberMember 106081673-Jul-14 0:54 
QuestionCan able to download document from Image services using IDM desktop. PinmemberAmmuaamear126-Mar-14 4:26 
QuestionCold documents PinmemberMember 1060816725-Feb-14 2:31 
GeneralMultipage Tif PinmemberBryan Ramsdell18-Jul-12 4:02 
Questionbulk Ingest into IS4.0 Pinmemberkumaran_vr24-Nov-11 4:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.1411023.1 | Last Updated 18 Dec 2011
Article Copyright 2011 by SwarnenduDas
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid