Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URI for inserting a new image in Word document refers to https instead of http #51

Closed
Tracked by #159
tdceus opened this issue Aug 21, 2020 · 13 comments
Closed
Tracked by #159

Comments

@tdceus
Copy link

tdceus commented Aug 21, 2020

The example "how-to-insert-a-picture-into-a-word-processing-document" contains a namespace error for the URI.

         new A.PresetGeometry(
                                 new A.AdjustValueList()
                             ) { Preset = A.ShapeTypeValues.Rectangle }))
                 ) { Uri = "https://schemas.openxmlformats.org/drawingml/2006/picture" })

must be

         new A.PresetGeometry(
                                 new A.AdjustValueList()
                             ) { Preset = A.ShapeTypeValues.Rectangle }))
                 ) { Uri = "http://schemas.openxmlformats.org/drawingml/2006/picture" })

Then this example will work.

@p-kaczynski
Copy link
Contributor

Sadly haven't noticed this issue, and it took me a while to track the issue I've been having. I have opened #52 with the fix yesterday due to that.

@jwisener
Copy link

jwisener commented Sep 4, 2020

The freaking sample code doesn't work boo! Seems like someone would actually run and make sure it works before posting it as a "Guide" on how to do it.

@lindalu-MSFT
Copy link
Collaborator

Hi I merged this but there's a build error on the docfx.json that I'm trying to figure out. Thanks for catching this.

@shapeh
Copy link

shapeh commented Dec 29, 2020

@tdceus - thank you so much. I have just wasted three hours figuring out what was going on here. The change to http from https worked for me.

@lindalu-MSFT - Another suggestion is to update the sample code in general. Please make it more versatile, and allow for adding several files.

Some issues are not really clear, such as the parameter EditId:

         {
             DistanceFromTop = (UInt32Value)0U,
             DistanceFromBottom = (UInt32Value)0U,
             DistanceFromLeft = (UInt32Value)0U,
             DistanceFromRight = (UInt32Value)0U,
             EditId = "50D07946" // why is this a fixed string / what is the meaning of EditId?
         });

Also:

         new PIC.NonVisualDrawingProperties()
         {
             Id = (UInt32Value)0U, // is this always fixed? What happens when we add more images - do we need to update the Id?
             Name = "New Bitmap Image.jpg"
         },

Next, in the code you reference:

string fileName = @"C:\Users\Public\Documents\MyPic.jpg"; // MyPic.jpg

However, the name in code is still New Bitmap Image.jpg - does it really matter what name you are using?:

           new PIC.NonVisualDrawingProperties()
           {
               // ...
               Name = "New Bitmap Image.jpg"
           },

@sdudnic
Copy link

sdudnic commented Mar 16, 2021

Also please don't hardcode

            // Define the rendered image size
            Size size = new Size(400, 300);

            Int64Value width = size.Width * 9525;
            Int64Value height = size.Height * 9525;
            
            // Define the reference of the image.
            var element =
                 new Drawing(
                     new DW.Inline(
                         new DW.Extent() { Cx = width, Cy = height },

@p-kaczynski
Copy link
Contributor

Now, to be fair, the OOXML is a nightmare and the docs are not enough to deal with it. I have been working with it for a while now and the process looks like follows:

  1. Open MS Word
  2. Write whatever you want to develop
  3. Open in Open XML Productivity Tool
  4. Check how word generated that
  5. Reflect code
  6. Refactor code so it's not a nightmare
  7. Replicate MS Word behaviour

Other docs for the OOXML are actually more useful often - just google (or bing) for the "OOXML " and you will get a decent explanation of what's what.

Also a protip: most wordprocessors that open docx files don't care about it, but MS Word OFTEN CARES about the order of things, so a RunProperties must have RunFonts before Color or else...

@shapeh
Copy link

shapeh commented Mar 16, 2021

@p-kaczynski OOXML is indeed a nightmare. It seems like MS is not really putting too much effort in the documentation. Last comment on this thread is 6~ months old.

@lindalu-MSFT, can you please update us on any status?

@lindalu-MSFT
Copy link
Collaborator

You're correct, we don't have any resources dedicated to monitoring this repo. If you create a PR with your suggested updates, I'll review and merge them in. Today I fixed the build error and did merge some changes including this one to production.

@sdudnic
Copy link

sdudnic commented Mar 17, 2021

@lindalu-MSFT fixed in C#, but not fixed in VB.NET on the article I linked above

@T4ssilo
Copy link

T4ssilo commented Apr 7, 2021

Article https://docs.microsoft.com/en-us/office/open-xml/structure-of-a-spreadsheetml-document contains https schema locations in namespaces, which don't work for me when building a spreadsheet from scratch.

@lindalu-MSFT
Copy link
Collaborator

@T4ssilo you could try reaching out to developers on Stack Overflow and see if anyone can help. Or go to Microsoft Q+A and ask a question there. You have a way better chance of having your questions answered in one of these community forums instead of this repo that currently isn't being monitored. (Except by me, but not in any official capacity! I just like to be sure that customers at least get a response from someone, even if it's "sorry I can't help!")

@mikeebowen
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants