I cannot change FontSize when trying to modify text style in docx by using DocumentFormat dll - openxml

I looked at document.xml of my Template. There are "w:sz", "w:szCs", "w:lang", "w:b" inside for "w:p" and "w:r". I opened my doc.docx and only saved using DocumentFormat.dll. I see that appropriate text is in "w:t" element of a "w:r" of a "w:p" element and ect in the output. I see that the "w:r" has "w:rPr" and there are "w:b", "w:rFonts w:ascii w:cs, w:hAnsi" inside of it. "w:p" also has some properties. But "w:sz", "w:szCs" are not present. I tried to create RunStyleProperties and to prepend to an existing paragraph like in "how can I change the font open xml" except i did not create a run, used foreach for existing paragrapths and runs. I tried to recreate methods that are described in "https://learn.microsoft.com/en-us/office/open-xml/how-to-apply-a-style-to-a-paragraph-in-a-word-processing-document",but all my attempts were not effective. The fact is the style was not applied, the text style has some default values.

Related

Microsoft Word: Set default styles

I have created a number of styles that I would like to use for many of my future documents. Thus, I want to create a template or set them as default so that whenever I open Word, they are there. I tried creating a template but my styles are not there. How can I do this?

TYPO3 Mask_Export: Any way I can export my mask elements without deleting the content?

I'm currently working on a TYPO3 Project and used the mask extension for the first time. I created a lot of elements, used them on the site and filled them with content. I just read in the manual that the mask extension itself causes some performance problems which i didn't knew about..
I installed the mask_export extension to prevent those, but now my content is gone.. I tried to just tell my TYPO3 to use the new content element but my contents ist still not displayed in it.
Is there any way I can use the mask_export extension in a running project without deleting my content?
If You use ext:mask_export your defined mask elements are exported in a new extension.
While the elements are exported they were renamed acording to the new extension name.
If you now deactivate mask and enable your new extension, your existing content (tt_content-records) have the wrong CType (there is no rendering definition).
Solution:
Reenable mask, deactivate your new extension and build a test-page with all content elements, then disable mask and enable your extension and build all content elments again (additionally). Now you can do a SQL-query (SELECT CType FROM tt_content WHERE pid=123) to identify the used CTypes and do database wide replacements.
Be aware, that the extension name may be used in other places (e.g. prefix for tables or fields). This needs to be fixed too.
Conclusion:
It's a bad idea to replace mask after content is inserted, as it generates a lot of manual work in the database.

manipulating Microsoft Word DOCX files that have links and track changes using Python

I have been using the excellent python-docx package to read, modify, and write Microsoft Word files. The package supports extracting the text from each paragraph. It also allows accessing a paragraph a "run" at a time, where the run is a set of characters that have the same font information. Unfortunately, when you access a paragraph by runs, you lose the links, because the package does not support links. The package also does not support accessing change tracking information.
My problem is that I need to access change tracking information. Or, more specifically, I need to copy paragraphs that have change tracking indicated from one document to another.
I've tried doing this at the XML level. For example, this code snippet appends the contents of file1.docx to file2.docx:
from docx import Document
doc1 = Document("file1.docx")
doc2 = Document("file2.docx")
doc2.element.body.append(doc1.element.body)
doc2.save("file2-appended.docx")
When I try to open the file on my Mac for complicated files, I get this error:
But if I click OK, the contents are there. The manipulation also works without problem for very simple files.
What am I missing?
The .element attribute is really an "internal" interface and should be named ._element. In most other places I have named it that. What you're getting there is the root element of the document part. You can see what it is by calling:
print(doc2.element.xml)
That element has one and only one w:body element below it, which is what you get when with doc2.element.body (.xml will work on that too, btw, if you want to inspect that element).
What your code is doing is appending one body element at the end of another w:body element and thereby forming invalid XML. The WordprocessingML vocabulary is quite strict about what element can follow another and how many and so forth. The only surprise for me is that it actually sometimes works for you, I take it :)
If you want to manipulate the XML directly, which is what the ._element attribute is there for, you need to do it carefully, in view of the (complex) WordprocessingML XML Schema.
Unlike when you stick to the published API, there's no safety net once ._element (or .element) appears in your code.
Inside the body XML can be relationships to external document parts, like images and hyperlinks. These will only be valid within the document in which they appear. This might explain why some files can be repaired.

Cannot add a third content field

I'm kinda new to typo, so maybe I am just missing something.
I'm trying to add a third content field to Typo3 4.5.
What I've done so far.
Edit my template and added a new block
Added the block via TemplatVoila > Update Mapping > Modify DS / TO with Element Preset "Page-Content Elements [Pos.: 0]
Mapped it to the new block in the template
But I am missing something as the new field isn't showing up in the Page edit screen.
EDIT: I've found the Block in the "Edit page properties" but how to show it on standard edit screen?
Any added content area will appear automatically in your TV-View-module. So if you dont see it in there, then
you may have duplicate fields names
wrong column positions
or the existing template is using a »beLayout«-section, which shows only the first two content areas (see example in reference http://docs.typo3.org/typo3cms/extensions/templavoila/ExtTemplavoila/StaticDataStructures/ExampleForBelayout/Index.html)
The TemplaVoila template is split into TS (TemplaVoilà Template Object) and DS (TemplaVoilà Data Structure) records, may you paste the content of the field „Data Structure XML“ of the DS record here? In there are all necessary information.
The two template files should be located in your general storage folder, your TypoScript root file should be there as well.

OPEN XML add custom not visible data to paragraph/table

Is there a way to store additional data for a paragraph, that would be persisted after user opens and saves a document in MS Word.
Ive been using CusotmXML for this, but it turns out that this is no logner possible due to the fact that MS-Word strips all CusotmXML elements from the document structure.
Every single paragraph or a table has an ID that I would like to "pair back" to my data-source.
So later when I read the docx again I can identify origins of every unchanged paragraph/table in the document.
A possibility would be to insert a SET field. This creates a bookmark in the document to which you can assign information. There's no way to protect it from the user removing it, however. A DATA field might also be a possibility.
Unlike "vanish" (which I believe is equivalent to "hidden" font format) the information would not display if the user is in the habit of displaying non-printing information. It will display, however, if the user toggles on field codes (Alt+F9).
You can have a divId on a paragraph, and in xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" there are attributes w14:textId and w14:paraId.
For example:
<w:p w14:textId="81a184ad" w14:paraId="81a184ad" >
<w:pPr>
<w:divId w:val="124349312"/>
See [MS-Docx] for details.
Alternatively, have a look at content controls, which you can wrap around paragraphs and tables (or put inside them). These have an ID property; they also let you store arbitrary text in their tag property. The string is limited in length to something like 120 chars.
A rather noddy solution, but have you cosidered using a custom run for your data and hiding it from displaying using Vanish
<w:rPr>
<w:vanish />
</w:rPr>
Adding vanish to run properties will hide the run from displaying and you might use this to store custom data with out affecting the output of the document.