none
Preserve Word line numbers in HTML? RRS feed

  • Question

  • Hi,

    I have a library of word rich text documents (hyperlinks, tables, formatting) that I want to make available for research and comments on the web. The plan is to somehow load the docs (with formatting and line numbers into a database), allow a user to search all docs in the library for a string, then display the selected doc, highlighting the search phrase in context.

    I also want to be able to select a phrase of the current document or even an entire document and be able to add a comment. One person suggested that the solution be built on a blog (BlogEngine.NET),  i.e. each document would be a blog entry and each comment a blog entry and a reference table would show the link. However, examining BlogEngine.NET's SQL Server database, it has no provision for line numbers within it's tables.

    The question is how to retain the rich text and the line numbers (for granular reference) and be able to display it on a web page with the formatting and line numbers. I have VBA code to extract text and line numbers but not formatting, and I want to create the load function in VB.Net.

    Any suggestions?

    Thanks,

    Jnana


    Jnana Sivananda

    Tuesday, June 26, 2012 3:11 AM

Answers

  • Hi Jnana,

    I'm not aware of line number features before. I understand you requirement now.

    You can save the Word document as xps file.  Then given you have installed XPS Viewer on client, you'll be able to view xps in IE. Line numbers and all format are preserved and well displayed in xps.  This is because xps is format that conform to Office Open XML specification.

    XPS Viewer is an OS feature, which you will want to turn on.

    Hope this gets you started.


    Forrest Guo | MSDN Community Support | Feedback to manager

    Friday, June 29, 2012 2:46 AM
    Moderator
  • I'm thinking of a way without using database. You can save the document content and format, and line number to database, but this only increase the complexibility. You may use Word Object model to read the document and get these information. Then retrieve these information and show up them in a web page.  But xps file can host your document with all format and line number, and present in IE very well.

    I mean the xps file appears in a page as whole page, but not to embedded xps in web page. You may show a link to the xps file on a page. The demo looks like below. When you select text, line number will not be selected.

    hope this helps.

    demo image


    Forrest Guo | MSDN Community Support | Feedback to manager


    Friday, June 29, 2012 7:36 AM
    Moderator

All replies

  • Hi Jnana,

    Thank you for posting in the MSDN Forum.

    I'll involve some experts who are familiar with your issue. This may take some time.

    Much appreciate for your patient and understanding.

    Best regards,
    Quist


    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, June 28, 2012 7:01 AM
    Moderator
  • Do you have a mock up image to demo your requirement? Word by default doesn't have line numbers.

    with regards,


    Forrest Guo | MSDN Community Support | Feedback to manager

    Thursday, June 28, 2012 2:30 PM
    Moderator
  • Hi Forest,

    Not sure what you mean by "Word by default doesn't have line numbers." You just turn them on (Page Layout>Line Numbers). See below a Word doc with numbering on. Line numbers are available through Word application routines.

    The desired application should have a means to reference a line on a page in a document. The editorial group for the documents meets on Skype and we need to be "on the same page", so to speak, to read and discuss together. I also want to be able to select a portion of a document, store a comment on the selection and to have a way for the user to link to any comments. I envision a window to the right of the text listing all associated comments by their titles, each with a link to open the comment in a new window.

    Thanks,

    Jnana


    Jnana Sivananda

    Thursday, June 28, 2012 6:42 PM
  • Thank you, Quist.

    -Jnana


    Jnana Sivananda

    Thursday, June 28, 2012 6:43 PM
  • Hi Jnana,

    I'm not aware of line number features before. I understand you requirement now.

    You can save the Word document as xps file.  Then given you have installed XPS Viewer on client, you'll be able to view xps in IE. Line numbers and all format are preserved and well displayed in xps.  This is because xps is format that conform to Office Open XML specification.

    XPS Viewer is an OS feature, which you will want to turn on.

    Hope this gets you started.


    Forrest Guo | MSDN Community Support | Feedback to manager

    Friday, June 29, 2012 2:46 AM
    Moderator
  • Thanks, Forrest.

    However, I don't see how this will allow me to do what I want.  I need to load a database table with rich text a line at a time and have the line number be a separate column from the rich text both in the database and when displayed on the web page. Though the line numbers will be displayed to the left of the text, the line number will not be selected when the text is selected.

    So then the question becomes: What's the best way to read a word doc and store formatting with the text one line at a time and then, when text is retrieved from the database, what's the best way to apply the formatting on the web page?

    Thanks,

    Jnana


    Jnana Sivananda

    Friday, June 29, 2012 5:19 AM
  • I'm thinking of a way without using database. You can save the document content and format, and line number to database, but this only increase the complexibility. You may use Word Object model to read the document and get these information. Then retrieve these information and show up them in a web page.  But xps file can host your document with all format and line number, and present in IE very well.

    I mean the xps file appears in a page as whole page, but not to embedded xps in web page. You may show a link to the xps file on a page. The demo looks like below. When you select text, line number will not be selected.

    hope this helps.

    demo image


    Forrest Guo | MSDN Community Support | Feedback to manager


    Friday, June 29, 2012 7:36 AM
    Moderator
  • Thanks, I'll be using the Word object model and SQL Server.

    -Jnana


    Jnana Sivananda

    Thursday, July 5, 2012 2:17 PM