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

Determine font, font size, bold/italic/underline styles #242

Closed
j-dimension opened this issue Jul 12, 2023 · 2 comments
Closed

Determine font, font size, bold/italic/underline styles #242

j-dimension opened this issue Jul 12, 2023 · 2 comments

Comments

@j-dimension
Copy link

j-dimension commented Jul 12, 2023

Hi,

I am kind of stuck determining the styling of an element. My code looks like this:

            if (childNode.getNodeName().equals("text:p")) {
                    OdfElement odfElement = (OdfElement) childNode;
                    TextPElement pElement = (TextPElement) odfElement;
                    Paragraph newP = targetDoc.addParagraph(pElement.getTextContent());
                
            }

Basically I am browsing a source document and selectively add its content to a target document. I would like to preserve styling - in the example above, I am copying a paragrahs text, and then want to apply the same styling.
However, I have no idea how to determine e.g.

  • font
  • font size
  • bold/italic/underline styles

Could you help pointing in the right direction?

Thanks!

@svanteschubert
Copy link
Contributor

Hi Jens,

It was years ago that I used this functionality, so I looked into our regression tests of ODFDOM.
Starting in those, that have something do to with Style:
https://github.com/tdf/odftoolkit/blob/master/odfdom/src/test/java/org/odftoolkit/odfdom/doc/StyleTest.java#L307
Hope that points you in the right direction!
If you looked in the docu and expected something that was missing, I would be happy if you could fill that gap from what you learned with a PR! :-)

Thanks in adanvce and greetings from Berlin Tegel, Jens, could it be we live just 12km away? ;-)
Svante

@j-dimension
Copy link
Author

Hi Svante,

thanks, very helpful indeed! Should've grepped the tests myself, will do so in the future!

I am actually based 2hrs south of Berlin. Let me know when you're in the area and I will take you on a local micro brewery tour :-D

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

2 participants