Bug 150164 - PDF exporter's "Export outlines as named destinations" does not export outlines, but bookmarks
Summary: PDF exporter's "Export outlines as named destinations" does not export outlin...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Printing and PDF export (show other bugs)
Version:
(earliest affected)
7.3.4.2 release
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard: target:7.6.0
Keywords:
Depends on: Clarify-Chapter-Heading-Outline-Level
Blocks: PDF-Export-Options-Dialog
  Show dependency treegraph
 
Reported: 2022-07-27 09:21 UTC by gabriel.crabbe
Modified: 2023-03-05 12:07 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Writer document with six headings and two bookmarks (53.93 KB, application/vnd.oasis.opendocument.text)
2022-07-27 09:21 UTC, gabriel.crabbe
Details
PDF export of the example Writer document (32.47 KB, application/pdf)
2022-07-27 09:23 UTC, gabriel.crabbe
Details
Screenshot (298.71 KB, image/jpeg)
2022-08-04 14:52 UTC, Dieter
Details
headings_vs_bookmarks (320.26 KB, image/png)
2022-08-06 18:32 UTC, gabriel.crabbe
Details

Note You need to log in before you can comment on or make changes to this bug.
Description gabriel.crabbe 2022-07-27 09:21:45 UTC
Created attachment 181433 [details]
Writer document with six headings and two bookmarks

The PDF Reference version 1.6, section 8.2.2, defines "Outline" as:

The outline consists of a tree-structured hierarchy of outline items (sometimes called bookmarks), which serve as a visual table of contents to display the document’s structure to the user.

In other words, what LibreOffice calls "Headings" in the Navigator pane and the Insert > Cross-reference menu are officially called "Outline items" (although "Bookmarks" is also recognized) by the PDF standard.

These "Bookmarks" should not be confused with what LibreOffice calls "Bookmarks" in the Navigator pane and the Insert > Cross-reference menu, which are named references to arbitrary text segments and have no concept of hierarchy.

Given the above, I would expect the PDF exporter's "Export outlines as named destinations" to export LibreOffice's "Headings" as named destinations. Instead, it exports LibreOffice's "Bookmarks".

The attached lorem_ipsum.odt has a total of six "Headings" and two "Bookmarks". Running Poppler's pdfinfo utility on the exported lorem_ipsum.pdf produces the following output:

$ pdfinfo -dests lorem_ipsum.pdf 
Page  Destination                 Name
   1 [ XYZ   92  736 null      ] "Dolor2520sit2520amet"
   2 [ XYZ   92  627 null      ] "Sodales2520posuere2520metus2520id"

To the best of my knowledge, there is no way to export LibreOffice's "Headings" as named destinations without manually creating a "Bookmark" for each "Heading".

Thus, the option should be renamed to something in the vein of "Export bookmarks as named destinations". Whether a separate "Export headings as named destinations" option should be implemented is, I believe, matter for another ticket.
Comment 1 gabriel.crabbe 2022-07-27 09:23:13 UTC
Created attachment 181434 [details]
PDF export of the example Writer document
Comment 2 Dieter 2022-08-04 14:52:57 UTC
Created attachment 181586 [details]
Screenshot

I can't confirm the problem. Even if I open your document shows the outline (see attachment).

Which PDF Viewer do you use? I'vee tested with Adobe Acrobat Reader.

Version: 7.3.5.2 (x64) / LibreOffice Community
Build ID: 184fe81b8c8c30d8b5082578aee2fed2ea847c01
CPU threads: 4; OS: Windows 10.0 Build 19044; UI render: Skia/Raster; VCL: win
Locale: de-DE (de_DE); UI: en-GB
Calc: CL
Comment 3 gabriel.crabbe 2022-08-06 18:32:08 UTC
I’m afraid there’s been a misunderstanding. I have no issues with the outline. I’m talking about named destinations, which are an entirely different thing.

Named destinations are what allows your browser to point to a specific section of the PDF, such as in:

$ firefox lorem_ipsum.pdf#Sodales2520posuere2520metus2520id

I don't think there's a way to view named destinations with Acrobat Reader.

In LibreOffice Writer, the exporter option “Export outline as named destinations” generates named destinations from the document's “Bookmarks” (c.f. screenshot), not from its “Headings”. 

This is why I consider the option to be misleading, as it's not exporting an "outline" (which LibreOffice calls "headings"), as its name implies, but what LibreOffice calls "bookmarks".
Comment 4 gabriel.crabbe 2022-08-06 18:32:57 UTC
Created attachment 181643 [details]
headings_vs_bookmarks
Comment 5 Buovjaga 2023-01-25 14:43:11 UTC
Miklós thinks this is reasonable, so setting to NEW
Comment 6 sdc.blanco 2023-02-16 23:00:48 UTC
@Gabriel Crabbe - thanks for your report.  I might be able to address your request, but first I want to check a few details with you.

1. Just to be sure:  the place where you want a change is found by:

File > Export as > Export as PDF > Links tab

and on the tab:  [] "Export outlines as named destinations"

2. The patch should change the word "outlines" in that label to "bookmarks"

3.  There is an extended tip for this control.  If you do not have extended tips enabled, then press Shift+F1 (the mouse cursor gets a question mark beside it), and hover over the line with the checkbox.

You seem to have a solid understanding of these issues.  Maybe you can evaluate if that tip is accurate.  The tip appears to say that bookmarks are exported, but I could not decide if the description there corresponds to the explanation you have given here.

4. Similarly, could you kindly look at the help page for this control:

https://help.libreoffice.org/7.6/en-US/text/shared/01/ref_pdf_export_links.html

I will be happy to make corrections if specific changes can be identified.

Will set Status as NEEDINFO.  After answering these questions, then you can change Status back to NEW.  Thanks.
Comment 7 sdc.blanco 2023-02-16 23:25:58 UTC
The issue of "named destinations" was raised in bug 104804.
The control label was changed from "bookmarks" to "outline" in bug 133403.

Will leave the question to @Dieter as to whether to reopen bug 133403 and/or mark this ticket as DUP of one of the previous bugs.
Comment 8 sdc.blanco 2023-02-17 12:35:23 UTC
I believe gabriel.crabbe has correctly identified a problem with the label, which was changed incorrectly in commit c42dc1be0c3161e621ed0a667ae6b047f8bb23d4.

Here is a patch to revert back to the correct label.
https://gerrit.libreoffice.org/c/core/+/147133

But before submitting the patch, I hope it will be possible to confirm (or correct) the extended tip for this control, which currently says:

   Enable the checkbox to export the names of objects in your document as valid 
   bookmark targets. This allows you to link to those objects by name from other 
   documents.

@gabriel.crabbe -- if this tip is correct, then the value of the "name" property for Frames, Images, Tables, OLE Objects will also be exported as named destinations, in addition to (LO) Bookmarks.
Comment 9 gabriel.crabbe 2023-02-18 22:09:58 UTC
> 1. Just to be sure:  the place where you want a change is found by:
> 
> File > Export as > Export as PDF > Links tab
> 
> and on the tab:  [] "Export outlines as named destinations"

Correct.

> 2. The patch should change the word "outlines" in that label to "bookmarks"

Correct.

> 3.  There is an extended tip for this control.  If you do not have extended tips > enabled, then press Shift+F1 (the mouse cursor gets a question mark beside it), > and hover over the line with the checkbox.

My understanding is that the tip is inaccurate. The phrasing "names of objects" is overly broad: only LibreOffice bookmarks are exported (just tested with LibreOffice 7.5.0). Moreover, they are not exported as "valid bookmark targets" (presumably PDF bookmarks, which is incorrect), but as "named destinations".

> 4. Similarly, could you kindly look at the help page for this control:

In addition to the inaccuracies reported above, the sentence "The bookmarks [...] in PDF files can be defined as rectangular areas." is incorrect. PDF bookmarks are another name for outline items. Even substituting "named destinations" for "bookmarks" does not fix the inaccuracy, as neither are "rectangular areas".

The PDF Reference version 1.6, section 8.2.1, defines "destination" as:

  A destination defines a particular view of a document, consisting of the
  following items:
  • The page of the document to be displayed
  • The location of the document window on that page
  • The magnification (zoom) factor to use when displaying the page

Of which "named destinations" are destinations referenced by a string (their name).

I do not think it's useful to delve down into the specifics of what is a named destination, however, which is why I propose the following text for both the extended tip and the help page:

  Enable the checkbox to export the bookmarks (targets of references) in your
  document as PDF named destinations. This allows you to create links to
  specific locations in your document.

I've also taken the liberty to revert @Buovjaga's edit, as it adds to the confusion between a mislabeled "bookmark export" feature (this issue) and an "outline export" new feature (hypothetical new issue).
Comment 10 sdc.blanco 2023-02-19 02:20:30 UTC
(In reply to gabriel.crabbe from comment #9)
Many thanks for helpful detailed answers.

> I propose the following text for both the extended tip and the help page:
Excellent proposal. 

>   Enable the checkbox to export the bookmarks (targets of references) in your
>   document as PDF named destinations. This allows you to create links to
>   specific locations in your document.
Three followup questions.

1. The first sentence ends with "PDF named destinations", which makes me wonder if the checkbox label should be:  

   [] Export bookmarks as PDF named destinations

not:

   [] Export bookmarks as named destinations

Do you have any intuition/opinion about which might be a preferred choice?
For example, would the first be less ambiguous than the second?

2.  First sentence: Is "targets of references" needed?  

seems like it is included as a way to explain what "bookmarks" means -- but if that is the reason, it does not seem like a good use of extended tip.

3. Alternative proposal for second sentence: 

"You can then create URL links to these locations in the PDF document."

(reasons can be supplied)



> I've also taken the liberty ...
You are welcome to change the summary, but nothing appears to have changed.

> an "outline export" new feature (hypothetical new issue).
If you think the idea deserves consideration, then please file a new bug report.
Comment 11 sdc.blanco 2023-02-19 02:39:08 UTC
(In reply to gabriel.crabbe from comment #9)
> The phrasing "names of objects" is overly broad: only LibreOffice bookmarks 
> are exported (just tested with LibreOffice 7.5.0). 
This phrase appears in the following sentence in the help page [1].

"Enable the checkbox to export the names of objects in your document as valid bookmark targets."

This raises the following question -- which I will ask to UXEval --

Is the intended behavior of this option:
(a) to only export LO bookmarks, or 
(b) should "names of objects" be interpreted as referring to the "Name" property of images, tables, frames, and OLE objects, which could plausibly be exported as named destinations.

If (a), then the needed corrections are being addressed here.
If (b), then (maybe) a bug report must be filed.


[1] https://help.libreoffice.org/7.6/en-US/text/shared/01/ref_pdf_export_links.html
Comment 12 gabriel.crabbe 2023-02-19 14:51:58 UTC
> Do you have any intuition/opinion about which might be a preferred choice?
> For example, would the first be less ambiguous than the second?

It's always hard to opine on how something might be perceived by someone unfamiliar with the subject matter (https://xkcd.com/2501/ comes to mind). That said, my impression is that "named destinations" is unambiguous enough by itself.

To make it clear that the "PDF" is not disambiguating "named destinations", but simply being explicit for maximum clarity (as tips are ought to do), one could rephrase it as: 

  Enable the checkbox to export the bookmarks (targets of references) in your
  document as named destinations in the PDF.

> seems like it is included as a way to explain what "bookmarks" means -- but if
> that is the reason, it does not seem like a good use of extended tip.

My main concern was to disambiguate the term "bookmarks". I actually looked for a definition that I could reuse in the "Insert Bookmark" help page (https://help.libreoffice.org/7.5/en-US/text/swriter/01/04040000.html), but could not find any.

I understand your reticence to define the term here, especially since it doesn't seem to be defined anywhere else. Maybe "the bookmarks (not to be confused with the headings)" as an explicit disambiguation? Another possibility would be to only include the parentheticals (either one) in the help page but not the tip.

> "You can then create URL links to these locations in the PDF document."

This is indeed more explicit. Perhaps even:

  This allows you to link to the corresponding locations in the PDF through an
  URL.

Putting it all together, I get:

  Enable the checkbox to export the bookmarks (not to be confused with the
  headings) in your document as named destinations in the PDF. This allows you
  to link to the corresponding locations in the PDF through an URL.

> You are welcome to change the summary, but nothing appears to have changed.

I changed the title from "PDF exporter's "Export outlines as named destinations" should export outlines, not bookmarks" back to "PDF exporter's "Export outlines as named destinations" does not export outlines, but bookmarks". Is the change not visible to you?

> If you think the idea deserves consideration, then please file a new bug report.

I think it does, and it is my intention to do so as soon as this issue is resolved. That way, I'm hoping to avoid most of the confusion surrounding the term "bookmarks".

> Is the intended behavior of this option:
> (a) to only export LO bookmarks, or 
> (b) should "names of objects" be interpreted as referring to the "Name"
> property of images, tables, frames, and OLE objects, which could plausibly be
> exported as named destinations.

If it turns out that (b) is the desired behavior, I would advise to split it into its own checkbox (i.e. make it a new feature, like the aforementioned "export outlines") and keep the current behavior.

The reason for my concern is that, as I understand it, these names live in different namespaces, which is not the case for named destinations. Therefore, bookmarks with the same name as another object might have their named destinations renamed, breaking existing references. The user should then be given the option not to export unneeded destinations, hence the additional checkbox.
Comment 13 sdc.blanco 2023-02-19 19:36:05 UTC
(In reply to gabriel.crabbe from comment #12)
> hard to opine .... my impression is that "named destinations" is 
> unambiguous enough by itself.
Nice cartoon. As one who is unfamiliar with the subject matter, I would assume – from the label and from knowing that I am exporting to a PDF document – that named destinations will be in the PDF document.  Given that "PDF" does not disambiguate a likely confusion =>

Will not add "PDF" to the label. 

> could not find any [definition of bookmark]
Neither could I. Now bug 153739.

> Putting it all together, I get:
Thanks again for useful proposal, which inspires the following extended tip proposal.

     Enable the checkbox to export bookmarks in your document as named 
     destinations in the PDF document. The destinations correspond to the 
     location of your bookmarks. Use these destinations to create URL links 
     that point to these locations in the PDF document.

If there is evidence (e.g., from bug reports or AskLibre) of confusion (e.g., about bookmarks vs. headings), then a "note" can be added on the help page.

> Is the change not visible to you?
My mistake. It is ok.
Comment 14 Heiko Tietze 2023-02-21 12:16:50 UTC
(In reply to sdc.blanco from comment #11)
> Is the intended behavior of this option:
> (a) to only export LO bookmarks, or 
> (b) should "names of objects" be interpreted as referring to the "Name"
> property of images, tables, frames, and OLE objects, which could plausibly
> be exported as named destinations.

Internally the option is defined at [1] with the description 
"Specifies that the target documents with .od[tpgs] extension, will have that extension changed to .pdf when the link is exported to PDF. The source document remains untouched."

Looking into the implementation [2] it seems to replace the od* extension into pdf.

[1] officecfg/registry/schema/org/openoffice/Office/Common.xcs 
[2] https://opengrok.libreoffice.org/xref/core/vcl/source/gdi/pdfwriter_impl.cxx?r=182e85ae#3655
Comment 15 sdc.blanco 2023-02-21 13:50:29 UTC
(In reply to Heiko Tietze from comment #14)
> Internally the option is defined at [1] 
But the relevant description appears just after the one you copied. 
It should be:

Specifies that the bookmarks contained in the source
OpenOffice.org file should be exported to the PDF file as Named
Destination (see PDF 1.4 section 8.2.1).
 
[1] https://opengrok.libreoffice.org/xref/core/officecfg/registry/schema/org/openoffice/Office/Common.xcs?r=f7c03364#5535

Less success trying to track down how it is implemented (and it is tricky because "bookmarks" are also mentioned in the source code in relation to what is now relabeled as "outline" on the General tab of PDFexport). 

But from my wandering around the source code, I get the impression that only bookmarks are exported with this option. "objects" are also mentioned in the source code, but it appears to be some PDF terminology that has crept into the help page, and does not refer the usual meaning of objects in LO.

I will now proceed with the assumption that only LO bookmarks are exported, and modify the help/tooltip accordingly.
Comment 16 Commit Notification 2023-02-21 14:16:03 UTC
Seth Chaiklin committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/0020562f55401bde7a497be8dbfdefdf138a06ca

tdf#150164  PDF exports bookmarks as named destinations

It will be available in 7.6.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 17 Commit Notification 2023-02-21 14:30:06 UTC
Seth Chaiklin committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/help/commit/3f7b5afe0b04aabf7d1fb26b9c825def3123506e

tdf#150164  corrections to "Export bookmarks as named destinations"
Comment 18 sdc.blanco 2023-02-21 14:33:01 UTC
Closing as FIXED.  Any followups about tooltip/help page for this control can be sent here.  Many thanks to Gabriel for technical guidance.
Comment 19 sdc.blanco 2023-02-27 23:16:33 UTC
From exploring how LO hyperlinks are exported (in connection with bug 104804, comment 25), I examined the entire help page for the Links tab [1] and noticed that the first sentence is:

"Specify how to export outlines and hyperlinks in your document."

I believe "outlines" -> "bookmarks" is needed, plus mention of document references, so the complete revised sentence should be:

"Specify how to export outlines, document references and hyperlinks in your document."

Will link the patch with this ticket, which was concerned about "outlines" -> "bookmarks". 


[1] https://help.libreoffice.org/7.6/en-US/text/shared/01/ref_pdf_export_links.html
Comment 20 Commit Notification 2023-02-28 00:54:24 UTC
Seth Chaiklin committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/help/commit/2e037f2dbf9c7d93ce020ca1709c581624c75fbd

tdf#150164  improve general description; mention hyperlink export