Skip to content

Instantly share code, notes, and snippets.

@sebastianrothbucher
Last active August 9, 2025 13:25
Show Gist options
  • Select an option

  • Save sebastianrothbucher/9c47d9265254badec9da88efcafee1a0 to your computer and use it in GitHub Desktop.

Select an option

Save sebastianrothbucher/9c47d9265254badec9da88efcafee1a0 to your computer and use it in GitHub Desktop.
Libreoffice odt is a ZIP - i.e. one can read forms - see form fields: content is right there. Better than manual (and better than editing custom doc props); can e.g. create an automator on Mac to xtract. Can also write-protect all but form in doc proprties. Also saves money vis-a-vis dumping it all into ChatGPT/Claude in order to get a table
<?xml version="1.0" encoding="UTF-8"?>
<office:document-content xmlns:css3t="http://www.w3.org/TR/css3-text/" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:rpt="http://openoffice.org/2005/report" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" office:version="1.3">
<office:scripts/>
<office:font-face-decls>
<style:font-face style:name="Arial Unicode MS" svg:font-family="'Arial Unicode MS'" style:font-family-generic="swiss"/>
<style:font-face style:name="Arial Unicode MS1" svg:font-family="'Arial Unicode MS'" style:font-family-generic="system" style:font-pitch="variable"/>
<style:font-face style:name="Liberation Sans" svg:font-family="'Liberation Sans'" style:font-family-generic="swiss" style:font-pitch="variable"/>
<style:font-face style:name="Liberation Serif" svg:font-family="'Liberation Serif'" style:font-family-generic="roman" style:font-pitch="variable"/>
<style:font-face style:name="PingFang SC" svg:font-family="'PingFang SC'" style:font-family-generic="system" style:font-pitch="variable"/>
<style:font-face style:name="Songti SC" svg:font-family="'Songti SC'" style:font-family-generic="system" style:font-pitch="variable"/>
</office:font-face-decls>
<office:automatic-styles>
<style:style style:name="P1" style:family="paragraph" style:parent-style-name="Standard">
<style:text-properties officeooo:rsid="00173684" officeooo:paragraph-rsid="00173684"/>
</style:style>
<style:style style:name="P2" style:family="paragraph" style:parent-style-name="Standard">
<style:text-properties officeooo:rsid="00173684" officeooo:paragraph-rsid="00188bdd"/>
</style:style>
<style:style style:name="P3" style:family="paragraph" style:parent-style-name="Standard">
<style:text-properties officeooo:rsid="00188bdd" officeooo:paragraph-rsid="00188bdd"/>
</style:style>
<style:style style:name="P4" style:family="paragraph">
<style:paragraph-properties fo:text-align="start"/>
</style:style>
<style:style style:name="P5" style:family="paragraph">
<style:paragraph-properties fo:text-align="start"/>
<style:text-properties style:text-line-through-style="none" style:text-line-through-type="none" fo:font-style="normal" style:text-underline-style="none"/>
</style:style>
<style:style style:name="gr1" style:family="graphic">
<style:graphic-properties draw:textarea-vertical-align="middle" style:wrap="run-through" style:number-wrapped-paragraphs="no-limit" style:vertical-pos="from-top" style:horizontal-pos="from-left" style:horizontal-rel="paragraph"/>
</style:style>
<style:style style:name="gr2" style:family="graphic">
<style:graphic-properties style:wrap="run-through" style:number-wrapped-paragraphs="no-limit" style:vertical-pos="from-top" style:horizontal-pos="from-left" style:horizontal-rel="paragraph"/>
</style:style>
</office:automatic-styles>
<office:body>
<office:text>
<office:forms form:automatic-focus="false" form:apply-design-mode="false">
<form:form form:name="Form" form:apply-filter="true" form:command-type="table" form:control-implementation="ooo:com.sun.star.form.component.Form" office:target-frame="">
<form:properties>
<form:property form:property-name="PropertyChangeNotificationEnabled" office:value-type="boolean" office:boolean-value="true"/>
<form:property form:property-name="TargetURL" office:value-type="string" office:string-value=""/>
</form:properties>
<form:text form:name="Text Box 1" form:control-implementation="ooo:com.sun.star.form.component.TextField" xml:id="control1" form:id="control1" form:current-value="Sebastian" form:input-required="false" form:convert-empty-to-null="true">
<form:properties>
<form:property form:property-name="ControlTypeinMSO" office:value-type="float" office:value="0"/>
<form:property form:property-name="DefaultControl" office:value-type="string" office:string-value="com.sun.star.form.control.TextField"/>
<form:property form:property-name="ObjIDinMSO" office:value-type="float" office:value="65535"/>
</form:properties>
</form:text>
<form:text form:name="Text Box 2" form:control-implementation="ooo:com.sun.star.form.component.TextField" xml:id="control2" form:id="control2" form:current-value="[email protected]" form:input-required="false" form:convert-empty-to-null="true">
<form:properties>
<form:property form:property-name="ControlTypeinMSO" office:value-type="float" office:value="0"/>
<form:property form:property-name="DefaultControl" office:value-type="string" office:string-value="com.sun.star.form.control.TextField"/>
<form:property form:property-name="ObjIDinMSO" office:value-type="float" office:value="65535"/>
</form:properties>
</form:text>
<form:checkbox form:name="Check Box 1" form:control-implementation="ooo:com.sun.star.form.component.CheckBox" xml:id="control3" form:id="control3" form:label="Check Box" form:input-required="false" form:current-state="checked" form:image-position="center">
<form:properties>
<form:property form:property-name="ControlTypeinMSO" office:value-type="float" office:value="0"/>
<form:property form:property-name="DefaultControl" office:value-type="string" office:string-value="com.sun.star.form.control.CheckBox"/>
<form:property form:property-name="ObjIDinMSO" office:value-type="float" office:value="65535"/>
<form:property form:property-name="SecondaryRefValue" office:value-type="string" office:string-value=""/>
</form:properties>
</form:checkbox>
<form:checkbox form:name="Check Box 1" form:control-implementation="ooo:com.sun.star.form.component.CheckBox" xml:id="control4" form:id="control4" form:label="Check Box" form:input-required="false" form:image-position="center">
<form:properties>
<form:property form:property-name="ControlTypeinMSO" office:value-type="float" office:value="0"/>
<form:property form:property-name="DefaultControl" office:value-type="string" office:string-value="com.sun.star.form.control.CheckBox"/>
<form:property form:property-name="ObjIDinMSO" office:value-type="float" office:value="65535"/>
<form:property form:property-name="SecondaryRefValue" office:value-type="string" office:string-value=""/>
</form:properties>
</form:checkbox>
</form:form>
</office:forms>
<text:sequence-decls>
<text:sequence-decl text:display-outline-level="0" text:name="Illustration"/>
<text:sequence-decl text:display-outline-level="0" text:name="Table"/>
<text:sequence-decl text:display-outline-level="0" text:name="Text"/>
<text:sequence-decl text:display-outline-level="0" text:name="Drawing"/>
<text:sequence-decl text:display-outline-level="0" text:name="Figure"/>
</text:sequence-decls>
<text:p text:style-name="Standard"/>
<text:p text:style-name="Standard"/>
<text:p text:style-name="P1">Name<text:tab/><text:tab/><draw:control text:anchor-type="as-char" svg:y="-0.517cm" draw:z-index="0" draw:name="Control 2" draw:style-name="gr2" draw:text-style-name="P5" svg:width="4.5cm" svg:height="0.579cm" draw:control="control1"/></text:p>
<text:p text:style-name="P1"/>
<text:p text:style-name="P1">E-Mail<text:tab/><text:tab/><draw:control text:anchor-type="as-char" svg:y="-0.582cm" draw:z-index="1" draw:name="Control 3" draw:style-name="gr2" draw:text-style-name="P5" svg:width="4.56cm" svg:height="0.641cm" draw:control="control2"/></text:p>
<text:p text:style-name="P1"/>
<text:p text:style-name="P2">Subscribe?<text:tab/><draw:control text:anchor-type="as-char" svg:y="-0.584cm" draw:z-index="2" draw:name="Control 1" draw:style-name="gr1" draw:text-style-name="P4" svg:width="0.359cm" svg:height="0.807cm" draw:control="control3"/></text:p>
<text:p text:style-name="P1"/>
<text:p text:style-name="P3">Upgrade?<text:tab/><draw:control text:anchor-type="as-char" svg:y="-0.584cm" draw:z-index="3" draw:name="Control 4" draw:style-name="gr1" draw:text-style-name="P4" svg:width="0.359cm" svg:height="0.807cm" draw:control="control4"/></text:p>
</office:text>
</office:body>
</office:document-content>
#!/bin/bash
mkdir formtest && cd formtest
cp ../formtest.odt formtest.zip
unzip formtest.zip && rm formtest.zip
echo "Name: " $(xpath -q -e "string(//form:text[@form:id='control1']/@form:current-value)" content.xml)
echo "Mail: " $(xpath -q -e "string(//form:text[@form:id='control2']/@form:current-value)" content.xml)
echo "Subscribe: " $(xpath -q -e "string(//form:checkbox[@form:id='control3']/@form:current-state)" content.xml)
# ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment