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

Question

Question

Can we merge files with the laserfiche SDK

SDK
asked on March 5, 2014 Show version history

I could not find any method in the API documentation to merge files with laserfiche SDK.Has anyone done it some other way.

0 0

Replies

replied on March 5, 2014

I'm not sure what you specifically mean by "merging files", but whatever it is the required steps to perform the operation are provided by the SDK.  If you describe what you are trying to accomplish maybe we can help you work out the API calls necessary to carry it out.

0 0
replied on March 5, 2014 Show version history

Kumud - By 'merge' do you mean taking the pages from one document and inserting them into another document?  If so, then yes you can do that with the SDK. 

 

If you need help with the SDK script then let me know and I can provide some code snippets.

 

(Late edit:  I see Brian beat me to the response! wink)

0 0
replied on March 5, 2014 Show version history

I am importing multiple files into Laserfiche.All these files are in different format.I want to generate pages in laserfiche for all of them and merge them together in one big file.

 

I have figured out how to import files

 

I still dont know how can I generate laserfiche pages with .NET SDK.I know it can be done with CAT.

 

I think inserting one document into another will work after I am able to generate pages.It will be great if you have some code snippets.

0 0
replied on March 5, 2014

I might be over simplifying this but if you are using Import Agent to import the files there is an option to 'append pages' if an LF document with the same name already exists. 

 

So you might be able to have Import Agent create that large single document for you if you use the same document name for each file

 

0 0
replied on March 5, 2014

Cliff,

 I am going to give it a try.In the meanwhile can you provide me some code to insert pages from one document into other documents.

 

I tried doing something with DocumentInfo Object but it does not seem to be working.

 

 

 

 

0 0
replied on March 5, 2014

The DocumentInfo class has member functions CopyPagesTo and MovePagesTo.

replied on March 5, 2014

Kumud,

 

Here is a code snippet that works on my 9.1.1 system.  The sub takes two parameters; the first one is the EntryID of the source document and the second is the EntryID of the target document.  The sub also deletes the source document once the pages are moved.

 

    Private Sub MovePages(ByVal sourceID As Integer, ByVal targetID As Integer)

        'Make sure we wrap the code in a Try Catch to catch errors...
        Try
            'Instantiate a new session...
            Dim lfSession As Session = New Session()

            'Connect to the repository and login...
            lfSession.Connect(New RepositoryRegistration("localhost", "LFMAIN"))
            lfSession.LogIn("admin", "admin")

            'Get references to both the source and target documents...
            Dim docSource As DocumentInfo = Document.GetDocumentInfo(sourceID, lfSession)
            Dim docTarget As DocumentInfo = Document.GetDocumentInfo(targetID, lfSession)

            'Lock them both...
            docSource.Lock(LockType.Exclusive)
            docTarget.Lock(LockType.Exclusive)

            'Move all of the pages from the source document to the target document...
            'NOTE: MovePages method parameters;
            'Parameter1 = page range to copy.  In this example we will copy all of the pages...
            'Parameter2 = the reference to the target document
            'Parameter3 = the destination page number.  In this example we want to move the copied pages to the end of the target document...
            docSource.MovePagesTo(New PageRange(1, docSource.PageCount), docTarget, docTarget.PageCount + 1)

            'Delete the source document...
            docSource.Delete()
            docSource.Save()

            'Unlock the target document...
            docTarget.Unlock()

            'Cleanup...
            docTarget.Dispose()
            docSource.Dispose()
            lfSession.Close()

        Catch ex As Exception

            'Show any errors...
            MessageBox.Show(ex.Message, "Error")

        End Try


    End Sub

Let me know if this helps...

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

Sign in to reply to this post.