speedata / publisher

speedata Publisher - a professional database Publishing system
https://www.speedata.de/
GNU Affero General Public License v3.0
292 stars 36 forks source link

partial code for `<AttachFile showattachments="yes"/>` #417

Closed pr-apes closed 1 year ago

pr-apes commented 2 years ago

@pgundlach,

here you have partial implementation to have <AttachFile showattachments="yes"/>.

I'm afraid in only replicated the code from showbookmarks. But I don't know what triggers it.

--- ../old-spp/sw/lua/publisher/commands.lua    2022-08-25 14:39:43.000000000 +0200
+++ sw/lua/publisher/commands.lua   2022-08-26 10:40:48.908789100 +0200
@@ -2478,7 +2478,8 @@
     local format       = publisher.read_attribute(layoutxml,dataxml,"format",    "string")
     local nc           = publisher.read_attribute(layoutxml,dataxml,"numcopies", "number")
     local printscaling = publisher.read_attribute(layoutxml,dataxml,"printscaling", "string")
-    local showbookmarks = publisher.read_attribute(layoutxml,dataxml,"showbookmarks", "boolean",true)
+    local showbookmarks = publisher.read_attribute(layoutxml,dataxml,"showbookmarks", "boolean", true)
+    local showattachments = publisher.read_attribute(layoutxml,dataxml,"showattachments", "boolean", true)
     local picktray     = publisher.read_attribute(layoutxml,dataxml,"picktraybypdfsize", "boolean")
     local showhyperlinks = publisher.read_attribute(layoutxml,dataxml,"showhyperlinks", "boolean", false)
     local duplex       = publisher.read_attribute(layoutxml,dataxml,"duplex",   "string")
@@ -2512,6 +2513,8 @@
     end
     if showbookmarks ~= nil then
         publisher.viewerpreferences.showbookmarks = showbookmarks
+    elseif showattachments ~= nil then
+        publisher.viewerpreferences.showattachments = showattachments
     end

     if printscaling then
diff -ru ../old-spp/sw/lua/publisher.lua sw/lua/publisher.lua
--- ../old-spp/sw/lua/publisher.lua 2022-08-25 14:39:43.000000000 +0200
+++ sw/lua/publisher.lua    2022-08-26 11:39:12.653215300 +0200
@@ -1406,6 +1406,8 @@

     if viewerpreferences.showbookmarks then
         pdfcatalog[#pdfcatalog + 1] = "/PageMode /UseOutlines"
+    elseif viewerpreferences.showattachments then
+        pdfcatalog[#pdfcatalog + 1] = "/PageMode /UseAttachments"
     else
         pdfcatalog[#pdfcatalog + 1] = "/PageMode /UseNone"
     end

I hope it might help.

pgundlach commented 1 year ago

Perhaps the showbookmarks, showattachments etc. should be depreciated in favour of a generic command pagemode with the options "attachments", "layers" (or "oc"), "fullscreen", "thumbs" (can't test), "outlines" and "none" since these options are exclusive and for example showbookmarks="yes" and showattachments="yes" contradict.

pr-apes commented 1 year ago

@pgundlach,

/PageMode allows: /UseNone, /UseOutlines, /UseThumbs, /FullScreen, /UseOC and /UseAttachments.

When using /PageMode /FullScreen, there is also a /NonFullScreenPageMode (in the /ViewerPreferences dictionary), which also allows /UseNone, /UseOutlines, /UseThumbs, / and /UseOC.

I don't think it makes sense to implement /NonFullScreenPageMode and /UseOC, at least. I cannot find that Publisher makes use of OCG.

displaymode may be a good attribute name with values: bookmarks, thumbnails, fullscreen and attachments.

This would also remove showbookmarks (which I think it shouldn't be be true by default [otherwise, it would impossible to use it for other values]).

pgundlach commented 1 year ago

Thanks. Closed with your fix.

pr-apes commented 1 year ago

Thank you for you improved code!