|
Hi everybody,
i got a problem. i'm developping an vb.net application. now i want to load a word file into a richtextbox with all the formatting text from word.
Or
how can i load the whole word file into a control in vb.net that can support it?
Thanks for your help.
Marc.
|
|
|
|
|
Try loading an RTF file. That has most of the formatting available in Word, and can be opened by Word, Wordpad, and the RichTextBox control
|
|
|
|
|
marclenoir2005 wrote: now i want to load a word file into a richtextbox with all the formatting text from word.
Generally speaking, not possible. The RichTextBox doesn't support the Word file format. You'd have to save the document in RTF format, then load that version into the RichTextBox. Now, there's another problem. The RichTextBox doesn't support the entire RTF specification. Meaning, while Word will save all the formatting and other goodies in RTF format, the RichTextBox doesn't understand it all and will not render the document properly if the document contains formatting it doesn't support.
|
|
|
|
|
Dave Kreskowiak wrote: The RichTextBox doesn't support the entire RTF specification
That could be a problem. Is there a list anywhere which has more information about this? Some of my coursework uses this setup for convenience, and it's saved using Word, so this could be a possible problem
|
|
|
|
|
Hi,
I don't know any details except this one: I have successfully been creating RTF files programmatically containing tables, which Wordpad can display but not create or drastically edit. And AFAIK Wordpad and the RichTextBox are based on the same basic control.
IMO a WebBrowser can show (not edit) a Word document, just like Internet Explorer can.
|
|
|
|
|
Luc 648011 wrote: IMO a WebBrowser can show (not edit) a Word document, just like Internet Explorer can.
So long as either Word or Word Viewer is installed, this is true. If not, IE can't display the document and you'll get a Save File option for the .DOC file.
|
|
|
|
|
thanks for your help.
I think it is not possible to do this like I want.
Thank you everybody.
|
|
|
|
|
You're very welcome. Always glad to help
|
|
|
|
|
Hey,
Don't give up hope yet, maybe this[^] can help you
Zaegra
Motivation is the key to software development.
|
|
|
|
|
This is really frustrating. I produced some graphs using GDI and vb.net and on the screen they look fine. When you print them off on a black and white printer they look fine BUT on a colour printer the quality is really bad. you can see lines in the colours which is just not acceptable..
I have included the sample code below. I have tried changing to bmp, png etc and it makes not difference.. what am I missing ?.. i can send a copy of the picture produced if anyone can help or you can just copy the code and try running it..
Thanks
Peter
----- Default.aspx
]]>
<title>Untitled Page
----- Default.aspx.vb
Imports System.Configuration
Imports System.Drawing.Printing
Imports System.Drawing
Imports System.Drawing.Imaging
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim brshObj As SolidBrush = New SolidBrush(Color.White)
Dim new_font As New Font("Tahoma", 6)
Dim x, y, i As Integer
Dim MTmonths(12) As String
Dim iloop, rec, lastx, lasty1, lasty2 As Integer
Dim starty, endy, ydiv, stepdiv, yaxis As Double
Dim j
Dim allMonths As String = "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec"
Dim monthNames(12) As String
monthNames = Split(allMonths, ",")
Dim LY_Yield(12) As Double
Dim TY_Yield(12) As Double
Dim TYield As String = "20.42,18,15.6,17.22,17.31,19.14,16.52,18.25,18.52,0,0,0"
Dim LYield As String = "22.16,20.59,16.72,17.3,18.35,18.24,19.24,19.62,17.62,16.56,14.53,16.08"
Dim sTYield(13) As String
Dim sLYield(13) As String
sTYield = Split(TYield, ",")
sLYield = Split(LYield, ",")
For rec = 1 To 12
LY_Yield(rec) = CDbl(sLYield(rec - 1))
TY_Yield(rec) = CDbl(sTYield(rec - 1))
MTmonths(rec) = monthNames(rec - 1)
Next
Dim maxy As Double
Dim miny As Double
Dim m1, m2 As Double
maxy = -9999999
miny = 9999999
For iloop = 1 To 12
m1 = TY_Yield(iloop) : m2 = LY_Yield(iloop)
If m1 <> -9999 And m1 <> 0 Then
If m1 > maxy Then maxy = m1
If m1 < miny Then miny = m1
End If
If m2 <> -9999 And m2 <> 0 Then
If m2 > maxy Then maxy = m2
If m2 < miny Then miny = m2
End If
Next
Dim objBitmap As Bitmap = New Bitmap(340, 230)
Dim objGraphics As Graphics = Graphics.FromImage(objBitmap)
Dim bmpNew As Bitmap = New Bitmap(objBitmap.Width, objBitmap.Height)
'bmpNew.SetResolution(280, 220)
Dim oGraphic As Graphics = Graphics.FromImage(bmpNew)
Dim rectObjB As Rectangle = New Rectangle(-50, -50, objBitmap.Width + 50, objBitmap.Height + 50)
Dim rectObj As Rectangle = New Rectangle(0, 0, objBitmap.Width, objBitmap.Height)
oGraphic.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
oGraphic.FillRectangle(brshObj, rectObj)
Dim pn1 As Pen = New Pen(Color.Red, 1)
Dim pn2 As Pen = New Pen(Color.RoyalBlue, 3)
Dim pnax As Pen = New Pen(Color.Black, 2)
oGraphic.DrawLine(pnax, 20, 210, 340, 210)
oGraphic.DrawLine(pnax, 20, 210, 20, 20)
objBitmap.RotateFlip(RotateFlipType.RotateNoneFlipY)
Dim TextBrsh As Brush = New SolidBrush(Color.Black)
Dim TextFont As New Font("Arial", 8, FontStyle.Regular)
For i = 1 To 12
x = ((i / 12) * 300) - 5
oGraphic.TextRenderingHint = Text.TextRenderingHint.AntiAliasGridFit
oGraphic.DrawString(MTmonths(i), TextFont, TextBrsh, x, 210)
Next
Dim aPoints(11) As Point
Dim bPoints(11) As Point
endy = maxy + (maxy * 20 / 100) : starty = miny - (miny * 20 / 100) : endy = Math.Floor(endy + 0.5) : starty = Math.Floor(starty + 0.5) : stepdiv = Math.Round((endy - starty) / 8, 0)
ydiv = endy - starty
For yaxis = starty To endy Step stepdiv
y = (-1 * ((yaxis - endy) / ydiv * 190))
oGraphic.DrawLine(Pens.Gray, 20, y + 20, 340, y + 20)
oGraphic.TextRenderingHint = Text.TextRenderingHint.AntiAliasGridFit
oGraphic.DrawString(yaxis, TextFont, TextBrsh, 1, y + 10)
Next
i = 1 : j = endy : lastx = 20 : lasty1 = 200 : lasty2 = 200
For iloop = 1 To 12
x = (i / 12) * 300
j = LY_Yield(iloop)
If j <> -9999 Then
y = (-1 * ((j - endy) / ydiv * 190))
Else
y = lasty1
x = lastx
End If
aPoints(i - 1).X = x : aPoints(i - 1).Y = y
lasty1 = y
j = TY_Yield(iloop)
If j <> -9999 Then
y = (-1 * ((j - endy) / ydiv * 190))
Else
y = lasty2
x = lastx
End If
bPoints(i - 1).X = x : bPoints(i - 1).Y = y
lasty2 = y
i = i + 1
lastx = x
Next
oGraphic.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
' new compression technique
Dim Codec, JPEGCodec As System.Drawing.Imaging.ImageCodecInfo
Dim EncParams As System.Drawing.Imaging.EncoderParameters
Dim QualitySetting As Long = 100L
For Each Codec In System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders
If Codec.MimeType = "image/jpeg" Then
JPEGCodec = Codec
Exit For
End If
Next
EncParams = New System.Drawing.Imaging.EncoderParameters(1)
EncParams.Param(0) = New System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Quality, QualitySetting)
'MyImage.Save(ImageFileName, JPEGCodec, EncParams)
'Dim offset As Integer = 1
'Dim segments As Integer = 3
'Dim tension As Single = 0.5F
'oGraphic.DrawCurve(pn1, aPoints, offset, segments, tension)
'oGraphic.DrawCurve(pn2, bPoints, offset, segments, tension)
oGraphic.DrawCurve(pn1, aPoints, 0.5F)
oGraphic.DrawCurve(pn2, bPoints, 0.5F)
objBitmap = bmpNew
objBitmap.Save(Server.MapPath("~/GT1.jpg"), ImageFormat.Jpeg)
objBitmap.Save(Server.MapPath("~/GT2.jpg"), JPEGCodec, EncParams)
objBitmap.Dispose()
End Sub
End Class
|
|
|
|
|
Since you're not doing any printing from your code, the result is going to be up to the printer driver and it's configuration on the client machine.
You're also going to have to show a picture of the result. You can post a link to a pic uploaded to ImageShack or Flickr or any other image hosting service.
Frome what you're describing, it doesn't look like you've got much in the way of options that you have control over.
|
|
|
|
|
thanks for that... are you saying the code looks fine ?
you can find the image at
http://www.flickr.com/photos/31889627@N08/3444828205/
cheers
Peter
|
|
|
|
|
That looks fine to me, except for the text, which is very low-res, but then you have chosen to use only a small bitmap in Bitmap(340, 230)
Images tend to scale rather well, for text having its rendering delayed as much as possible is advantageous, since in the end it is the printer that knows its actual resolution, the available fonts, etc. Rendering the text early on and in a (small) bitmap isn't good for final quality.
|
|
|
|
|
I concur with Luc. This looks fine except if you're sending this size image to a printer, it's going to get scaled up, and with it, the tiniest of flaw (which JPG loves to introduce!), will also get scaled up as well.
|
|
|
|
|
Thanks for the great comments. The reason the graphic is small is that it is on a asp.net local report page which is generated from a sql database and then presented to the user as a pdf page. They then print this page off.
If I was to make the graphic much larger and then scale the image to fit on a web page will that still suffer from the same printer upscaling problem ?
Do you have any other sugestions or should I drop a message to the reporting services section of the forum.
Cheers
Peter
|
|
|
|
|
I would probably make the graph generator able to scale it's own image and code the web page to want an image for "such and such" resolution, and the version that goes in the PDF at a high resolution. Scaling an existing image to do a different job has its problems, both if you scale up and if you scale down. Down doesn't degrade the image as much, but can still introduce "jaggies" and make text look funny.
|
|
|
|
|
Hi,
im using Wshell.Regwrite to write registry(vb script) through html page...
but it works fine only when the option "Initialize and script ActiveX
controls not marked as safe" under Tools\internet
options/Security/Customlevel/ActiveX controls and plugIns ,is set to prompt or enable .....and if we set to any other option ie(disable) it fails ie it shows error like .. "ActiveX component cannot create object "Wscript.shell"...
So May i know whether is it possible to create my own ActiveX control(signed) with certificate so that it doesn"t depend on internet options..
if yes pls let me know how to do the same...
pls correct me if im wrong...
|
|
|
|
|
cross posting is rude. You have posted the same question in web development forum
Yusuf
Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
|
|
|
|
|
Hi,
I have created a dataset and made changes to it....in a for loop
now that dataset has to be updated to the database...
Ramesh Sambari
|
|
|
|
|
Look at point seven of this link. It's in C#, but you can easily run it through an online converter to get bona fide VB.Net code. Additionally, you could look at this, this and this link
|
|
|
|
|
You must use an Update Statement of the Adapter
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
www.ITS.co.za
|
|
|
|
|
hi all,
i am very confused about the relation between Font and character set.
can any body provide some information(or useful link) which can describe the relation between Font and character set.
Actually i want to know that what is role of Font for any character set?
|
|
|
|
|
A character set is a collection of characters which can be used by a particular character encoding, such as ASCII or UTF-8. A font is a complete character set of a single size of a particular typeface
|
|
|
|
|
Computafreak wrote: A font is a complete character set of a single size of a particular typeface
can you explain little more this thing. and what is the typeface
|
|
|
|
|
sunil goyalG wrote: what is the typeface
What the characters look like, usually implementing a common style between all character images.
|
|
|
|
|