.rtf to pdf

  • Thread starter Thread starter Paulywog0667_Laptop
  • Start date Start date
P

Paulywog0667_Laptop

Guest
Hello,

I'm playing with 3Des, hashes and signatures through a .rtf file. Like in Access lab it opens Word and shows the options for style. I'd like to bypass Word and write the richtextbox data from .rtf to .pdf format. Is there a simple conversion from rtf to pdf? The example uses richtextbox1 in a second form named View_edit. The goal is to have the data decrypt from sql, write to .pdf and dodge prompts when closed.

Imports System.Security.Cryptography
Imports System.IO

Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
Dim inFileName As String = ("C:\temp\RTFDocument1.rtf")
Dim outFileName As String = ("C:\temp\RTFDocument1.rtf")
Dim MyText As String
MyText = " Individual Treatment Plan" + vbCrLf + vbCrLf &
Label1.Text & " " & TextBox1.Text & " " & Label2.Text & " " & TextBox2.Text & " " & Label3.Text & " " & DateTimePicker5.Text & vbCrLf &
Label4.Text & " " & TextBox3.Text & vbCrLf &
Label5.Text & vbCrLf & TextBox4.Text & vbCrLf &
Label6.Text & " " & ComboBox1.Text & vbCrLf &
Label7.Text & " " & ComboBox2.Text & vbCrLf & vbCrLf &
Label11.Text & vbCrLf & vbCrLf &
Label8.Text & vbCrLf & TextBox5.Text & vbCrLf &
Label9.Text & vbCrLf & TextBox6.Text & vbCrLf &
Label10.Text & vbCrLf & TextBox7.Text & vbCrLf
View_edit.RichTextBox1.Text = MyText
MakeBold()
MoreBold()
View_edit.RichTextBox1.SaveFile("C:\temp\RTFDocument1.rtf", RichTextBoxStreamType.RichText)
Dim full_file_name = "C:\temp\RTFDocument1.rtf"
Dim plaintext = My.Computer.FileSystem.ReadAllBytes(full_file_name)
Dim wrapper As New Simple3Des("112913")
Dim ciphertext = wrapper.EncryptData(plaintext)
'write to file
My.Computer.FileSystem.WriteAllText("c:\temp\RTFDocument1.rtf", ciphertext, False)
'Add a varification Hash

'Sign Document to secure 3DES
Dim signer As RSACryptoServiceProvider = New RSACryptoServiceProvider
Dim file As FileStream = New FileStream("C:\temp\RTFDocument1.rtf", FileMode.Open, FileAccess.Read)
Dim reader As BinaryReader = New BinaryReader(file)
Dim data As Byte() = reader.ReadBytes(CType(file.Length, Integer))
file.Close()
Dim Paulywog0667_Laptop As Byte() = signer.SignData(data, New SHA512CryptoServiceProvider)
'step 4// Export the public key
Dim publicKey As String = signer.ToXmlString(False)
My.Computer.FileSystem.WriteAllText("c:\temp\RTFDocument1.rtf", Convert.ToBase64String(Paul_m_Lacher), False)
'MsgBox("Signature: " + Convert.ToBase64String(Paul_m_Lacher))
reader.Close()
'View_edit.Show()
'file.Close()
MsgBox("File Saved")

End Sub

Continue reading...
 
Back
Top