You are viewing limited content. For full access, please sign in.

Question

Question

upload a file to laserfiche in laserfiche format

asked on June 18, 2015 Show version history

I am trying to upload a file to laserfiche in laserfiche format. I have a piece of code that upload files in original file format to laserfiche.

1) How do i convert that document to laserfiche format/ Laserfiche pages ?

2) Am i doing this the right way ?

 

This is what i am doing. 

1) Create a destination folder in laserfiche

2) Create a laserfiche document at that destination folder location

3) Import the local file as Edoc to the laserfiche document 

 

 # region creates a file with specified folder name and filename

                    //Prevent memory leak with the using statement
                    using (DocumentInfo doc = new DocumentInfo(mySess))
                    {
                        //Check if the destination folder exists
                        EntryInfo docentryinfo = Entry.TryGetEntryInfo(laserfichedestinationfolder, mySess);
                        if (docentryinfo == null)
                        {
                            //Create a document in the destination folder
                            doc.Create(laserfichedestinationfile, "DEFAULT", EntryNameOption.AutoRename);

                           //It is advised to lock the document folder / document before making any changes .. saw this in the docs 
                            docentryinfo.Lock(LockType.Exclusive);
                            DocumentImporter DI = new DocumentImporter();
                            DI.Document = doc;
                            //Import the local file into the laserfiche document ...gives the mime type and path of the file as arguments 
                                                   DI.ImportEdoc(System.Web.MimeMapping.GetMimeMapping(Path.GetFileName(localfilepath)), localfilepath);
                            docentryinfo.Unlock();
                        }
                    }

                #endregion

 

0 0

Answer

SELECTED ANSWER
replied on June 19, 2015

The functionality to dynamically generate Laserfiche image pages from PDFs is not available in the SDK due to third-party licensing restrictions. 

1 0

Replies

replied on June 18, 2015

The code looks ok to me.

If you're asking about extracting pages from arbitrary electronic documents, there isn't support for this in the SDK.  See e.g. this recent question.

0 0
replied on June 18, 2015 Show version history

If the source file that you are importing is an image file, then you do not want to import it as edoc.  What I like to do is check the file extension against the users conversion list and then handle the import accordingly.

Here is a function to get the users conversion list from their profile:

    Private Function ConvertionExt() As List(Of String)
        Dim slReturn As New List(Of String)
        If CurSession IsNot Nothing Then
            Try
                Dim tac As TrusteeAttributeCollection = Trustee.GetAttributes(CurSession.UserIdentity, CurSession)
                Dim sExt As String = Nothing
                If tac.TryGetValue("[OPTIONS]ImportConversionList", sExt) Then
                    slReturn.AddRange(sExt.ToLower.Split(","))
                End If
            Catch ex As Exception
                ' Log Error here
		' return empty list
                slReturn.Clear()
            End Try
        End If
        Return slReturn
    End Function

And then here is sample code of how I approach the import:

'  Get the document into a DocumentInformation object however you wish...
'  I usually have code that checks if I am creating a new document or
'  adding to an existing document.  So if that is the case, I first create the 
'  DocInfo object and set it to nothing.  Then either open the existing doc
'  or create the new document.
'  Now ensure that the DocInfo is not nothing and then import...
If docInfo IsNot Nothing Then
   Dim MyConvertionList As List(Of String) = ConvertionExt()
   Dim docImporter As DocumentImporter = New DocumentImporter
   docImporter.Document = docInfo
   ' Get the lower case extention without the period
   Dim sExt As String = sFileName.ToLower.Substring(sFileName.LastIndexOf("."c) + 1)
   If MyConvertionList.Contains(sExt) Then
      If sExt = "txt" Then
         ' Import the text file
         docImporter.ImportText(sFileName)
      Else
         ' Set the Document importer OCR option
         docImporter.OcrImages = True
         ' Import the Image file
         docImporter.ImportImages(sFileName)
      End If
   Else
      ' Set the Document importer Text Extraction option
      docImporter.ExtractTextFromEdoc = True
      ' Import the Electronic file
      docImporter.ImportEdoc(GetMimeType("." & sExt), sFileName)
   End If
   docInfo.Dispose()
End If

 

0 0
replied on June 19, 2015 Show version history

Thank you brian and bert ,

1) According to brian , i can't generate laserfiche pages from an Edoc (pdf file in my case) . Is that right ?

2) I am trying to import a pdf file with the following options

     a) Generate the laserfiche pages

     b) Don't Keep/ Remove the original pdf file . This functionality is currently available in laserfiche client          as i have described below 

I am  trying to programmatically mimic a  functionality which allows users to generate laserfiche pages when a document is imported into laserfiche. My program is currently doing  a batch upload of pdf files with the code i mentioned above. The problem is that the file is getting uploaded in a pdf format . But i don't want the pdf file , I only want the laserfiche pages generated. To see what i mean by that do the following 

1) Hit File -> Import 

2) On the Import Files dialog , select a pdf file 

3) Hit options and then check generate laserfiche pages and then uncheck keep original pdf files 

4) Go ahead and import the pdf file with these options 

lfimportsnip.JPG
lfimportsnip.JPG (130.46 KB)
0 0
replied on June 19, 2015

ok. thank you justin

0 0
replied on June 19, 2015

The Laserfiche SDK does not have the tools to convert PDF to TIFF, but you can use GhostScript to convert the PDF and then import the resulting TIFF.

See Pdf to tiff via sdk and tiff to pdf its possible ? for more info.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.