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

Question

Question

Import PDF by docImporter.ImportEdoc is not work

asked on January 6, 2022 Show version history

Hello all...

I have been trying for a long time to import a PDF file into my repository, but the problem is in the (docImporter.ImportEdoc) Is there an error in the code, knowing that I created a new project, but the same problem and I did not find any solution for it
I need help

 

 

using Laserfiche;
using Laserfiche.Project;
using global::Laserfiche.RepositoryAccess;
using System.IO;
using DocumentProcessor102;
using LFDocument = LFSO102Lib.LFDocument;
using LFSO102Lib;

 


        private void button1_Click(object sender, EventArgs e)
        {
            string nameE = "12345678910";
            string patheS = @"55\";
            string fuLL = patheS + nameE;
            string fuLL2 = @"C:\temp\output.pdf";
            try
            {

 var myRegistration = new RepositoryRegistration("192.168.154.147", "ems-nrc");
 var mySession = new Session();

 mySession.LogIn("admin", "8589955", myRegistration);

int docID = Document.Create(fuLL, "DEFAULT", EntryNameOption.AutoRename, mySession);

DocumentInfo docInfo = (DocumentInfo)Entry.GetEntryInfo(fuLL, mySession);
DocumentImporter docImporter = new DocumentImporter();
docImporter.ImportEdoc(fuLL2,"application/pdf");
 

 

 

 

 

error mee.png
error mee.png (116.92 KB)
0 0

Answer

SELECTED ANSWER
replied on January 6, 2022

Your project references include LFSO, so maybe it's pulling DocumentImporter from the wrong library. The one that's compatible with the DocumentInfo objects you have is from DocumentServices. You're also missing the step where you hook up the DocumentImporter with the target document, I think it's just the property Document.

1 0

Replies

replied on January 6, 2022

If you compile the project, the output window should show more information about the error. One problem I see is that the contentType is the first parameter and the file path is the second path, but that wouldn't explain why it won't compile.

1 0
replied on January 6, 2022

Thank you, my friend
The problem was solved by adding a new (reference) and deleting the unused ones
But when executing the code and accessing the command (docImporter.ImportEdoc("application/pdf",fulll2);) the following error message appears
(object reference no set to an instance of an object)

Note that the file (output.pdf) is located in the correct address in (C:\\temp\\output.pdf)

my code.png
my code.png (133.56 KB)
0 0
replied on January 7, 2022

Like Brian mentioned, I think you need to assign the document to the docImporter object before calling ImportEdoc.

0 0
replied on January 7, 2022

thanks for helping me

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

Sign in to reply to this post.