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

Question

Question

How do i upload a file to laserfiche

asked on June 8, 2015 Show version history

Hello,

               I want upload a file to laserfiche.  I have tried a few things which didn’t work out. For ex

 

            RepositoryRegistration myRepoReg = new RepositoryRegistration("GCLFDEV", "GeneralCodeDBDev");

            Session mySess = new Session();

            mySess.LogIn("ADMINusername", "ADMINpassword", myRepoReg); //uses Laserfiche authentication

 

            DocumentInfo doc = new DocumentInfo(mySess);

 

            doc.Create(@"GeneralCodeDBDEV\TEST", "DEFAULT000000", EntryNameOption.AutoRename); -- An unhandled exception of type 'Laserfiche.RepositoryAccess.ObjectNotFoundException' occurred in Laserfiche.RepositoryAccess.dll

 

            DocumentImporter DI = new DocumentImporter();

 

            DI.Document = doc;

            DI.ImportEdoc("application/pdf", @"C:\Users\tdt1038\Desktop\Order Placed.pdf");

 

  Is this the right way to do this ?

0 0

Answer

SELECTED ANSWER
replied on June 8, 2015

Don't put the repository name in the path, so you'll want just "\TEST" as your first argument.  For volumes, just give the name of the logical volume "DEFAULT", since the server decides which physical volume the document will be assigned to.

1 0

Replies

replied on June 8, 2015

Glad to hear changing to the logical volume name fixed your issue.

If you have a lot of files you are processing, if you are not releasing the DocumentInfo object, you will have a memory leak in your application.  As stated above, you should use a using statement like this:

RepositoryRegistration myRepoReg = new RepositoryRegistration("GCLFDEV", "GeneralCodeDBDev");
Session mySess = new Session();
mySess.LogIn("ADMINuser", "ADMINuser", myRepoReg); //uses Laserfiche authentication
// Prevent memory leak with "Using" statement
using (DocumentInfo doc = new DocumentInfo(mySess)) 
{
    doc.Create(@"\TEST", "DEFAULT", EntryNameOption.AutoRename);
    DocumentImporter DI = new DocumentImporter();
    DI.Document = doc;
    DI.ImportEdoc("application/pdf", @"C:\Users\tdt1038\Desktop\Order Placed.pdf");
}
// don't forget to log out also.
mySess.LogOut();

 

2 0
replied on June 8, 2015

Have you tried to specify the logical volume name of DEFAULT instead of the physical volume name of DEFAULT000000?

 

Also, you should either use a using statement or make sure to dispose of the DocumentInfo object after import is done.

1 0
replied on June 8, 2015

it worked thanks. here is the working code snippet

 

RepositoryRegistration myRepoReg = new RepositoryRegistration("GCLFDEV", "GeneralCodeDBDev");
            Session mySess = new Session();
            mySess.LogIn("ADMINuser", "ADMINuser", myRepoReg); //uses Laserfiche authentication

            DocumentInfo doc = new DocumentInfo(mySess);

            doc.Create(@"\TEST", "DEFAULT", EntryNameOption.AutoRename);

            
            DocumentImporter DI = new DocumentImporter();

            DI.Document = doc;
            DI.ImportEdoc("application/pdf", @"C:\Users\tdt1038\Desktop\Order Placed.pdf");

0 0
replied on June 8, 2015

ok thank you

0 0
replied on June 23, 2017

Good evening,

My logic is almost verbatim with the C# example above.  My process creates a document based on a template, updates a few values and imports a PDF document.  My PDF document shows up as follows:

I don't see any errors during my processing.  Admittedly, I am real green with this stuff... but shouldn't the document appear under thumbnails?

0 0
replied on June 23, 2017

If you right click the document and choose Open - Edit Electronic File, what happens?

If it opens the PDF in acrobat, then you do not have pages generated so there are no thumbnails and no page images.

0 0
replied on June 23, 2017

Hmm - both documents load in acrobat

I guess I don't understand enough.  The PDF I am trying to import was stolen from this document.  Should my logic say create a 1 one page document thumbnail image?

0 0
replied on June 23, 2017

Your logic is probably fine.  When you use the SDK to import PDFs, there is not an option in the SDK DocumentImporter to generate pages for the PDF.

 

You can try to log into the client as the user that your program is logging in as and then try going into "Tools - Options - New Documents - Settings" and check the box for "When importing PDFs" Generate Laserfiche Pages

I think that then will apply to SDK imports as well.

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

Sign in to reply to this post.