Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7047095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:43:45+00:00 2026-05-28T02:43:45+00:00

Background My project is urgent and requires that I iterate a large XML file

  • 0

Background

My project is urgent and requires that I iterate a large XML file and return Base64 encoded images.

Each image must be inserted into an MS Word doc, and I am using the DocX library for that.

I am converting the Base64 strings to bitmap with no problem.

Problem

For the life of me, I can’t seem to get the bitmaps into a Novacode.Image object which can then be inserted to the document. NOTE: I already know how to convert to System.Drawing.Image format. It is Novacode.Image format (DocX) that is giving me grief.

If I try to convert a la (Novacode.Image)somebitmap; I get Can not cast expression of type Image to Bitmap. If I try to initialize a new Novacode.Image object I get Can not access internal constructor Image here.

Using C#, .NET 4, Forms App, lots of coffee.

Question

Only Novacode.Image objects can be inserted into the MS Word doc via the library, so how the heck do I get my bitmap in there??

I am bleary-eyed at this point so perhaps I am just missing something simple.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:43:46+00:00Added an answer on May 28, 2026 at 2:43 am

    You have to use the DocX.AddImage() method to create a Novacode.Image object.

    Follow these 5 steps to add a image to a word document:

    1. Save your picture into a memory stream.
    2. Create the Novacode.Image object by calling AddImage() method.
    3. Create a picture by calling CreatePicture() on the Novacode.Image object created in step 2.
    4. Set the shape of the picture (if needed).
    5. Insert your picture into a pragraph.

    The sample below shows how to insert a image into a word document:

    using (DocX doc = DocX.Create(@"Example.docx"))
    {
      using (MemoryStream ms = new MemoryStream())
      {
        System.Drawing.Image myImg = System.Drawing.Image.FromFile(@"test.jpg");
    
        myImg.Save(ms, myImg.RawFormat);  // Save your picture in a memory stream.
        ms.Seek(0, SeekOrigin.Begin);                    
    
        Novacode.Image img = doc.AddImage(ms); // Create image.
    
        Paragraph p = doc.InsertParagraph("Hello", false);
    
        Picture pic1 = img.CreatePicture();     // Create picture.
        pic1.SetPictureShape(BasicShapes.cube); // Set picture shape (if needed)
    
        p.InsertPicture(pic1, 0); // Insert picture into paragraph.
    
        doc.Save();
      }
    }
    

    Hope, this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After upgrading a project from Flex4 Beta1 to Beta2, I've found that the background-image
Background: In our project, we have a bunch of xml files that define tests
Background A project installs some files that contain all the elements to define a
My project requires a background thread to initiate the creation of a WPF control
Background : I have a asp.net webapplication project that should contain a public and
Background I'm adding some features to a project that uses subversion - I'm using
Background: Got a C# project which involves a block of javascript that gets programmatically
Background I have a PDF file located (under my Project) in an Assets >
I recently started a project were I wanted the background image to scale to
I have a project which downloads images in background using NSOperationQueue . It was

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.