Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

I need help with .Tiff images being to large when saved from my WPF vb.Net

Avatar of mainrotor
mainrotor asked on
.NET ProgrammingVisual Basic.NET* WPF
2 Comments1 Solution64 ViewsLast Modified:
Hi Experts,
I have a WPF application with VB.Net code-behind.

When I save my document as a .tiff file to a directory, then later print the saved document it prints in normal 8 1/2 x 11 (i.e. Letter size).

When I fax that same saved document the one page is jumbo sized and takes up 6 pages.

What am I doing wrong?

Here is my code below:
    Private Sub cmdSave_Click(sender As Object, e As RoutedEventArgs) Handles cmdSave.Click
        If ListToLoadX Is Nothing Then
            MessageBox.Show("There are no image(s) to save.")
            Exit Sub
        End If

            Me.Cursor = Cursors.Wait

            Dim SaveFileDialog = New SaveFileDialog
            SaveFileDialog.Title = "Export Image As..."
            SaveFileDialog.Filter = "Image Files (*.tif)|*.tif"

            Dim ImageArr As New ArrayList

            For Each XYA As ToLoadImages In ListToLoadX

            Dim MasterBitMap As Bitmap = BitMapImage2BitMap(ImageArr.Item(0))
            ExportSaved = ""

            'Select the image encoder
            Dim enc As Encoder = Encoder.SaveFlag
            Dim info As ImageCodecInfo = Nothing
            Dim ice As ImageCodecInfo
            For Each ice In ImageCodecInfo.GetImageEncoders()
                If ice.MimeType = "image/tiff" Then
                    info = ice
                End If
            Next ice
            Dim ep As New EncoderParameters(1)
            ep.Param(0) = New EncoderParameter(enc, CLng(EncoderValue.MultiFrame))
            If SaveFileDialog.ShowDialog Then
                Dim fileName As String = SaveFileDialog.FileName
                MasterBitMap.Save(fileName, info, ep)
                ep.Param(0) = New EncoderParameter(enc, CLng(EncoderValue.FrameDimensionPage))
                'add all images from index 1 to n  
                Dim i As Integer
                For i = 1 To (ImageArr.Count) - 1
                    MasterBitMap.SaveAdd(BitMapImage2BitMap(ImageArr.Item(i)), ep)
                Next i
                ep.Param(0) = New EncoderParameter(enc, CLng(EncoderValue.Flush))

                'Return True
                MsgBox("File was saved successfully.")
                ExportSaved = fileName 'True
            End If

            Me.Cursor = Cursors.Arrow

        Catch ee As System.Exception
            ExportSaved = False
            Me.Cursor = Cursors.Arrow
            Throw New Exception(ee.Message & "Error in saving as multipage")
        End Try
    End Sub
Avatar of Dr. Klahn
Dr. KlahnPrincipal Software Engineer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answers