neslihan 0 Newbie Poster

printing RTF document in VB was OK. After converting to VB.NET, the RTF file being printed is placed wrongly on the paper and there is next page problem
the code is like that
Public Function Yaz(ByRef argFileName As String, ByRef argValues As Dictionary(Of String, String), Optional ByRef argPreview As Boolean = True, Optional ByRef argFormCaption As String = "Yazdırma Ekranı", Optional ByRef argDeviceName As String = "", Optional ByRef argReadOnly As Boolean = False) As Boolean
Dim lcRTFText As String
Dim lcTextFile As Boolean
Dim lcPrinter As String

Yaz = False

Try
mErrorCode = 0
mReason = ""
'ali-
mPrinted = False

If Not argDeviceName = String.Empty Then
mPreviewForm.PrintDocument1.PrinterSettings.PrinterName = String.Empty
End If

If Not argDeviceName = String.Empty Then
For Each lcPrinter In PrinterSettings.InstalledPrinters
If lcPrinter.ToLower = argDeviceName.ToLower Or _
lcPrinter.ToLower.IndexOf(argDeviceName.ToLower) > 0 Then
mPreviewForm.PrintDocument1.PrinterSettings.PrinterName = lcPrinter
Exit For
End If
Next
End If

If mPreviewForm.PrintDocument1.PrinterSettings.PrinterName = String.Empty Then
mErrorCode = -2
mReason = "Uygun yazıcı bulunamadı! (Aranılan Yazıcı Adı = " + argDeviceName + ")" + Environment.NewLine + "Lütfen yazıcınızı kontrol edip tekrar deneyiniz..."
Exit Function
End If

lcTextFile = argFileName.Substring(argFileName.Length - 3, 3).ToLower = "log" Or argFileName.Substring(argFileName.Length - 3, 3).ToLower = "txt"
If File.Exists(argFileName) Then
lcRTFText = File.ReadAllText(argFileName) 'open rtf file
Else
lcRTFText = File.ReadAllText(argFileName.Substring(0, argFileName.Length - 3) & "txt")
End If

If lcTextFile Then
lcRTFText = mConvertKeys(lcRTFText, argValues, False) 'convert
If argPreview Then
'ali-
If argReadOnly Then
mPreviewForm.cmdPrint.Enabled = False
Else
mPreviewForm.cmdPrint.Enabled = True
End If
'form gösterilecek
mPreviewForm.Text = argFormCaption
mPreviewForm.rtxt.Rtf = lcRTFText
mPreviewForm.ShowDialog()
Else
mPreviewForm.rtxt.Rtf = lcRTFText
mPreviewForm.PrintDocument1.Print()
End If
Else
mFontOnEk = mFind_FontOnek(lcRTFText) 'font oneklerini bulur
lcRTFText = mConvertKeys(lcRTFText, argValues) 'convert
If argPreview Then
'ali-
If argReadOnly Then
mPreviewForm.cmdPrint.Enabled = False
Else
mPreviewForm.cmdPrint.Enabled = True
End If
'form gösterilecek
mPreviewForm.Text = argFormCaption
mPreviewForm.rtxt.Rtf = lcRTFText
mPreviewForm.ShowDialog()
Else
mPreviewForm.rtxt.Rtf = lcRTFText
mPreviewForm.PrintDocument1.Print()
End If

End If

Yaz = True

Catch ex As Exception
mErrorCode = -1
mReason = ex.Message()
End Try
End Function

help me !!!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.