OneNote links between page

P

Piotr Karocki

I'm trying to export OneNote Notebook with all links between pages and
paragraphs working.

To get page content, I use
oONapp.GetPageContent oPage.Attributes.getNamedItem("ID").Text, xmlPage

In it, I get links in form like this:
<a href="onenote:#sakr&amp;section-id={3453F9ED-AC95-4114-B18A-
F376A6D3170B}&amp;page-id={DA363880-D52D-4AB5-A713-AFEA59375B5E}
&amp;object-id={31EA72C6-9DE2-00C3-0291-A1670E1C2892}&amp;AB&amp;base-
path=C:\MyDoc\OneNote\Std\r5s1.one">akcent na dynamiczny</a>

I thought "object-id" in this link is same as "objectID" in
<one:Outline author="pkar" lastModifiedBy="pkar" lastModifiedTime="2013-10-
01T06:07:23.000Z" objectID="{15531D5B-12D5-09EA-101F-1DA482DA012D}{10}
{B0}">
or in
<one:OE creationTime="2013-10-01T06:07:19.000Z" lastModifiedTime="2013-10-
01T06:07:23.000Z" objectID="{15531D5B-12D5-09EA-101F-1DA482DA012D}{11}
{B0}" alignment="left">

but it isn't :(


Someone know how to 'convert' object-id from <a href tag to objectId in
<one:Outline or <one:OE tag?
 
Joined
Nov 5, 2021
Messages
2
Reaction score
0
I'm trying to export OneNote Notebook with all links between pages and
paragraphs working.

To get page content, I use
oONapp.GetPageContent oPage.Attributes.getNamedItem("ID").Text, xmlPage

In it, I get links in form like this:
<a href="onenote:#sakr&amp;section-id={3453F9ED-AC95-4114-B18A-
F376A6D3170B}&amp;page-id={DA363880-D52D-4AB5-A713-AFEA59375B5E}
&amp;object-id={31EA72C6-9DE2-00C3-0291-A1670E1C2892}&amp;AB&amp;base-
path=C:\MyDoc\OneNote\Std\r5s1.one">akcent na dynamiczny</a>

I thought "object-id" in this link is same as "objectID" in
<one:Outline author="pkar" lastModifiedBy="pkar" lastModifiedTime="2013-10-
01T06:07:23.000Z" objectID="{15531D5B-12D5-09EA-101F-1DA482DA012D}{10}
{B0}">
or in
<one:OE creationTime="2013-10-01T06:07:19.000Z" lastModifiedTime="2013-10-
01T06:07:23.000Z" objectID="{15531D5B-12D5-09EA-101F-1DA482DA012D}{11}
{B0}" alignment="left">

but it isn't :(


Someone know how to 'convert' object-id from <a href tag to objectId in
<one:Outline or <one:OE tag?
I would love to know how to do this also. Piotr, if you found the solution for this would you mind passing it on? Thanks!
 
Joined
Nov 5, 2021
Messages
2
Reaction score
0
I finally found a solution, but you basically have to reverse-engineer the link. Anyway, it works! If this looks like something you can use and you need more details let me know.
Here is my code:
private string GetAnchorFromObjectId(Anchor destinationAnchor, string notebookPath)
{
List<Outline> outlines = db.GetOutlines(destinationAnchor.PageId);
foreach (Outline outline in outlines)
{
List<Paragraph> paragraphs = db.GetParagraphs(outline.ObjectId);
foreach (Paragraph paragraph in paragraphs)
{
try
{
onApp.GetHyperlinkToObject(destinationAnchor.PageId, paragraph.ObjectId, out string text);
Anchor parsedAnchor = SplitDestinationHyperlink(text, "", "", notebookPath);
if (destinationAnchor.ObjectId == parsedAnchor.ObjectId)
return text;
}
catch { }
}
}
return null;
}
 
Top