ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Re: No menu bar option for Adobe Reader
@ 2019-05-01 20:00 Paul Schalck
  0 siblings, 0 replies; 10+ messages in thread
From: Paul Schalck @ 2019-05-01 20:00 UTC (permalink / raw)
  To: ntg-context

I have just tested the latest beta (2019-04-29). The new option works as expected in both Acrobat Reader 11 and DC. Thanks again.

Paul
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: No menu bar option for Adobe Reader
  2019-04-28 10:27 ` Hans Hagen
  2019-04-28 15:25   ` Alan Braslau
@ 2019-05-01 14:02   ` Henning Hraban Ramm
  1 sibling, 0 replies; 10+ messages in thread
From: Henning Hraban Ramm @ 2019-05-01 14:02 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Am 2019-04-28 um 12:27 schrieb Hans Hagen <j.hagen@xs4all.nl>:

> On 4/27/2019 6:07 PM, Paul Schalck wrote:
>> Hi,
>> I use the "Hide menu bar" option extensively in Adobe Acrobat Reader to get a cleaner interface. To this end, I usually hack lpdf-mis.lua after a ConTeXt upgrade to create a \setupinteractionscreen[option=nomenubar] switch.
>> I wonder if it would be possible to add this little feature to the source code. Perhaps it can be useful to others as well.
>> Greetings!
>> Paul
>> Attachment: patch + modified lpdf-mis.lua (from ConTeXt MkVI 2019.04.25)
> ok, but i didn't test it, so you need to check next beta

Thanks, I added it in the wiki.

Greetlings, Hraban
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: No menu bar option for Adobe Reader
  2019-04-28 20:38 Paul Schalck
@ 2019-05-01  9:54 ` luigi scarso
  0 siblings, 0 replies; 10+ messages in thread
From: luigi scarso @ 2019-05-01  9:54 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 374 bytes --]

On Sun, Apr 28, 2019 at 10:38 PM Paul Schalck <schickele@web.de> wrote:

> @luigi: Version 11. I know, it isn't supported anymore since October 2017.
>



https://linuxconfig.org/how-to-install-latest-adobe-acrobat-reader-dc-on-ubuntu-18-04-bionic-beaver-linux-with-wine
seems to work,
I have installed
AcroRdrDC1901020099_en_US.exe
and opened a couple of files.

-- 
luigi

[-- Attachment #1.2: Type: text/html, Size: 998 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: No menu bar option for Adobe Reader
@ 2019-04-28 20:38 Paul Schalck
  2019-05-01  9:54 ` luigi scarso
  0 siblings, 1 reply; 10+ messages in thread
From: Paul Schalck @ 2019-04-28 20:38 UTC (permalink / raw)
  To: ntg-context

@luigi: Version 11. I know, it isn't supported anymore since October 2017.
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: No menu bar option for Adobe Reader
  2019-04-28 19:42 Paul Schalck
@ 2019-04-28 19:50 ` luigi scarso
  0 siblings, 0 replies; 10+ messages in thread
From: luigi scarso @ 2019-04-28 19:50 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 317 bytes --]

On Sun, Apr 28, 2019 at 9:42 PM Paul Schalck <schickele@web.de> wrote:

>
>  I use Acrord because I'm used to it and because I think it still has the
> best subpixel rendering, at least in the Linux world (with Wine). Mozilla's
> PDF.js comes close though.
>

 which version of adobe reader are you using?

-- 
luigi

[-- Attachment #1.2: Type: text/html, Size: 718 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: No menu bar option for Adobe Reader
@ 2019-04-28 19:42 Paul Schalck
  2019-04-28 19:50 ` luigi scarso
  0 siblings, 1 reply; 10+ messages in thread
From: Paul Schalck @ 2019-04-28 19:42 UTC (permalink / raw)
  To: ntg-context

@Hans: Thanks a lot, I'm looking forward to testing it.

@Alan: Like Hans said. It's a new option, and I have it activated in my local environment file. It's the only and clumsy way to control the interface setting since Adobe Reader cannot save the state of the menu bar permanently (which is complete nonsense). I use Acrord because I'm used to it and because I think it still has the best subpixel rendering, at least in the Linux world (with Wine). Mozilla's PDF.js comes close though.

Paul
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: No menu bar option for Adobe Reader
  2019-04-28 15:25   ` Alan Braslau
@ 2019-04-28 15:38     ` Hans Hagen
  0 siblings, 0 replies; 10+ messages in thread
From: Hans Hagen @ 2019-04-28 15:38 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Alan Braslau

On 4/28/2019 5:25 PM, Alan Braslau wrote:
> 
>> On 28Apr19, at 04:27, Hans Hagen <j.hagen@xs4all.nl> wrote:
>>
>>> \setupinteractionscreen[option=nomenubar] switch.
>>> I wonder if it would be possible to add this little feature to the source code.
> 
> Why don’t you simply put this setup in your local environment (texmf-local) as I do not believe that it should in anyway become a default.
they are options (nomenubar is a new one), no defaults (also, only afaik 
only acrobat listens to such options)

Hans


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: No menu bar option for Adobe Reader
  2019-04-28 10:27 ` Hans Hagen
@ 2019-04-28 15:25   ` Alan Braslau
  2019-04-28 15:38     ` Hans Hagen
  2019-05-01 14:02   ` Henning Hraban Ramm
  1 sibling, 1 reply; 10+ messages in thread
From: Alan Braslau @ 2019-04-28 15:25 UTC (permalink / raw)
  To: mailing list for ConTeXt users


> On 28Apr19, at 04:27, Hans Hagen <j.hagen@xs4all.nl> wrote:
> 
>> \setupinteractionscreen[option=nomenubar] switch.
>> I wonder if it would be possible to add this little feature to the source code. 

Why don’t you simply put this setup in your local environment (texmf-local) as I do not believe that it should in anyway become a default.

Alan


--
Alan Braslau



___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: No menu bar option for Adobe Reader
  2019-04-27 16:07 Paul Schalck
@ 2019-04-28 10:27 ` Hans Hagen
  2019-04-28 15:25   ` Alan Braslau
  2019-05-01 14:02   ` Henning Hraban Ramm
  0 siblings, 2 replies; 10+ messages in thread
From: Hans Hagen @ 2019-04-28 10:27 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 4/27/2019 6:07 PM, Paul Schalck wrote:
> Hi,
> 
> I use the "Hide menu bar" option extensively in Adobe Acrobat Reader to get a cleaner interface. To this end, I usually hack lpdf-mis.lua after a ConTeXt upgrade to create a \setupinteractionscreen[option=nomenubar] switch.
> 
> I wonder if it would be possible to add this little feature to the source code. Perhaps it can be useful to others as well.
> 
> Greetings!
> 
> Paul
> 
> Attachment: patch + modified lpdf-mis.lua (from ConTeXt MkVI 2019.04.25)
ok, but i didn't test it, so you need to check next beta

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 10+ messages in thread

* No menu bar option for Adobe Reader
@ 2019-04-27 16:07 Paul Schalck
  2019-04-28 10:27 ` Hans Hagen
  0 siblings, 1 reply; 10+ messages in thread
From: Paul Schalck @ 2019-04-27 16:07 UTC (permalink / raw)
  To: ntg-context

[-- Attachment #1: Type: text/plain, Size: 445 bytes --]

Hi,

I use the "Hide menu bar" option extensively in Adobe Acrobat Reader to get a cleaner interface. To this end, I usually hack lpdf-mis.lua after a ConTeXt upgrade to create a \setupinteractionscreen[option=nomenubar] switch.

I wonder if it would be possible to add this little feature to the source code. Perhaps it can be useful to others as well.

Greetings!

Paul

Attachment: patch + modified lpdf-mis.lua (from ConTeXt MkVI 2019.04.25)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: lpdf-mis.lua --]
[-- Type: text/x-lua, Size: 22314 bytes --]

if not modules then modules = { } end modules ['lpdf-mis'] = {
    version   = 1.001,
    comment   = "companion to lpdf-ini.mkiv",
    author    = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
    copyright = "PRAGMA ADE / ConTeXt Development Team",
    license   = "see context related readme files"
}

-- Although we moved most pdf handling to the lua end, we didn't change
-- the overall approach. For instance we share all resources i.e. we
-- don't make subsets for each xform or page. The current approach is
-- quite efficient. A big difference between MkII and MkIV is that we
-- now use forward references. In this respect the MkII code shows that
-- it evolved over a long period, when backends didn't provide forward
-- referencing and references had to be tracked in multiple passes. Of
-- course there are a couple of more changes.

local next, tostring, type = next, tostring, type
local format, gsub, formatters = string.format, string.gsub, string.formatters
local flattened = table.flattened

local backends, lpdf, nodes = backends, lpdf, nodes

local nodeinjections       = backends.pdf.nodeinjections
local codeinjections       = backends.pdf.codeinjections
local registrations        = backends.pdf.registrations

local nuts                 = nodes.nuts
local copy_node            = nuts.copy

local nodepool             = nuts.pool
local pageliteral          = nodepool.pageliteral
local register             = nodepool.register

local pdfdictionary        = lpdf.dictionary
local pdfarray             = lpdf.array
local pdfconstant          = lpdf.constant
local pdfreference         = lpdf.reference
local pdfunicode           = lpdf.unicode
local pdfverbose           = lpdf.verbose
local pdfstring            = lpdf.string
local pdfflushobject       = lpdf.flushobject
local pdfflushstreamobject = lpdf.flushstreamobject
local pdfaction            = lpdf.action
local pdfminorversion      = lpdf.minorversion

local formattedtimestamp   = lpdf.pdftimestamp
local adddocumentextgstate = lpdf.adddocumentextgstate
local addtocatalog         = lpdf.addtocatalog
local addtoinfo            = lpdf.addtoinfo
local addtopageattributes  = lpdf.addtopageattributes
local addtonames           = lpdf.addtonames

local pdfgetmetadata       = lpdf.getmetadata

local texset               = tex.set

local variables            = interfaces.variables

local v_stop               = variables.stop
local v_none               = variables.none
local v_max                = variables.max
local v_bookmark           = variables.bookmark
local v_fit                = variables.fit
local v_doublesided        = variables.doublesided
local v_singlesided        = variables.singlesided
local v_default            = variables.default
local v_auto               = variables.auto
local v_fixed              = variables.fixed
local v_landscape          = variables.landscape
local v_portrait           = variables.portrait
local v_page               = variables.page
local v_paper              = variables.paper
local v_attachment         = variables.attachment
local v_layer              = variables.layer
local v_lefttoright        = variables.lefttoright
local v_righttoleft        = variables.righttoleft
local v_title              = variables.title
local v_nomenubar          = variables.nomenubar

local positive             = register(pageliteral("/GSpositive gs"))
local negative             = register(pageliteral("/GSnegative gs"))
local overprint            = register(pageliteral("/GSoverprint gs"))
local knockout             = register(pageliteral("/GSknockout gs"))

local omitextraboxes       = false

directives.register("backend.omitextraboxes", function(v) omitextraboxes = v end)

local function initializenegative()
    local a = pdfarray { 0, 1 }
    local g = pdfconstant("ExtGState")
    local d = pdfdictionary {
        FunctionType = 4,
        Range        = a,
        Domain       = a,
    }
    local negative = pdfdictionary { Type = g, TR = pdfreference(pdfflushstreamobject("{ 1 exch sub }",d)) } -- can be shared
    local positive = pdfdictionary { Type = g, TR = pdfconstant("Identity") }
    adddocumentextgstate("GSnegative", pdfreference(pdfflushobject(negative)))
    adddocumentextgstate("GSpositive", pdfreference(pdfflushobject(positive)))
    initializenegative = nil
end

local function initializeoverprint()
    local g = pdfconstant("ExtGState")
    local knockout  = pdfdictionary { Type = g, OP = false, OPM  = 0 }
    local overprint = pdfdictionary { Type = g, OP = true,  OPM  = 1 }
    adddocumentextgstate("GSknockout",  pdfreference(pdfflushobject(knockout)))
    adddocumentextgstate("GSoverprint", pdfreference(pdfflushobject(overprint)))
    initializeoverprint = nil
end

function nodeinjections.overprint()
    if initializeoverprint then initializeoverprint() end
    return copy_node(overprint)
end
function nodeinjections.knockout ()
    if initializeoverprint then initializeoverprint() end
    return copy_node(knockout)
end

function nodeinjections.positive()
    if initializenegative then initializenegative() end
    return copy_node(positive)
end
function nodeinjections.negative()
    if initializenegative then initializenegative() end
    return copy_node(negative)
end

-- function codeinjections.addtransparencygroup()
--     -- png: /CS /DeviceRGB /I true
--     local d = pdfdictionary {
--         S = pdfconstant("Transparency"),
--         I = true,
--         K = true,
--     }
--     lpdf.registerpagefinalizer(function() addtopageattributes("Group",d) end) -- hm
-- end

-- actions (todo: store and update when changed)

local openpage, closepage, opendocument, closedocument

function codeinjections.registerdocumentopenaction(open)
    opendocument = open
end

function codeinjections.registerdocumentcloseaction(close)
    closedocument = close
end

function codeinjections.registerpageopenaction(open)
    openpage = open
end

function codeinjections.registerpagecloseaction(close)
    closepage = close
end

local function flushdocumentactions()
    if opendocument then
        addtocatalog("OpenAction",pdfaction(opendocument))
    end
    if closedocument then
        addtocatalog("CloseAction",pdfaction(closedocument))
    end
end

local function flushpageactions()
    if openpage or closepage then
        local d = pdfdictionary()
        if openpage then
            d.O = pdfaction(openpage)
        end
        if closepage then
            d.C = pdfaction(closepage)
        end
        addtopageattributes("AA",d)
    end
end

lpdf.registerpagefinalizer    (flushpageactions,    "page actions")
lpdf.registerdocumentfinalizer(flushdocumentactions,"document actions")

--- info : this can change and move elsewhere

local identity = { }

function codeinjections.setupidentity(specification)
    for k, v in next, specification do
        if v ~= "" then
            identity[k] = v
        end
    end
end

local done = false  -- using "setupidentity = function() end" fails as the meaning is frozen in register

local function setupidentity()
    if not done then
        local metadata = pdfgetmetadata()
        local creator  = metadata.creator
        local version  = metadata.contextversion
        local time     = metadata.time
        local jobname  = environment.jobname or tex.jobname or "unknown"
        --
        local title = identity.title
        if not title or title == "" then
            title = tex.jobname
        end
        addtoinfo("Title", pdfunicode(title), title)
        local subtitle = identity.subtitle or ""
        if subtitle ~= "" then
            addtoinfo("Subject", pdfunicode(subtitle), subtitle)
        end
        local author = identity.author or ""
        if author ~= "" then
            addtoinfo("Author",  pdfunicode(author), author) -- '/Author' in /Info, 'Creator' in XMP
        end
        addtoinfo("Creator", pdfunicode(creator), creator)
        addtoinfo("CreationDate", pdfstring(formattedtimestamp(time)))
        local date = identity.date or ""
        local pdfdate = date and formattedtimestamp(date)
        if pdfdate then
            addtoinfo("ModDate", pdfstring(pdfdate), date)
        else
            -- users should enter the date in 2010-01-19T23:27:50+01:00 format
            -- and if not provided that way we use the creation time instead
            addtoinfo("ModDate", pdfstring(formattedtimestamp(time)),time)
        end
        local keywords = identity.keywords or ""
        if keywords ~= "" then
            keywords = gsub(keywords, "[%s,]+", " ")
            addtoinfo("Keywords",pdfunicode(keywords), keywords)
        end
        local id = lpdf.id()
        addtoinfo("ID", pdfstring(id), id) -- needed for pdf/x
        --
        addtoinfo("ConTeXt.Version",version)
        --
        local lmtx = codeinjections.lmtxmode()
        if lmtx then
            addtoinfo("ConTeXt.LMTX",formatters["%0.2f"](lmtx))
        end
        --
        addtoinfo("ConTeXt.Time",os.date("%Y-%m-%d %H:%M"))
        addtoinfo("ConTeXt.Jobname",jobname)
        addtoinfo("ConTeXt.Url","www.pragma-ade.com")
        addtoinfo("ConTeXt.Support","contextgarden.net")
        addtoinfo("TeX.Support","tug.org")
        --
        done = true
    else
        -- no need for a message
    end
end

lpdf.registerpagefinalizer(setupidentity,"identity")

-- or when we want to be able to set things after pag e1:
--
-- lpdf.registerdocumentfinalizer(setupidentity,1,"identity")

local function flushjavascripts()
    local t = interactions.javascripts.flushpreambles()
    if #t > 0 then
        local a = pdfarray()
        local pdf_javascript = pdfconstant("JavaScript")
        for i=1,#t do
            local ti     = t[i]
            local name   = ti[1]
            local script = ti[2]
            local j = pdfdictionary {
                S  = pdf_javascript,
                JS = pdfreference(pdfflushstreamobject(script)),
            }
            a[#a+1] = pdfstring(name)
            a[#a+1] = pdfreference(pdfflushobject(j))
        end
        addtonames("JavaScript",pdfreference(pdfflushobject(pdfdictionary{ Names = a })))
    end
end

lpdf.registerdocumentfinalizer(flushjavascripts,"javascripts")

-- -- --

local plusspecs = {
    [v_max] = {
        mode = "FullScreen",
    },
    [v_bookmark] = {
        mode = "UseOutlines",
    },
    [v_attachment] = {
        mode = "UseAttachments",
    },
    [v_layer] = {
        mode = "UseOC",
    },
    [v_fit] = {
        fit  = true,
    },
    [v_doublesided] = {
        layout = "TwoColumnRight",
    },
    [v_fixed] = {
        fixed  = true,
    },
    [v_landscape] = {
        duplex = "DuplexFlipShortEdge",
    },
    [v_portrait] = {
        duplex = "DuplexFlipLongEdge",
    },
    [v_page] = {
        duplex = "Simplex" ,
    },
    [v_paper] = {
        paper  = true,
    },
    [v_title] ={
        title = true,
    },
    [v_lefttoright] ={
        direction = "L2R",
    },
    [v_righttoleft] ={
        direction = "R2R",
    },
    [v_nomenubar] ={
        nomenubar = true,
    },
}

local pagespecs = {
    --
    [v_max]         = plusspecs[v_max],
    [v_bookmark]    = plusspecs[v_bookmark],
    [v_attachment]  = plusspecs[v_attachment],
    [v_layer]       = plusspecs[v_layer],
    [v_lefttoright] = plusspecs[v_lefttoright],
    [v_righttoleft] = plusspecs[v_righttoleft],
    [v_title]       = plusspecs[v_title],
    --
    [v_none] = {
    },
    [v_fit] = {
        mode = "UseNone",
        fit  = true,
    },
    [v_doublesided] = {
        mode   = "UseNone",
        layout = "TwoColumnRight",
        fit = true,
    },
    [v_singlesided] = {
        mode   = "UseNone"
    },
    [v_default] = {
        mode   = "UseNone",
        layout = "auto",
    },
    [v_auto] = {
        mode   = "UseNone",
        layout = "auto",
    },
    [v_fixed] = {
        mode   = "UseNone",
        layout = "auto",
        fixed  = true, -- noscale
    },
    [v_landscape] = {
        mode   = "UseNone",
        layout = "auto",
        fixed  = true,
        duplex = "DuplexFlipShortEdge",
    },
    [v_portrait] = {
        mode   = "UseNone",
        layout = "auto",
        fixed  = true,
        duplex = "DuplexFlipLongEdge",
    },
    [v_page] = {
        mode   = "UseNone",
        layout = "auto",
        fixed  = true,
        duplex = "Simplex",
    },
    [v_paper] = {
        mode   = "UseNone",
        layout = "auto",
        fixed  = true,
        duplex = "Simplex",
        paper  = true,
    },
    [v_nomenubar] = {
        mode   = "UseNone",
        layout = "auto",
        nomenubar = true,
    },
}

local pagespec, topoffset, leftoffset, height, width, doublesided = "default", 0, 0, 0, 0, false
local cropoffset, bleedoffset, trimoffset, artoffset = 0, 0, 0, 0
local marked = false
local copies = false

local getpagedimensions  getpagedimensions = function()
    getpagedimensions = backends.codeinjections.getpagedimensions
    return getpagedimensions()
end

function codeinjections.setupcanvas(specification)
    local paperheight = specification.paperheight
    local paperwidth  = specification.paperwidth
    local paperdouble = specification.doublesided
    --
    paperwidth, paperheight = codeinjections.setpagedimensions(paperwidth,paperheight)
    --
    pagespec    = specification.mode       or pagespec
    topoffset   = specification.topoffset  or 0
    leftoffset  = specification.leftoffset or 0
    height      = specification.height     or paperheight
    width       = specification.width      or paperwidth
    marked      = specification.print
    --
    copies      = specification.copies
    if copies and copies < 2 then
        copies = false
    end
    --
    cropoffset  = specification.cropoffset  or 0
    trimoffset  = cropoffset  - (specification.trimoffset  or 0)
    bleedoffset = trimoffset  - (specification.bleedoffset or 0)
    artoffset   = bleedoffset - (specification.artoffset   or 0)
    --
    if paperdouble ~= nil then
        doublesided = paperdouble
    end
end

local function documentspecification()
    if not pagespec or pagespec == "" then
        pagespec = v_default
    end
    local settings = utilities.parsers.settings_to_array(pagespec)
    -- so the first one detemines the defaults
    local first    = settings[1]
    local defaults = pagespecs[first]
    local spec     = defaults or pagespecs[v_default]
    -- successive keys can modify this
    if spec.layout == "auto" then
        if doublesided then
            local s = pagespecs[v_doublesided] -- to be checked voor interfaces
            for k, v in next, s do
                spec[k] = v
            end
        else
            spec.layout = false
        end
    end
    -- we start at 2 when we have a valid first default set
    for i=defaults and 2 or 1,#settings do
        local s = plusspecs[settings[i]]
        if s then
            for k, v in next, s do
                spec[k] = v
            end
        end
    end
    -- maybe interfaces.variables
    local layout    = spec.layout
    local mode      = spec.mode
    local fit       = spec.fit
    local fixed     = spec.fixed
    local duplex    = spec.duplex
    local paper     = spec.paper
    local title     = spec.title
    local direction = spec.direction
    local nomenubar = spec.nomenubar
    if layout then
        addtocatalog("PageLayout",pdfconstant(layout))
    end
    if mode then
        addtocatalog("PageMode",pdfconstant(mode))
    end
    local prints = nil
    if marked then
        local pages     = structures.pages
        local marked    = pages.allmarked(marked)
        local nofmarked = marked and #marked or 0
        if nofmarked > 0 then
            -- the spec is wrong in saying that numbering starts at 1 which of course makes
            -- sense as most real documents start with page 0 .. sigh
            for i=1,#marked do marked[i] = marked[i] - 1 end
            prints = pdfarray(flattened(pages.toranges(marked)))
        end
    end
    if fit or fixed or duplex or copies or paper or prints or title or direction or nomenubar then
        addtocatalog("ViewerPreferences",pdfdictionary {
            FitWindow         = fit       and true                   or nil,
            PrintScaling      = fixed     and pdfconstant("None")    or nil,
            Duplex            = duplex    and pdfconstant(duplex)    or nil,
            NumCopies         = copies    and copies                 or nil,
            PickTrayByPDFSize = paper     and true                   or nil,
            PrintPageRange    = prints                               or nil,
            DisplayDocTitle   = title     and true                   or nil,
            Direction         = direction and pdfconstant(direction) or nil,
	    HideMenubar       = nomenubar and true                   or nil,
        })
    end
    addtoinfo   ("Trapped", pdfconstant("False")) -- '/Trapped' in /Info, 'Trapped' in XMP
    addtocatalog("Version", pdfconstant(format("1.%s",pdfminorversion())))
    addtocatalog("Lang",    pdfstring(tokens.getters.macro("currentmainlanguage")))
end

-- temp hack: the mediabox is not under our control and has a precision of 5 digits

local factor  = number.dimenfactors.bp
local f_value = formatters["%.6F"]

directives.register("pdf.stripzeros",function()
    local f_value = formatters["%.6N"]
end)

local function boxvalue(n) -- we could share them
    return pdfverbose(f_value(factor * n))
end

local function pagespecification()
    local paperwidth, paperheight = codeinjections.getpagedimensions()
    local llx = leftoffset
    local lly = paperheight + topoffset - height
    local urx = width - leftoffset
    local ury = paperheight - topoffset
    -- boxes can be cached
    local function extrabox(WhatBox,offset,always)
        if offset ~= 0 or always then
            addtopageattributes(WhatBox, pdfarray {
                boxvalue(llx + offset),
                boxvalue(lly + offset),
                boxvalue(urx - offset),
                boxvalue(ury - offset),
            })
        end
    end
    if omitextraboxes then
        -- only useful for testing / comparing
    else
        extrabox("CropBox",cropoffset,true) -- mandate for rendering
        extrabox("TrimBox",trimoffset,true) -- mandate for pdf/x
        extrabox("BleedBox",bleedoffset)    -- optional
     -- extrabox("ArtBox",artoffset)        -- optional .. unclear what this is meant to do
    end
end

lpdf.registerpagefinalizer(pagespecification,"page specification")
lpdf.registerdocumentfinalizer(documentspecification,"document specification")

-- Page Label support ...
--
-- In principle we can also support /P (prefix) as we can just use the verbose form
-- and we can then forget about the /St (start) as we don't care about those few
-- extra bytes due to lack of collapsing. Anyhow, for that we need a stupid prefix
-- variant and that's not on the agenda now.

local map = {
    numbers       = "D",
    Romannumerals = "R",
    romannumerals = "r",
    Characters    = "A",
    characters    = "a",
}

-- local function featurecreep()
--     local pages, lastconversion, list = structures.pages.tobesaved, nil, pdfarray()
--     local getstructureset = structures.sets.get
--     for i=1,#pages do
--         local p = pages[i]
--         if not p then
--             return -- fatal error
--         else
--             local numberdata = p.numberdata
--             if numberdata then
--                 local conversionset = numberdata.conversionset
--                 if conversionset then
--                     local conversion = getstructureset("structure:conversions",p.block,conversionset,1,"numbers")
--                     if conversion ~= lastconversion then
--                         lastconversion = conversion
--                         list[#list+1] = i - 1 -- pdf starts numbering at 0
--                         list[#list+1] = pdfdictionary { S = pdfconstant(map[conversion] or map.numbers) }
--                     end
--                 end
--             end
--             if not lastconversion then
--                 lastconversion = "numbers"
--                 list[#list+1] = i - 1 -- pdf starts numbering at 0
--                 list[#list+1] = pdfdictionary { S = pdfconstant(map.numbers) }
--             end
--         end
--     end
--     addtocatalog("PageLabels", pdfdictionary { Nums = list })
-- end

local function featurecreep()
    local pages        = structures.pages.tobesaved
    local list         = pdfarray()
    local getset       = structures.sets.get
    local stopped      = false
    local oldlabel     = nil
    local olconversion = nil
    for i=1,#pages do
        local p = pages[i]
        if not p then
            return -- fatal error
        end
        local label = p.viewerprefix or ""
        if p.status == v_stop then
            if not stopped then
                list[#list+1] = i - 1 -- pdf starts numbering at 0
                list[#list+1] = pdfdictionary {
                    P = pdfunicode(label),
                }
                stopped = true
            end
            oldlabel      = nil
            oldconversion = nil
            stopped       = false
        else
            local numberdata = p.numberdata
            local conversion = nil
            local number     = p.number
            if numberdata then
                local conversionset = numberdata.conversionset
                if conversionset then
                    conversion = getset("structure:conversions",p.block,conversionset,1,"numbers")
                end
            end
            conversion = conversion and map[conversion] or map.numbers
            if number == 1 or oldlabel ~= label or oldconversion ~= conversion then
                list[#list+1] = i - 1 -- pdf starts numbering at 0
                list[#list+1] = pdfdictionary {
                    S  = pdfconstant(conversion),
                    St = number,
                    P  = label ~= "" and pdfunicode(label) or nil,
                }
            end
            oldlabel      = label
            oldconversion = conversion
            stopped       = false
        end
    end
    addtocatalog("PageLabels", pdfdictionary { Nums = list })
end

lpdf.registerdocumentfinalizer(featurecreep,"featurecreep")

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: nomenubar_patch.diff --]
[-- Type: text/x-patch, Size: 587 bytes --]

78a79
> local v_nomenubar          = variables.nomenubar
331a333,335
>     [v_nomenubar] ={
>         nomenubar = true,
>     },
395a400,404
>     [v_nomenubar] = {
>         mode   = "UseNone",
>         layout = "auto",
>         nomenubar = true,
>     },
474a484
>     local nomenubar = spec.nomenubar
493c503
<     if fit or fixed or duplex or copies or paper or prints or title or direction then
---
>     if fit or fixed or duplex or copies or paper or prints or title or direction or nomenubar then
502a513
> 	    HideMenubar       = nomenubar and true                   or nil,

[-- Attachment #4: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-05-01 20:00 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-01 20:00 No menu bar option for Adobe Reader Paul Schalck
  -- strict thread matches above, loose matches on Subject: below --
2019-04-28 20:38 Paul Schalck
2019-05-01  9:54 ` luigi scarso
2019-04-28 19:42 Paul Schalck
2019-04-28 19:50 ` luigi scarso
2019-04-27 16:07 Paul Schalck
2019-04-28 10:27 ` Hans Hagen
2019-04-28 15:25   ` Alan Braslau
2019-04-28 15:38     ` Hans Hagen
2019-05-01 14:02   ` Henning Hraban Ramm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).