Tiff File Creation For Fax With FAXCOMLib

W

Will Arrowsmith

Hi All,

I am trying to create a .tiff file to fax using the windows fax service
FAXCOMLib.
I have created an array of images (bitmaps) and converted them to 1pbb
format in order to allow CCITT3/4 compression for faxing.

The .Tiff file appears to be created successfully however when I try to send
the file as a fax I get the error:
System.Runtime.InteropServices.COMException (0x8007000D): The data is
invalid.

Most other file formats (.txt, .doc etc) send are sent using my faxing code
fine.
My code to send the fax is:

Dim fs As New FAXCOMLib.FaxServerClass
fs.Connect(Environment.MachineName) '//specifies the machinename
Dim obj As Object = fs.CreateDocument(pathToImage)
Dim fd As FAXCOMLib.FaxDoc = CType(obj, FAXCOMLib.FaxDoc)
fd.FaxNumber = txtNumber.Text
Dim i As Integer = fd.Send()
fd = Nothing
fs.Disconnect()
fs = Nothing

As the code above appears to function correctly when not sending one of the
tiff images I have created, Im guessing that Im doing something wrong in my
Tiff image creation code:

Private Function createTiffImage(ByVal bitmapArray() As Bitmap) As String
'get the codec for tiff files
Dim info As ImageCodecInfo = Nothing
Dim ice As ImageCodecInfo
Dim faxPath As String = Application.StartupPath & "\SPLREP\Fax.tiff"

For Each ice In ImageCodecInfo.GetImageEncoders()
If ice.MimeType = "image/tiff" Then
info = ice
End If
Next ice

'use the save encoder
Dim enc As Encoder = Encoder.SaveFlag
Dim enc1 As Encoder = Encoder.Compression

Dim ep As New EncoderParameters(2)

ep.Param(0) = New EncoderParameter(enc, CLng(EncoderValue.MultiFrame))
ep.Param(1) = New EncoderParameter(enc1,
CLng(EncoderValue.CompressionCCITT3))

Dim pages As Bitmap = Nothing
Dim i As Integer = 0

For i = 0 To bitmapArray.GetUpperBound(0) Step 1
If i = 0 Then
'save the first frame
pages = bitmapArray(i)
pages.Save(faxPath, info, ep)
Else
'save the intermediate frames
ep.Param(0) = New EncoderParameter(enc,
CLng(EncoderValue.FrameDimensionPage))
ep.Param(1) = New EncoderParameter(enc1,
CLng(EncoderValue.CompressionCCITT3))
pages.SaveAdd(bitmapArray(i), ep)
End If

If i = bitmapArray.GetUpperBound(0) Then
'flush and close.
ep.Param(0) = New EncoderParameter(enc, CLng(EncoderValue.Flush))
ep.Param(1) = New EncoderParameter(enc1,
CLng(EncoderValue.CompressionCCITT3))
pages.SaveAdd(ep)
End If
Next
Return faxPath
End Function

The Tiff images seem to be recognised by image manipulation programs (e.g.
IrfanView) but are invalid as fax files. What do I need to do to make the
Tiff image a valid fax file?

Thanx very much in advance for all your help.

Will @ Multepos
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top