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

Question

Question

SDK - Export PDF

SDK
asked on September 22, 2014

I have a customer that has an SDK 8.0 application that exports files out of Laserfiche in PDF format. These documents are stored in Laserfiche either as electronic PDF files or Laserfiche documents (tiff images). Everything is exported  in PDF format. They are in the process of testing out their applications with SDK 9.0. The original SDK 8.0 code will not function properly in 9.0. The issue is with exporting the Laserfiche document. The error received is “Document_Format_PDF is not a member of DocumentProcessor90”

 

They have not been able to get ExportPdf to function either. Below is the original 8.0 code. Any additional direction or sample code would be greatly appreciated.

 

The code original code is:

Dim doc as LFDocument

Dim db as LFDatabase

Dim DocE as new DocumentExporter

Dim electri_1 as LFElectfile

 

 

doc = db.GetEntryByPath(“the_path_in-Laserifiche”)

DocE.SourceDocument = doc

electri_1 = doc.ElectFile

 

if electri_1 .IsEmpty then   (If  this is a image then do this)

   DocE.format = Documnet_Format.Documetn_Format_PDF

Else ( if this is pdf then do this)

  DocE.format = Documnet_Format.Documetn_Format_Electronicfile

End if

DocE.ExportToFile(“c:\test\mypdf.pdf”) 

0 0

Replies

replied on September 23, 2014

Part II - This uses the same example as above, and replaces Document Processor with the PDFExporter.

First, add a reference to the dll and then import it:

 

 

Then the code looks like this:

 

            Dim PdfOptions As New ExportOptions
            'Set the properties
            PdfOptions.SetLayers(DocumentLayers.All)
            PdfOptions.SetMetadataOptions(MetaDataOptions.All)
            PdfOptions.setPagesToExport(New Integer() {1, 3})
            PdfOptions.SetRedactionOption(RedactionOptions.Apply)
            'Create the exporter and assign the information object
            Dim PdfExp As New PdfExporter
            PdfExp.SetOptions(PdfOptions)
            'The rest of the stuff
            Dim LFDoc as LFDocument = Me.Entry
            Dim sClientNumber As String = GetTokenValue("GetFieldData_RM Client Number").ToString
            Dim sMatterNumber As String = GetTokenValue("GetFieldData_RM Matter Number").ToString
            Dim sDocType As String = GetTokenValue("GetFieldData_RM Doc Type").ToString
            Dim sBatesNo As String = GetTokenValue("GetFieldData_RM_Bates_Number").ToString
            Dim sFileName =  "C:\Temp\Export\" & sClientNumber & "-" & _
                             sMatterNumber & "-" & sDocType & "-" & sBatesNo & ".pdf"

            'And write the file
            Dim Arr() As Byte = PdfExp.ExportPages(LFDoc)
            Dim Pdf As New FileStream(sFileName, FileMode.Create)
            Pdf.Write(Arr, 0, Arr.Length)

 

It's well documented in the .COM SDK help files.

1 0
replied on September 22, 2014

You want to look into the PDFExporter library for exporting images as PDFs. This was deprecated in DocumentProcessor and moved there around 8.1.

0 0
replied on September 23, 2014 Show version history

Here is some code we wrote to do this as a workflow sdk task for tif files. 

Justin is correct, pdfs are handled differently, and I'll dig out the code for that. 

In case this is helpful for anyone, here's how to export tif files as a workflow sdk task:

 

Add this to the top of the script:

Imports LFSO90Lib
Imports System.IO
Imports DocumentProcessor90

 

And this code, modifying it to meet your specific needs. This was for a law firm, hence field names like "Matter #". We collect the index fields, and then use that to build up a file name, then export the item.  This is all in a Try Catch loop, in case something goes wrong.

 

        Protected Overrides Sub Execute()
            'Exports the document as a TIF file, with tags for the client, matter, doc type and bates # = The filename
            'The start rule requires a document
            Dim LFDoc as LFDocument = Me.Entry
            Dim sClientNumber As String = GetTokenValue("GetFieldData_RM Client Number").ToString
            Dim sMatterNumber As String = GetTokenValue("GetFieldData_RM Matter Number").ToString
            Dim sDocType As String = GetTokenValue("GetFieldData_RM Doc Type").ToString
            Dim sBatesNo As String = GetTokenValue("GetFieldData_RM_Bates_Number").ToString
            Dim sFileName =  "C:\Data\Export\" & sClientNumber & "-" & _
                             sMatterNumber & "-" & sDocType & "-" & sBatesNo & ".tif"
            Dim DocExporter as New DocumentExporter
            Dim DocPages as LFDocumentPages = LFDoc.Pages
            DocPages.MarkAllPages
            DocExporter.AddSourcePages(DocPages)
            DocExporter.Format = Document_Format.DOCUMENT_FORMAT_TIFFG4
            DocExporter.ExportToFile (sFileName)

        End Sub

 

0 0
replied on September 29, 2014

Hi Cynthia, 

If your question has been answered, please let us know by clicking the "This answered my question" button on the response.

If you still need assistance with this matter, just update this thread. Thanks!

0 0
replied on October 1, 2014

The user is still struggling to get this to run. I have uploaded a sample application. To upload I renamed the zip file to .txt but it will need to be renamed .7z.

The user is attempting to run this in a 32-bit environment and receives the error message: "Retrieving the COM class factory for component with CLSID {AC89C47D-1BA9-4F31-B90C-435C576B31BB} failed due to the following error: 800736b1."

Support tells us that this is due to the code referencing an x64-bit component. Unfortunately, we have not been able to identify this component.

It is running in visual studio 2008 and using Visual Basic.

Also the only dll's being used are DocumentProcessor90, LFSO90, LFImageEnable80, and PdfExporter90.

Any assistance is greatly appreciated.

0 0
replied on October 1, 2014

It's DocumentProcessor90.

0 0
replied on October 1, 2014

Thanks Miruna.

What should be used in place of DocumentProcessor90 in a 32-bit environment? DocumentProcessor80?

0 0
replied on October 1, 2014

There 32-bit and 64-bit versions of DocumentProcessor, you need to reference the the 32-bit one in your project if you're compiling as 32-bit. Same for LFSO and LFImageEnable.

1 0
replied on October 1, 2014

Thanks Miruna for the additional explanation.

0 0
replied on October 2, 2014

Miruna,

The user believes he is referencing the 32-bit versions but continues to receive the same error message. Any suggestions?

0 0
replied on October 2, 2014

The GUID in the message above is for the x64 version, not the x86 one. How is he referencing the files in the project? Is the application built as x86?

0 0
replied on October 3, 2014

One thing to check is whether your Configuration Manager is set to "x86", as opposed to "Any CPU".  x86 will force a 32 bit compilation and is what you want.

0 0
replied on October 3, 2014

Thanks for the additional info. The programmer is taking a closer look now.

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

Sign in to reply to this post.