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

Tiff File Creation For FAXCOMLib

P: n/a
Hi All,

I am aiming to create a multiframe Tiff file that I can fax using the
windows fax service FAXCOMLib.
I have created an array of Bitmaps (pages I want in my fax doc) and
succesfully converted them all to be 1bppIndexed.
I then combine all bitmaps into a single multiframed Tiff file (with CCITT3
compression) before attempting to fax the file.

When I call the send method of the fax routine I get the error:
"System.Runtime.InteropServices.COMException (0x8007000D): The data is
invalid."
However if I try and fax any other document then the routine works fine and
transmitts the fax succesfully. For your info here is my fax routine:

Dim fs As New FAXCOMLib.FaxServerClass
fs.Connect(Environment.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

Because the above fax routine works with all other file types I'm guessing
that I have a problem with my Tiff creation routine (although it does not
generate an error). The routine is as follows:

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

What do I need to do in my creation routine in order to allow the FAXCOMLib
service to recognise the Tiff file as a valid fax and hence get past the
'invalid data' error?

Thanx 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.