469,935 Members | 1,924 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,935 developers. It's quick & easy.

Tiff File Creation For Fax With FAXCOMLib

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
0 1808

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Ponty | last post: by
reply views Thread by Will Arrowsmith | last post: by
5 posts views Thread by Eddie Leung | last post: by
6 posts views Thread by qysbc | last post: by
5 posts views Thread by Sameer Gupta | last post: by
reply views Thread by Stedak | last post: by
8 posts views Thread by Robert Dufour | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.