Click here to Skip to main content
16,004,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
from server folder i have images , i need to bind images in word document .and in that file path i am directly given to the image control its thorough an exception "URI file format not supported ." and i am try to given that file path to chrome its preview image ...

What I have tried:

am trying to create .doc file and declare sting builder and append image control and with in source giving an file path url , with in the local its working fine once deployed in server its return "URI file format not supported ".
Posted
Updated 10-May-18 1:37am

When creating Office files from a server, using the OpenXML library is the officially supported scenario by MicroSoft (InterOp is not recommended by them in that scenario).

OpenXML is a fairly obtuse library and not terribly easy to use when you're just getting started with it. There are, however, a large number of samples available on the web. A good place to start is from the official documentation:

How to: Open and add text to a word processing document (Open XML SDK)[^]

How to: Insert a picture into a word processing document (Open XML SDK)[^]
 
Share this answer
 
Adding to solution 1:

I have built a class to do more or less what you describe: custom documents with images. Mine is database driven so DBA's can create documents without learning how to. I happened to use php/javascript, but that's not important.

Here's what is - in terms of being helpful to solving your problem.

Create a very simple document with Word, like "hello world", and save it as XML (one of the options). Now, open this in a text editor and see what's going on.

You do the same with a very simple and small graphic and see how those are stored. I suggest a new document as the editing markup (for undo, etc.) is saved to an extent and will confuse the analysis. Simply change "hello world" to "Hello world" and you'll observe more than just the letter was changed.

All the tags and such, and there are a lot of them, are displayed in a controllable manner. To cheat, I copied the header/footer info to files and insert them appropriately when building the document. Note that the XML generated comes in variants, depending upon the version of Word you have.

You will find these pages are generated very quickly and are usually much smaller than the normal binary format that Word uses for saving files.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900