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

Question

Question

Export tiff to pdff

asked on December 2, 2015

Good morning,

I'm writing a script in workflow to export a Tiff file as a PDF in my computer. We are able to export the tiff, however we can't convert it. We looked for related questions here and found some examples where the programmers use the method ExportPdf of a DocumentExporter object.  However we are having problems with its parameters, this example was taken from a old thread:

ExportDoc.ExportPdf(MyDocument,MyDocument.AllPages, PdfExportOptions.None, "C:\TestData\" + EntryName + ".pdf")

One of our problems is that we don't have the property "AllPages".

Could someone please help us with a sample code where we can see how this script should be, if possible with the references. I'm sorry for asking this much but we are literally running out of time and it's critical. 

 

Below is our script:

namespace WorkflowActivity.Scripting.SecuenciadeComandosSDK
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;
    using System.Text;
    using Laserfiche.RepositoryAccess;
   // using DocumentProcessor90;
    using LFSO90Lib;
    //using DocumentProcessor92;
    using Laserfiche.DocumentServices;


    /// <summary>
    /// Proporciona uno o más métodos que se pueden ejecutar al ejecutarse la actividad de secuencias de comando de flujo de trabajo.
    /// </summary>
    public class Secuenciadecomandosde1 : RAScriptClass92
    {
        /// <summary>
        /// Este método se ejecuta cuando se ejecuta la actividad.
        /// </summary>
        protected override void Execute()
        {
            LFApplication app = new LFApplication();
            LFServer serv = (LFServer)app.GetServerByName("LOCALHOST");
            LFDatabase db = (LFDatabase)serv.GetDatabaseByName("Lasefiche");
            //LFDatabase db = (LFDatabase)serv.GetDatabaseByName("Lasefiche");
            LFConnection conn = new LFConnection();
            conn.UserName = "admin";
            conn.Password = "123";
            conn.Create(db); 
            //IDocumentContents doc = (IDocumentContents)db.GetEntryByID(4);
            LFDocument doc = (LFDocument)db.GetEntryByID(4);
            LFDocumentPages pages = (LFDocumentPages)doc.Pages;
            //pages.MarkPageByIndex(1);
            //DocumentExporter docuExport = new DocumentExporter();
            DocumentExporter docuExport = new DocumentExporter();
            docuExport.ExportPdf(doc, doc.Pages, PdfExportOptions.None, "C:\\Ricardo\\doc.pdf");
            //docuExport.ExportPdf(doc, pages, PdfExportOptions.None,@"C:\Ricardo\doc.pdf");*/
            /*
            codigo que borre
            */
           // DocumentInfo docInfo = Document.GetDocumentInfo()
            doc.Dispose();
    
        }
    }
}

Inline image 1

Thanks!!! 

0 0

Answer

SELECTED ANSWER
replied on December 2, 2015 Show version history

Hi Guys!

The problem is gone, it was something pretty stupid, we moved the document services dll to the system32 folder, that was all.

 

Thank you very much for your assitance :)

0 0

Replies

replied on December 2, 2015

I don't see where you're using DocumentProcessor. Your code seems to be calling Laserfiche.DocumentServices and mixing LFSO and RA which will not work. Please don't make your own LF connections, the script already provides a connection to LF.

1 0
replied on December 2, 2015

Miruna, 

Sorry for posting an incorrect script, we noticed that error and corrected it, below is the code my coworker made with the correction:

LFApplication app = new LFApplication();
           LFServer serv = (LFServer)app.GetServerByName("localhost");
           LFDatabase db = (LFDatabase)serv.GetDatabaseByName("Aplicom-Procesos");
           LFConnection conn = new LFConnection();
           conn.UserName = "admin";
           conn.Password = "123";
           conn.Create(db);
           
           IDocumentContents doc1 = (IDocumentContents)db.GetEntryByID(130);
           
           
           
           DocumentExporter docuExport = new DocumentExporter();
           
           PageRange Range = new PageRange(1, 1);
           PageSet Set = new PageSet(Range);
           
           docuExport.ExportPdf(doc1, Set, PdfExportOptions.None, "C:\\Esteban\\doc.pdf");
           
           doc1.Dispose();

Any suggestion? We are missing something important. 

 

0 0
replied on December 2, 2015 Show version history

As Miruna said, you are mixing RA with LFSO. You will want to use "DocumentInfo" class which implements "IDocumentContents" interface. This code should get you in the right direction:

using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;
    using System.Text;
    using Laserfiche.RepositoryAccess;
    using Laserfiche.DocumentServices;

    /// <summary>
    /// Provides one or more methods that can be run when the workflow scripting activity is performed.
    /// </summary>
    public class Script1 : RAScriptClass91
    {
        /// <summary>
        /// This method is run when the activity is performed.
        /// </summary>
        protected override void Execute()
        {
            // Write your code here. The BoundEntryInfo property will access the entry, RASession will get the Repository Access session
            using (DocumentInfo doc = Document.GetDocumentInfo(BoundEntryId, RASession)) //or use Document.GetDocument([Path], RASession) if you know the path
            {
                PageSet pg = doc.AllPages;
                DocumentExporter docexp = new DocumentExporter();
                docexp.ExportPdf(doc,pg,PdfExportOptions.None, "C:\\Ricardo\\doc.pdf");
            }
        }
    }

Now this assumes that in your workflow you have a bound entry you are running the script against.

0 0
replied on December 2, 2015

We trying with this code  but it shows the following error

 

 

"No entry point was found" any idea?

0 0
replied on December 2, 2015 Show version history

If you want to use it that way, use this code: (Make sure that entryid exists in Laserfiche as well)

using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;
    using System.Text;
    using Laserfiche.RepositoryAccess;
    using Laserfiche.DocumentServices;

    /// <summary>
    /// Provides one or more methods that can be run when the workflow scripting activity is performed.
    /// </summary>
    public class Script1 : RAScriptClass91
    {
        /// <summary>
        /// This method is run when the activity is performed.
        /// </summary>
        protected override void Execute()
        {
            // Write your code here. The BoundEntryInfo property will access the entry, RASession will get the Repository Access session
            using (DocumentInfo doc = new DocumentInfo(130, RASession))
            {
                PageSet pg = doc.AllPages;
                DocumentExporter docexp = new DocumentExporter();
                docexp.ExportPdf(doc,pg,PdfExportOptions.None, "C:\\Ricardo\\doc.pdf");
            }
        }
    }

Also, it is not necessary that you create a new session. Workflow creates the session in the object "RASession" which uses the workflow connection profile.

2 0
replied on December 2, 2015 Show version history

it shows this error

it can't find this document

 

Any idea?

 

 

0 0
replied on December 2, 2015

Oh, i should've seen this coming. blush

Your initial post says you're trying to generate pages for PDF. The code above takes a document's image pages and exports them as PDF. You want to use ExportElecDoc instead of ExportPDF to export the PDF.

replied on December 2, 2015

I'm confused, your screenshots and code keep switching between WF 9.1 and 9.2.

When exactly are you getting those errors? If it's when you test the script, did you specify an entry? The Error List in the script editor should give you the line where the error occurs.

0 0
replied on December 2, 2015

We are trying to export a tif image to pdf, any idea of how to export this document with Laserfiche SDK?

0 0
replied on December 2, 2015

Umm... I'm confused

0 0
replied on December 2, 2015 Show version history

this is the script we are testing


   

using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;
    using System.Text;
    using Laserfiche.RepositoryAccess;
    using Laserfiche.DocumentServices;

    public class Script1 : RAScriptClass92
    {
        protected override void Execute()
        {
            using (DocumentInfo doc = Document.GetDocumentInfo(272, RASession))
            {
               
                MsgBox(doc.Name);

                DocumentExporter docexp = new DocumentExporter();

                docexp.ExportPdf(doc, doc.AllPages   ,PdfExportOptions.None, "C:\\Esteban\\doc.pdf");
            }
        }
    }

 

and is shows this error

 

0 0
replied on December 2, 2015 Show version history

Ok, let me do a summary of this, sorry if we are not making much sense, we just want to take one tiff file and export it to a specific path, but we need to convert it to PDF. We are using the document ID as a filter. 

The above code which Esteban is using shows that error (in general all our scripts are failing). 

0 0
replied on December 2, 2015 Show version history

Your script works for me for documents with image pages. Just to double-check, your document ID 272 is an image document, not an TIFF image imported as an electronic document, right?

Edit: The only time i get the error you have above is when the document contains a single empty page. If the document has image pages, the export works. If the document is an electronic document with no pages, i get "Object reference not set to an instance of an object".

1 0
SELECTED ANSWER
replied on December 2, 2015 Show version history

Hi Guys!

The problem is gone, it was something pretty stupid, we moved the document services dll to the system32 folder, that was all.

 

Thank you very much for your assitance :)

0 0
replied on December 2, 2015

Ok, but that doesn't make sense with the errors you're getting. The dlls would be loaded from the GAC, not System32.

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

Sign in to reply to this post.