I write the program for conversion of .txt and .rtf in to the .pdf files. for this program we
need to create a function of conversion. Otherwise we need to use third party utility and
call the function from it,in our program.
Here i do the same ,i use third party utility in my program.
My project is in VS 2010 window form.let's see the program step by step ,what i do:-
1)Create your own functions(.dll) or download third party dll. and locate in your system folder
C:\Windows\System32.
2)Open your project and right click on project and click on 'Add Reference' form 'Browse'
tab in new dialog box select that(downloaded dll).
3)Drop the one button in your window form,write the code in Click_event.
4)Import that dll in porgram and write the below code:-
5)In this program 'SautinSoft.PdfMetamorphosis' is the third party dll and 'RtfToPdfConvertFile'
function.
Imports Microsoft.VisualBasic
Imports System
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Data
Imports System.IO
Imports System.Windows.Forms.Form
Public Class Form1
Private Sub _Open_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles _Open.Click
InitializeComponent()
Dim openFile As New OpenFileDialog
Dim p As New SautinSoft.PdfMetamorphosis()
openFile.Filter = "All Files (*.*)|*.*"
openFile.ShowDialog()
p.PageStyle.PageOrientation.Landscape()
'specify header in HTML format
p.Header.Html("<b>Sample header in HTML format</b>")
'specify footer in RTF format
p.Footer.Rtf("{\b Bold footer}")
'specify page numbers
p.PageStyle.PageNumFormat = "Page {page} of {numpages}"
If p IsNot Nothing Then
Try
'Dim str As String
TextBox1.Text = openFile.FileName
Dim rtfPath As String = TextBox1.Text
Dim pdfPath As String = "D:\test.pdf"
Dim pdfPath1 As String = "D:\test1.pdf"
p.RtfToPdfConvertStringToFile("hello shiv", pdfPath1)
Dim i As Integer = p.RtfToPdfConvertFile(rtfPath, pdfPath)
If i = 0 Then
System.Diagnostics.Process.Start(pdfPath)
Else
MessageBox.Show("An error occured during converting RTF to PDF!")
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End If
End Sub
End Class