Thanks to visit codestin.com
Credit goes to github.com

Skip to content

LaTeX package for OCG-aware PDF form fields. Fields are bound to layers using native /OC and toggle visibility with the layer via /SetOCGState. Target: pdfLaTeX, Adobe Acrobat/Reader.

License

Notifications You must be signed in to change notification settings

R0mb0/Ocgformfields

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Ocgformfields ⚠️This library actually doesn’t work

Codacy Badge Maintenance Open Source Love svg3 MIT Donate

PDF fields (AcroForm) natively associated with OCG (layers) via the /OC key in the annotation dictionary, with dynamic toggling of the layer state. Target: pdfLaTeX + Adobe Acrobat/Reader.

🧩 Features

  • Native binding of fields to layers: adds /OC <ref> to the widget dictionary.
  • Dynamic layer toggle via /SetOCGState action.
  • Simple API:
    • ocgform (environment): defines the OCG context for fields.
    • \OCGTextField (command): text field bound to the current OCG.
    • \OCGToggle and \OCGToggleButton: link/button to show/hide dynamically.

✅ Requirements

  • Engine: pdfLaTeX
  • Viewer: Adobe Acrobat/Reader (other apps may ignore /OC on annotations)
  • LaTeX packages: hyperref, ocgx2, acrotex (provides eforms), xparse, l3packages

💻 On MiKTeX, install packages via MiKTeX Console (Packages): “acrotex”, “ocgx2”.

Installation 🛠️

  • Local (same folder as the .tex):
    • \usepackage{./ocgformfields} (harmless warning about name difference).
  • MiKTeX TEXMFHOME (persistent):
    • Create: C:\Users\<user>\texmf\tex\latex\ocgformfields\ocgformfields.sty
    • MiKTeX Console → Settings → Directories → Add… add C:\Users\<user>\texmf
    • Tasks → Refresh file name database
    • Verify: kpsewhich ocgformfields.sty

Quick start 🚀

\documentclass{article}
\usepackage[a4paper,margin=2.5cm]{geometry}

\usepackage{hyperref}
\usepackage{ocgx2}
\usepackage{eforms}
\usepackage{ocgformfields}

\begin{document}

\OCGToggle{sens}{\textbf{Show/Hide sensitive data}}

\begin{ocgform}{Sensitive Data}{sens}{on}
  Name: \OCGTextField[name=name,width=8cm]{}\\
  Email: \OCGTextField[name=email,width=8cm]{}
\end{ocgform}

\medskip
\OCGToggleButton{sens}{Toggle Sensitive Data}

\end{document}

About

LaTeX package for OCG-aware PDF form fields. Fields are bound to layers using native /OC and toggle visibility with the layer via /SetOCGState. Target: pdfLaTeX, Adobe Acrobat/Reader.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Languages