I would like to implement WordAddin.
I need to have json list related in my word document.
My functionality search word document and base on some criteria crate json string.
I would like to store this json string in word document and use it later if needed. It would be perfect to easy store and easy get this json.
I want have all data in word document, so separate files or database are not options.
My question is: where to store this json string?
Possible solutions I can see are :
Save on document as text and then hide and protect this text
Save to file and attach this file to word document (protect and hide)
Is there some better place where could I store data like this in word document?
Each Microsoft Word document has metadatas and properties. I would recommend to store your Json into one of these.
Here's some examples on how to do it:
MSDN
Accessing Excel Custom Document Properties programmatically
How do I add custom properties to a Word doc with .NET 4?
Note that properties can be read by the users (if they know what they are searching for).
Related
I would like to store variable data inside of a Visio file similar to how you can in a Word file, but I am unable to find anything similar for Visio. A word example would be:
WordDocument.Variables("myVar").Value = "myVariable";
Alternatively, can you store a file (xml for instance) inside of a Visio file, then read and write to the file at run time?
First option is already voiced by #Jon Fournier. DocumentSheet is a Visio way to store document-specific values. Check out also this article, which gives more details: http://visualsignals.typepad.co.uk/vislog/2011/11/shapes-with-global-values.html
The second option could be Document.SolutionXmlElement, which allows you to store arbitrary XML fragment in Visio file for a document.
https://msdn.microsoft.com/en-us/library/office/aa218416.aspx
Third option could be (note that this is a bit archaic) to create a hidden master and store document data in there (in it's ShapeSheet).
Note that Visio does not support "CustomDocumentProperties" the way some other Office application do. See more information here: https://social.technet.microsoft.com/Forums/office/en-US/85fbc601-1612-4e63-91f4-b900a59109bd/how-to-access-visio-document-properties-builtindocumentproperties-customdocumentproperties-from?forum=visiogeneral
Although there are also some "normal" office document properties which are exposed via API; likte "Title" and "Company" which can be accessed directly as document properties (i.e. "Document.Company"), user custom ole compound document properties not exposed directly and are not available with Visio API. If you are interested in that you might find out this topic useful: http://visguy.com/vgforum/index.php?topic=6535.0
You can use the Document's DocumentSheet, which is a normal shapesheet object, so you can add User cells and store your data there.
I am trying to make a word document in an asp.Net MVC application using OpenXML template document .
The main challenges for me are
How can i create a word document as an OpenXML template? In my word
document i have some paragraphs of texts and in every paragraphs i
have to fill information from data base like in word file there are
instances of text like
etc and these should be filled with actual data. But
i dont know how can i convert a normal word document as a OpenXML
template file .
How can i fill the values with data from db ? If i have a model say WordModel in hand with filled values of properties FirstName TotalAmount AmountUnit TotalCopies etc then how can i fill the details to template and allow user to download the file ?
What you want to do is called Mail Merge and means populating word documents that act as templates with your application data. There are some existing (commercial) solutions out there, but if you want to do it yourself using Open XML SDK, you need to set up some kind of tagging mechanism that you will use to tag certain parts of document where you want the data/text from the database should be placed. For Word documents you have the following options: Bookmarks, Content Controls, Merge Fields, or special text (<% FirstName %>). I would personally go with Content Controls as they offer the best user experience and they are pretty easy to parse and replace. So the templates would be ordinary word documents containing these tags and then you could use Open XML SDK to parse these templates, search the tags in them and replace them with your application data according to the tag's name/code/title. This a very abstract, high level picture of a mail merge processor. Of course system like this is not easy to implement and also note that using Open XML requires some learning. There was a similar question answered, but you can probably find many more - just google.
Trying to learn how to use OOXML to replace tokens win a word document by following this tutorial
Everything has been going pretty well until I hit this
Next, create the custom XML file containing the data for this document, and store it in the package.
Store the custom XML in memory and add placeholders for the actual data.
I'm having trouble discerning where to store the custom XML and what he means by storing it in memory.
The author also continues to refer to the file as package, so does that mean I should keep the word Template in .zip format?
Next, create the custom XML file containing the data for this document, and store it in the package.
In context, I would suggest the package is the file containing the xml data, which when you load it or display it becomes a document.
Storing it in memory, means loading an object with the data(i.e. xmldocument)
I have a .doc document. In this document i have some blanks for data. For example:
"car_id" is the best car in "car_country".
I need to open this doc file and change this blanks ("car_id", "car_country") to data from some object.
How to do this?
I would use DocumentFormat.OpenXml.dll. You can find it here. OpenXMLSDKv2.msi will add assembly. You will just need to add reference to DocumentFormat.OpenXml. And the OpenXMLSDKTool.msi will install a usefull tool that will display xml structure of .docx (for example) document.
This web page has some very good samples of Word automation using C#. Specifically, look at section 6 in the web page for a Mail Merge example.
http://www.c-sharpcorner.com/UploadFile/amrish_deep/WordAutomation05102007223934PM/WordAutomation.aspx
I'm using Lucene.Net to create a website to search books, articles, etc, stored as PDFs. I need to be able to filter my search results based on author name, for example. Can this be done with just Lucene? Or do I need a DB to store the filter fields for each document?
Also, what's the best way to index my documents? I'll have about 50 documents to start with and periodically I'll have to add a bunch of documents to the index--may be through a web form. Should I use a DB to store the document paths?
Thanks.
Here is a list of what you need to do IMO:
Extract raw text from PDF - please see this question which recommends iTextSharp for this purpose.
For each PDF document, create a Lucene.net document that has several fields: author, title, document text and whatever you want to search. It is recommended to also have a unique id field per document. I suggest you also store a field with the path to the original PDF document.
After indexing all the documents, you will have a Lucene index you can search by fields.
You can add new documents by repeating step 2. It is easier to do this offline - incremental updates are tough.
Lucene has a couple of different Analyzers that can scrub out the noise and do "stemming" which is helpful when you want to do fulltext searching, but you're still going to need to store the PDF itself somewhere. Lucene.Net is happy to build an index on the file system, and you could add a field to the Document it builds called something like "PATH" with the path to the document.