Code Monkey home page Code Monkey logo

Comments (13)

PrzemyslawKlys avatar PrzemyslawKlys commented on May 25, 2024 1

Cool :-) Lets see how that WordTextBox goes first

from officeimo.

PrzemyslawKlys avatar PrzemyslawKlys commented on May 25, 2024

Well, how would you do it manually in Word to achieve what you want?

  • Modify margins
  • Add a table with hidden borders?

Both of that you can do. But maybe you are thinking on something else?

from officeimo.

TopperDEL avatar TopperDEL commented on May 25, 2024

In Word I would create a TextField:
image

And then I would place it at a specific location:
image
(Sorry, my Word is german, but I hope you recognize it).

Could this be added?

I'm not sure if a Table would do it, as I need multiple TextFields in e.g. the top region of a page - think of Sender-Address, Receiver-Address, Communication Info etc.

The basic problem is: those text fields need to be separate from the "normal" text run. They have to be at a specific location and should not interfere with the rest of the text.

from officeimo.

PrzemyslawKlys avatar PrzemyslawKlys commented on May 25, 2024

Looks like TextBox is drawing with anchor

image

Relative to a page

image

It's doable, but we need to add new type and all the properties to change different things. Alternate Content Fallback may be harder to do. But we will see.

from officeimo.

TopperDEL avatar TopperDEL commented on May 25, 2024

Is there anything where I can help? Unfortunately I have no clue what needs to be done - but this feature is critical for my app-idea, so I would be very happy to have this included.

Let me know if/how I may help!

from officeimo.

PrzemyslawKlys avatar PrzemyslawKlys commented on May 25, 2024

This looks similar to how you manage Images. So I will use WordImage type as a starting point and will have to create new type WordTextbox type or something similar. Hopefully it will be enough.

We will see from there.

from officeimo.

TopperDEL avatar TopperDEL commented on May 25, 2024

Awesome!

The project I'm working on should get to the market next year. As soon as I earn something with it I will give back to the projects I'm stacking on top like yours is!

from officeimo.

PrzemyslawKlys avatar PrzemyslawKlys commented on May 25, 2024

I got this thing working

internal static void Example_AddingTextbox2(string folderPath, bool openWord) {
    Console.WriteLine("[*] Creating standard document with some textbox");

    var filePath = System.IO.Path.Combine(folderPath, "BasicDocumentWithTextBox3.docx");

    using (WordDocument document = WordDocument.Create(filePath)) {
        var paragraph = document.AddParagraph("Adding paragraph with some text");

        var textBox = document.AddTextBox("My textbox on the left");

        textBox.HorizontalPositionRelativeFrom = HorizontalRelativePositionValues.Page;
        // horizontal alignment overwrites the horizontal position offset so only one will work
        textBox.HorizontalAlignment = HorizontalAlignmentValues.Left;
        textBox.VerticalPositionOffsetCentimeters = 3;

        var textBox2 = document.AddTextBox("My textbox on the right");
        textBox2.HorizontalPositionRelativeFrom = HorizontalRelativePositionValues.Page;
        textBox2.WordParagraph.ParagraphAlignment = JustificationValues.Right;
        // horizontal alignment overwrites the horizontal position offset so only one will work
        textBox2.HorizontalAlignment = HorizontalAlignmentValues.Right;
        textBox2.VerticalPositionOffsetCentimeters = 3;

        Console.WriteLine(textBox.VerticalPositionOffsetCentimeters);

        Console.WriteLine(document.TextBoxes[0].VerticalPositionOffsetCentimeters);

        Console.WriteLine(document.TextBoxes[1].VerticalPositionOffsetCentimeters);

        document.Save(openWord);
    }
}

image

But need to add some tests and probably there will be things that are going to need improvements. Maybe add some styles that are available in Word. Also the object is very complicated so I am not sure if it will survive testing on real world documents created by other people.

from officeimo.

TopperDEL avatar TopperDEL commented on May 25, 2024

Looks awesome! Exactly what I need! Would love to test this out!

from officeimo.

PrzemyslawKlys avatar PrzemyslawKlys commented on May 25, 2024

There is PR linked to this issue. You can play with it

from officeimo.

TopperDEL avatar TopperDEL commented on May 25, 2024

Oh right! Was on my mobile phone and did not realize it. Will try asap!

from officeimo.

TopperDEL avatar TopperDEL commented on May 25, 2024

As mentioned in the PR: it works and is exactly what I need! Would love to see it merged. :)
Thank you!

from officeimo.

PrzemyslawKlys avatar PrzemyslawKlys commented on May 25, 2024

Well that was an easy part. Now the "tests" needs to be done which is less than exciting ;p

from officeimo.

Related Issues (20)

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.