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

Question

Question

Read Electronic File

asked two days ago

How can I read an electronic file and see if the file begins with the string ‘%PDF’ in workflow SDK activity?

0 0

Replies

replied one day ago

Any update please?

0 0
replied one day ago

You would have to download the PDF edocument to a memory stream, then convert the stream to byte array, and finally analyze the first so may bytes to check for PDF signature.

0 0
replied one day ago

Thanks. Do you have any sample code for that please?

0 0
replied one day ago

I did not test this code nor did I code how to compare the byte arrays, but this is a starting point (assuming the edoc is already in the repository).

            If BoundEntryInfo.EntryType = EntryType.Document Then
                Using Doc As DocumentInfo = DirectCast(BoundEntryInfo, DocumentInfo)
                    Try
                        If Doc.ElecDocumentSize > 0 Then
                            Using msDoc As MemoryStream = New MemoryStream()
                                Dim CurExporter As DocumentExporter = New DocumentExporter()
                                ' Export edoc to memorystream
                                CurExporter.ExportElecDoc(Doc, msDoc)
                                ' Set up PDF signature
                                Dim PDFSig As Byte() = New Byte(){ 37, 80, 68, 70, 45, 49, 46 }
                                ' Create byte arry to hold first 7 bytes of edoc
                                Dim LFDocSig As Byte()
                                ' Load first 7 bytes of memorystream into byte array
                                memStream.Read(LFDocSig, 0, 7)
                                ' Now compare the PDFSig and LFDocSig and if same, then it is a PDF
                            End Using
                        End If
                    Catch ex As Exception
                        WorkflowApi.TrackError(ex.Message)
                    End Try
                End Using
            End If

 

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

Sign in to reply to this post.