By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,812 Members | 863 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,812 IT Pros & Developers. It's quick & easy.

Tiff File Creation For Fax With FAXCOMLib

P: n/a
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

Nov 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.