|
-
Jan 28th, 2011, 06:46 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] Copy text from a webpage and keep formatting
Hi,
I want to put some kind of text editor on my website which allows the user to manipulate the formatting of text.
I would also like it to be possible for a user to copy/paste text from an existing webpage and it keep the formatting i.e. markup tags, font weight, bullet points.
I just dont know hoe to go about this but the information must be there as when you copy from a web page into ms Word it keeps the format.
-
Jan 28th, 2011, 10:16 AM
#2
Re: Copy text from a webpage and keep formatting
You just need a Rich text editor for your site. A personal favourite of mine is TinyMCE but there are many many more if you google Rich Text Editor or WYSIWYG editor
-
Jan 28th, 2011, 07:15 PM
#3
Re: Copy text from a webpage and keep formatting
I personally like FCKEditor, which has now changed name to just CKEditor.
http://ckeditor.com/
Gary
-
Feb 21st, 2011, 09:40 AM
#4
Thread Starter
Frenzied Member
Re: Copy text from a webpage and keep formatting
Ok I chose to use FreeTextBox which accepts the html fine, now I need to store the contents in a way that will enable me to generate generate a PDF. I need to strip out all the HTML markup that is not required nd then produce a document that keeps has paragraphs, line breaks, bullet points, bold text and headings as originally specified in the html. I have had a look at MigraDoc for creating PDFs but it looks like it is the stripping out of unwanted html and formatting based on kept markup where I am going to struggle. I have considered making a word doc rather than pdf then making the pdf from the word doc, this may allow me to only have to srip out the unwanted html.
I would welcome any suggestions as to how to achieve this.
-
Feb 21st, 2011, 04:47 PM
#5
Re: Copy text from a webpage and keep formatting
Hey,
How about the iTextSharp library:
http://sourceforge.net/projects/itextsharp/
If you search these forums, you will find examples of how to use it.
Why are you stripping out the html? Why not print the HTML directly to the PDF? If you are looking to strip out the HTML, then have a look at the HtmlAgilityPack:
http://htmlagilitypack.codeplex.com/
This should be able to help you.
Gary
-
Feb 21st, 2011, 07:57 PM
#6
Re: Copy text from a webpage and keep formatting
The WebBrowser has a built in mini-editor inside it. It is not as advanced as a full fledged text editor or one of those advanced html editors, but see if it is sufficient for your needs.
Add a WebBrowser control to your form and the following code:
vb.net Code:
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted If WebBrowser1.ReadyState = WebBrowserReadyState.Complete Then WebBrowser1.Document.ExecCommand("EditMode", False, Nothing) End Sub
-
Feb 22nd, 2011, 02:15 AM
#7
Re: Copy text from a webpage and keep formatting
Pradeep,
Let me see if I have this right...
You are suggesting that you use a System.Windows.Forms.WebBrowser control in an ASP.net WebPage to allow the editing of HTML?
Will that even work?!?
Gary
-
Feb 22nd, 2011, 03:17 AM
#8
Re: Copy text from a webpage and keep formatting
My bad... 
I was thinking about VB.NET desktop application while writing that post.
-
Feb 22nd, 2011, 03:22 AM
#9
Re: Copy text from a webpage and keep formatting
 Originally Posted by Pradeep1210
My bad...
I was thinking about VB.NET desktop application while writing that post.
Cool, that is what I thought. Either that, or you were being VERY clever, and I wanted to know more 
Gary
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|