Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X
Hello
I am looking for a way to access and override the content of headers without starting MathCad. This is required for our document management system - once the file is officially issued the document management system needs to override the date, title, etc.
I do understand that MathCad files are zipped xml's and I could modify the values in the xml file but the header/footer text content does not seem to be available.
Thank you in advanced
Michal
Solved! Go to Solution.
@StuartBruff wrote:
What version of Mathcad did you use? I can't find my text in any of the files.
I am using Prime 11.
The reference to the FlowDocument#.XamlPackage containing the the text of the header resp. footer are in mathcad\_rels\header.xml resp. mathcad\_rels\footer.xml .
In the attached file test.mcdx (when renamed to *.zip) we can find in the file /mathcad/_rels/header.xml with the reference to /mathcad/xaml/FlowDocument4.Xamlpackage
FlowDocument4.Xamlpackage is a zipped file again an when we unpack it we find in /Xaml/Document.xaml the text I used in the header
BTW, I am not sure how to get Notepad++ to display the file contents nicely formatted and not all in one line. Any ideas??
That's tricky!
When you unzip a mcdx file you should see a directory "\mathcad\xaml\". In this directory you should see a couple of files with names "FlowDocument<x>.XamlPackage", where <x> is a number. These again are renamed zip archives!
When you unzip them you should get a directory "Xaml" and the file "Document.xaml" in this directory contains the text of the header resp. footer.
I just created a small test document and here the header text was found in "FlowDocument3.XamlPckage" and the footer text in the file with #4.
The numbers 3 and 4 may vary. They are referenced in "_rels\header.xml" and "_rels\footer.xml".
@Werner_E wrote:
That's tricky!
When you unzip a mcdx file you should see a directory "\mathcad\xaml\". In this directory you should see a couple of files with names "FlowDocument<x>.XamlPackage", where <x> is a number. These again are renamed zip archives!
When you unzip them you should get a directory "Xaml" and the file "Document.xaml" in this directory contains the text of the header resp. footer.
I just created a small test document and here the header text was found in "FlowDocument3.XamlPckage" and the footer text in the file with #4.
The numbers 3 and 4 may vary. They are referenced in "_rels\header.xml" and "_rels\footbleer.xml".
Interesting. I've just created a Mathcad Express 11 worksheet based on the Blank template, adding only a header and footer. The header comprises a math region and the filename. The footer comprises a text region and the <page of pages> data.
I couldn't see the header and footer in _rels, but I did find them in mathcad.
Here are their pretty-printed contents in Notepad++.
Header:
<header xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:ws="http://schemas.mathsoft.com/worksheet50" xmlns:ml="http://schemas.mathsoft.com/math50" xmlns:u="http://schemas.mathsoft.com/units10" xmlns:p="http://schemas.mathsoft.com/provenance10" xmlns="http://schemas.mathsoft.com/worksheet50">
<regions>
<region region-id="0" actualWidth="64.91" actualHeight="25.6" top="9.4488188976377945" left="0">
<math resultRef="0">
<ml:eval>
<ml:apply>
<ml:mult/>
<ml:real>3</ml:real>
<ml:real>3</ml:real>
</ml:apply>
<ml:unitOverride>
<ml:placeholder/>
</ml:unitOverride>
</ml:eval>
</math>
</region>
<region region-id="1" actualWidth="79.266666666666666" actualHeight="17.703333333333333" top="28.346456692913385" left="0">
<fieldText>
<text>
<FlowDocument FontFamily="Tahoma" FontStyle="Normal" FontWeight="Normal" FontSize="14.6666666666667" Foreground="#FF000000" Background="#00FFFFFF" TextAlignment="Left" Typography.Variants="Normal" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<Paragraph>04/10/2025</Paragraph>
</FlowDocument>
</text>
<dateSaved template="dd_mm_yyyy"/>
</fieldText>
</region>
</regions>
</header>
Footer:
<footer xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:ws="http://schemas.mathsoft.com/worksheet50" xmlns:ml="http://schemas.mathsoft.com/math50" xmlns:u="http://schemas.mathsoft.com/units10" xmlns:p="http://schemas.mathsoft.com/provenance10" xmlns="http://schemas.mathsoft.com/worksheet50">
<regions>
<region region-id="2" width="200" actualWidth="200" actualHeight="17.703333333333333" top="9.4488188976377945" left="0">
<text item-idref="R527cf950b05e4154">
<FlowDocument FontFamily="Tahoma" FontStyle="Normal" FontWeight="Normal" FontSize="14.6666666666667" Foreground="#FF000000" Background="#00FFFFFF" TextAlignment="Left" xml:lang="en-gb" Typography.Variants="Normal" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"/>
</text>
</region>
<region region-id="3" actualWidth="322.09333333333336" actualHeight="17.703333333333333" top="18.897637795275589" left="349.6062992125984">
<fieldText>
<text>
<FlowDocument FontFamily="Tahoma" FontStyle="Normal" FontWeight="Normal" FontSize="14.6666666666667" Foreground="#FF000000" Background="#00FFFFFF" TextAlignment="Left" Typography.Variants="Normal" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<Paragraph>blank worksheet with header and footer 01.mcdx</Paragraph>
</FlowDocument>
</text>
<fileName/>
</fieldText>
</region>
<region region-id="4" actualWidth="78.01" actualHeight="17.703333333333333" top="28.346456692913385" left="0">
<fieldText>
<text>
<FlowDocument FontFamily="Tahoma" FontStyle="Normal" FontWeight="Normal" FontSize="14.6666666666667" Foreground="#FF000000" Background="#00FFFFFF" TextAlignment="Left" Typography.Variants="Normal" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<Paragraph>Page 1 of 1</Paragraph>
</FlowDocument>
</text>
<pageNumber template="Page_@PageNo_of_@PagesTotal"/>
</fieldText>
</region>
</regions>
</footer>
The text region in the footer appears to be encoded.
The Mathcad Express 11 worksheet is attached.
Stuart
I created a test sheet, too.
But I used just one custom text region in the header and the footer.
The text I used could not be found anywhere in header.xml or footer.xml but as described rather in the file "Document.xaml" which is inside one of the FlowDocument#.XamlPckage.
What version of Mathcad did you use? I can't find my text in any of the files.
...
Belay that. I just noticed from [Content_Types].xml that the XamlPackage is zipped.
<?xml version="1.0" encoding="utf-8"?>
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
<Default Extension="xml" ContentType="application/vnd.openxmlformats-officedocument.mathprocessingml.mathcad.main+xml"/>
<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>
[>>>>>] <Default Extension="XamlPackage" ContentType="application/zip"/>[<<<<<]
<Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml"/>
<Override PartName="/docProps/app.xml" ContentType="application/mathcad.extended-properties+xml"/>
<Override PartName="/mathcad/settings/presentation.xml" ContentType="application/vnd.openxmlformats-officedocument.mathprocessingml.mathcad.settings.presentation+xml"/>
<Override PartName="/mathcad/settings/calculation.xml" ContentType="application/vnd.openxmlformats-officedocument.mathprocessingml.mathcad.settings.calculation+xml"/>
<Override PartName="/mathcad/result.xml" ContentType="application/vnd.openxmlformats-officedocument.mathprocessingml.mathcad.result+xml"/>
<Override PartName="/mathcad/integration.xml" ContentType="application/vnd.openxmlformats-officedocument.mathprocessingml.mathcad.integration+xml"/>
</Types>
Expanding the XamlPackage yields the Document.xaml content as
<Section xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xml:space="preserve" TextAlignment="Left" LineHeight="Auto"... [Font, Typography & other Settings] >
<Paragraph>
<Run style="Normal">This is the footer</Run>
</Paragraph>
</Section>
Stuart
@StuartBruff wrote:
What version of Mathcad did you use? I can't find my text in any of the files.
I am using Prime 11.
The reference to the FlowDocument#.XamlPackage containing the the text of the header resp. footer are in mathcad\_rels\header.xml resp. mathcad\_rels\footer.xml .
In the attached file test.mcdx (when renamed to *.zip) we can find in the file /mathcad/_rels/header.xml with the reference to /mathcad/xaml/FlowDocument4.Xamlpackage
FlowDocument4.Xamlpackage is a zipped file again an when we unpack it we find in /Xaml/Document.xaml the text I used in the header
BTW, I am not sure how to get Notepad++ to display the file contents nicely formatted and not all in one line. Any ideas??
@StuartBruff wrote:
Hi Werner,Yes, apologies, I missed you mentioning in your first post that the xaml package was zipped (I worked it out independently).
No worries. I seemed to have missed that you already mentioned pretty-print in one of your former posts.
As far as I remember this was the default view in Notepad++ for XML files anyway. I thought that the file format in newer versions of Prime had changed (omitted CRLF). Not sure what happened. I don't think that I had XML Tools installed at those time but it sure could be that i forgot about it and maybe had uninstalled it unintentionally. Thank for reminding me and pushing my nose at XML Tools. Works like a charm.
XML Tools, JSTool and NppExport (to RTF) are pretty(!) useful adjuncts to Mathcad for XML and scripting.
I haven't had a chance to effectively play with Python scripting.
Stuart
Thankyou all for quick reply.
This double zipping of files is exactly what I have been missing.
Much appreciated.
Michal
Hi,
If you are prepared to open a Mathcad template then save as a file you can use the API to open the template set the values at the top of the calculation sheet rather than the header and save with an appropriate filename.
In the footer that shows on every page it is possible to put the path and filename given during save with the API that has the appropriate data in filename.
Cheers
Terry
Hi,
And this is the version I would save as a template with an Excel component cover page.
Cheers
Terry
Thank you for the reply.
I cannot use MathCad from the document manager so direct .xml file modification is the way to go.
Best regards
Michal