Code Monkey home page Code Monkey logo

Comments (7)

Selmirrrrr avatar Selmirrrrr commented on May 19, 2024 1

Great, thank you very much.

It works, it just has some strange behaviors with headers and footers, but I'll take some time to debug and understand what's going on.

Thanks again for everything :)

from wordroller.

Selmirrrrr avatar Selmirrrrr commented on May 19, 2024

Just for info, for now, I've tried to only retrieve an existing image from a package :

package = Package.Open(memoryStream, FileMode.Open, FileAccess.ReadWrite);
var images= package.GetRelationshipsByType(RelationshipTypes.Image);

And from a Document part :

package = Package.Open(memoryStream, FileMode.Open, FileAccess.ReadWrite);

var officeDocumentRelationship = package.GetRelationshipsByType(RelationshipTypes.OfficeDocument).Single();

DocumentPart = package.GetPart(PackagePartHelper.EnsureCorrectUri(officeDocumentRelationship.TargetUri));
var images = DocumentPart.GetRelationships().Where(r => r.RelationshipType == relationshipType)

But each time this returns nothing even though there's an image in the document I'm processing, and I really don't get why...

from wordroller.

shestakov avatar shestakov commented on May 19, 2024

Hello, @Selmirrrrr, thanks for coming in!

Happy to know the lib adds some value to others, especially if it is a small business.

Image replacement is a crucial feature, indeed.

I hope, I can add the feature this week. Will also investigate retrieving existing images, and get back to you.

from wordroller.

Selmirrrrr avatar Selmirrrrr commented on May 19, 2024

Thank you very much for the quick support. Personally, I don't really need to retrieve images, it was just an entry point to try to implement the replacement.

Btw, if you have a Patreon or a GitHub Sponsor account, I'll be happy to sponsor this feature :)

from wordroller.

shestakov avatar shestakov commented on May 19, 2024

@Selmirrrrr, could you please provide some more specifics on the task you're trying to accomplish?

Problem is, inserting and image in Word is actually two operations: adding a bitmap to a package and inserting [a reference to] the image into one or more places in text as a drawing. The latter implies specifying image output size and other transformations.

This means, that if you just need to replace an image with another one of the same size and position within the document, you just need to replace the bitmap resource behind it.

But if you also need to make some adjustments (like size on the page or alt text), you'll need to change all the drawings referencing the bitmap. In this case I'd suggest to just add the new image, insert it everywhere you need after or before the existing drawings, and then remove the old ones.

from wordroller.

shestakov avatar shestakov commented on May 19, 2024

Btw, if you have a Patreon or a GitHub Sponsor account, I'll be happy to sponsor this feature :)

Thank you very much, I appreciate it! But consider this project company backed.

I could maybe use some support one day, but only in case of adding something really heavy :)

from wordroller.

shestakov avatar shestakov commented on May 19, 2024

@Selmirrrrr, I've just pushed a test demonstrating image replacement.

This test replaces the image file within the document (you can find it if you unzip the .docx file). But it also finds all the drawings with images in the document, so you can make other adjustments and replacements I described above.

from wordroller.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.