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

Question

Question

How to get bytes of LF Pages or electronic document?

asked on June 10, 2015

[Using Coding]

Very first I would like to check whether document has LF pages or not, whether it has electronic document available or not. Let me try to clarify more, whether it has only LF pages or only electronic document or both.

1) only pages: I want bytes, mimetype and extension

2) only electronic document: I want bytes, mimetype and extension

3) both:  I want bytes, mimetype and extension

 

How can I verify and get the bytes?

0 0

Replies

replied on June 10, 2015 Show version history

Hi,

Try with the next code with Laserfiche SDK:

        Dim objDocumentoLF As LFDocument
        Dim objDocPagesLF As LFDocumentPages

        Dim lngTocID As Long = 0 'is TocId of the Document Laserfiche
        Dim strMimeType As String = ""
        Dim bolIsPage As Boolean = False
        Dim bolIsElectronic As Boolean = False

        objDocumentoLF = objRepositorio.GetEntryByID(lngTocID)
        objElectFileLF = objDocumentoLF.ElectFile
        objDocPagesLF = objDocumentoLF.Pages

        If objDocumentoLF.ElectFile.IsEmpty Then
            'only pages, is image
            bolIsPage = True
        Else
            'electronic document
            strExtension = objDocumentoLF.ElectFile.MimeType
            bolIsElectronic = True
        End If
        For Each objPage As LFPage In objDocPagesLF
            MsgBox(objPage.ImageSize.ToString)
        Next

 

objRepositorio is the type LFDatabase (repository from the server)
lngTocID is the TocID of the document

I hope you help!!!

0 0
replied on June 10, 2015

Thanks

I think this code using old methods not new one as in .net SDK. If possible can you please update.

0 0
replied on June 17, 2015

Hi Ashish,

I found a solution here that will get:

  • The bytes from a document containing Laserfiche Pages
  • The bytes, mimetype, and extension for a document containing an electronic document
  • The bytes, mimetype, and extension for a document containing both Laserfiche Pages and an electronic document
' Create DocumentInfo from a document with EntryID 4781
 Dim docInfo As DocumentInfo = Document.GetDocumentInfo(4781, session)

 Dim isEDoc As Boolean = docInfo.IsElectronicDocument ' Boolean indicating if the document contains an electronic document
 Dim pageCount As Integer = docInfo.PageCount ' Integer representing the number of pages the document contains

' Prepare filesize, mimetype, and extension variables
Dim size As Long
Dim mimetype As String
Dim extension As String

' Checks to see if a document contains pages
If pageCount > 0 Then

     ' PageInfoReader will read each page in the document
     Dim pageReader As PageInfoReader = docInfo.GetPageInfos

     ' Displays the ImageSize of each page in bytes
     Console.WriteLine("The sizes of the pages are as follows...")

     For Each pInfo As PageInfo In pageReader
          Dim imageSize As Integer = pInfo.ImageDataSize
          Console.WriteLine(imageSize)
     Next

End If

' Checks to see if the document contains in electronic document
If isEDoc Then

     ' Gets the filesize (in bytes), mimetype, and extension for the document
     size = docInfo.ElecDocumentSize
     mimetype = docInfo.MimeType
     extension = docInfo.Extension

End If

This does not get the mimetype and extension for LF Pages since that information is more relevant when exporting the document outside of the repository.  It does retrieve that information for electronic documents, though!

I hope this helps!

0 0
replied on June 17, 2015

Sorry, may be I haven't clarified but I want file bytes not the size in bytes

I have done it using exportpdf option

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

Sign in to reply to this post.