1

We have to replicate an existing pdf form using latex.

I found this to be of use: https://www.tug.org/applications/hyperref/manual.html

The existing form which I have to replicate has clickable cells.

See image: enter image description here

I think I need to either, make a table cell being a \CheckBox.

Or make the \CheckBox fill the whole table cell.

Currently I tried to play with the attributes of \CheckBox but no success.

\mbox{\CheckBox[borderwidth=0.1mm,name=tblWetCell,width=3mm,height=3mm]{}}&\CheckBox[width=1mm,height=1mm]{ }

This is what it looks like in its current state.

enter image description here

Full table:

\begin{table}[!ht]
\begin{small}
\begin{tabular}{|l|l|l|l|l|l|l|}
\cline{3-7}
\multicolumn{1}{l}{Anz. sep. WC}        &\TextField[width=3cm,name=toilAmount]{}        &\multirow{3}{*}{\rotatebox{90}{\hfill wöchentlich }} & \multirow{3}{*}{\rotatebox{90}{\hfill täglich }} & \multirow{3}{*}{\rotatebox{90}{\hfill monatl
ich }} & \multirow{3}{*}{\rotatebox{90}{\hfill bei Bedarf }} & \multirow{3}{*}{\rotatebox{90}{\hfill Zusatzarbeiten }} \\
\multicolumn{2}{l|}{}                   &&&&&\\
\multicolumn{2}{l|}{}                   &&&&&\\
\multicolumn{1}{l}{Anz. Nasszellen}     &\TextField[width=3cm,name=wetCellAmount]{}     &&&&&\\
\multicolumn{2}{l|}{}                   &&&&&\\
\multicolumn{2}{l|}{}                   &&&&&\\

\hline
\multicolumn{2}{|l|}{Nasszellen (Bad / Dusche / Toiletten)}&\mbox{\CheckBox[borderwidth=0.1mm,name=tblWetCell,width=3mm,height=3mm]{}}&\CheckBox[width=1mm,height=1mm]{ }& &            &                \\
\hline
\multicolumn{2}{|l|}{Abfalleimer in Küchenabfall leeren} & &         &           &            &                \\
\hline
\end{tabular}
\end{small}
\end{table}

Full document

\documentclass[a4paper,10pt]{article}
\usepackage{amssymb} % needed for math
\usepackage{amsmath} % needed for math
\usepackage[utf8]{inputenc} % this is needed for german umlauts
\usepackage[ngerman]{babel} % this is needed for german umlauts
\usepackage[T1]{fontenc}    % this is needed for correct output of umlauts in pdf
\usepackage[margin=1cm]{geometry} %layout
\usepackage{graphicx}   % to enable \resizebox for table sacling to \linewidth

% specifics
\usepackage{hyperref}  % this is needed for forms and links within the text
%\def\DefaultHeightofSubmit{12pt}
%\def\DefaultWidthofSubmit{2cm}
%\def\DefaultHeightofReset{12pt}
%\def\DefaultWidthofReset{2cm}
%\def\DefaultHeightofCheckBox{0.5\baselineskip}
%\def\DefaultWidthofCheckBox{0.5\baselineskip}
\usepackage{multirow}                           % for cells with multiple rows
\usepackage{graphicx}                           % needed for the tables
\usepackage{xcolor}                             % to make text in required color
\renewcommand{\familydefault}{\sfdefault}       % use non serif font
\usepackage{helvet}                             % use non serif font
\definecolor{orng}{HTML}{ff6700}                % define colors
\definecolor{grey}{HTML}{F0F0F0}                % define colors
\newcommand{\agencyName}{Agency}                % specific agency name
\newcommand{\mailAddr}{example@test.ch} % mailto addresses list

% Global Styles for the \TextField
\def\DefaultOptionsofText{
        print,
        %bordercolor={0 0 0},
        backgroundcolor=grey,
        width=4.6cm,
        borderwidth=0
        %height=5pt
}

\hypersetup{
  pdfauthor   = {XXX},
  pdfkeywords = {XXXXX},
  pdftitle    = {YYYYYYYYY}
}

\begin{document}
\begin{Form}[action=mailto:\mailAddr{},encoding=html,method=post]

\begin{table}[!ht]
\resizebox{\textwidth}{!}{
\begin{tabular}{p{13.5cm}rr}
\textcolor{orng}{TITLE MAGIC \agencyName{} XXXX}&
\Submit[color=grey,bordersep={0 1 0}]{Send}&
\Reset[backgroundcolor=grey]{Reset}
\\
\end{tabular}}
\end{table}

\begin{table}[!ht]
\begin{small}
\begin{tabular}{llll}
Kunde:&\TextField[name=customer]{}&Einsatzdauer Basis in Stunden:&\TextField[name=onSetTime]{}
\vspace{1mm}\\
Kundennummer:&\TextField[name=customerNr]{}&Einstzfauer Zusatz in Sunden:&\TextField[name=onSetExtras]{}
\vspace{1mm}\\
Anzahl Zimmer:&\TextField[name=roomFromAmount,width=1cm]{} von \TextField[name=roomToAmount,width=1cm]{}&Einsatztag:&\TextField[name=onSetDay]{}
\vspace{1mm}\\
Etage:&\TextField[name=floor]{}&Einsatzzeit:&\TextField[name=seviceTime]{}
\vspace{1mm}\\
Anzahl Stockwerke:&\TextField[name=floorFromAmount,width=1cm]{} von \TextField[name=floorToAmount,width=1cm]{}&Putzfrau:&\TextField[name=employee]{}
\vspace{1mm}\\
Haustiere:&\TextField[name=petAnimals]{}&Rhytmus:&\TextField[name=interval]{}
\vspace{1mm}\\
&&&\\
\multicolumn{4}{l}{asldkjflkasj faslkj flkasdj flksadj fjkasdlj flaskdfj!}\\
\end{tabular}
\end{small}
\end{table}

\begin{table}[!ht]
\begin{small}
\begin{tabular}{|l|l|l|l|l|l|l|}
\cline{3-7}
\multicolumn{1}{l}{Anz. sep. WC}        &\TextField[width=3cm,name=toilAmount]{}        &\multirow{3}{*}{\rotatebox{90}{\hfill wöchentlich }} & \multirow{3}{*}{\rotatebox{90}{\hfill täglich }} & \multirow{3}{*}{\rotatebox{90}{\hfill monatlich }} & \multirow{3}{*}{\rotatebox{90}{\hfill bei Bedarf }} & \multirow{3}{*}{\rotatebox{90}{\hfill Zusatzarbeiten }} \\
\multicolumn{2}{l|}{}                   &&&&&\\
\multicolumn{2}{l|}{}                   &&&&&\\
\multicolumn{1}{l}{Anz. Nasszellen}     &\TextField[width=3cm,name=wetCellAmount]{}     &&&&&\\
\multicolumn{2}{l|}{}                   &&&&&\\
\multicolumn{2}{l|}{}                   &&&&&\\

\hline
\multicolumn{2}{|l|}{Nasszellen (Bad / Dusche / Toiletten)}&\mbox{\CheckBox[borderwidth=0.1mm,name=tblWetCell,width=3mm,height=3mm]{}}&\CheckBox[width=1mm,height=1mm]{ }& &            &                \\

\hline
\multicolumn{2}{|l|}{Abfalleimer in Küchenabfall leeren} & &         &           &            &                \\
\hline
\multicolumn{2}{|l|}{Wasserhähne polieren}             &             &         &           &            &                \\
\hline
\multicolumn{2}{|l|}{Duschkabine} &             &         &           &            &                \\
\hline
\multicolumn{2}{|l|}{Fliesen entkalken}&             &         &           &            &                \\
\hline
\multicolumn{2}{|l|}{Lavabo inkl. Zahngläser + Seifenschalen}&             &         &           &            &                \\
\hline
\multicolumn{2}{|l|}{Lüftung / Abzug}  &             &         &           &            &                \\
\hline
\multicolumn{2}{|l|}{Radiator für Frottetücher abstauben}&             &         &           &            &                \\
\hline
\multicolumn{2}{|l|}{ } &           &         &           &            &                \\
\hline
\end{tabular}
\end{small}
\end{table}



\hfill ~\\

\end{Form}
\end{document}
  • 1
    Welcome to TeX.SX! Can you provide a MWE? A compilable code for us to "play" with? So we know which packages you use. – Sango Sep 11 '19 at 13:38
  • Sure, added to the question. – Pfarc Sep 11 '19 at 13:43
  • Most likely unrealted, but please keep the following in ind: hyperref should usually (with a few exceptions) be the last package in your preamble. Also small is not an environment, but a switch (\small) that is active inside a group or untill switched back. – leandriis Sep 11 '19 at 13:52
  • Regadring: "\usepackage{graphicx} % to enable \resizebox for table sacling to \linewidth": I'd definitely recommend to not do that. Depending on the table size this will lead to inconsistent and probably unreadably small font sizes. – leandriis Sep 11 '19 at 13:54
2

Maybe the following is closer to what you want to achieve. I have used fixed width centered columns and removed the horizontal white space between table borders and the contents of the correnponding cells:

enter image description here

\documentclass[a4paper,10pt]{article}
\usepackage{amssymb} % needed for math
\usepackage{amsmath} % needed for math
\usepackage[utf8]{inputenc} % this is needed for german umlauts
\usepackage[ngerman]{babel} % this is needed for german umlauts
\usepackage[T1]{fontenc}    % this is needed for correct output of umlauts in pdf
\usepackage[margin=1cm]{geometry} %layout
\usepackage{graphicx}   % to enable \resizebox for table sacling to \linewidth


\usepackage{array} % needed for \newcolumntype
% specifics

%\def\DefaultHeightofSubmit{12pt}
%\def\DefaultWidthofSubmit{2cm}
%\def\DefaultHeightofReset{12pt}
%\def\DefaultWidthofReset{2cm}
%\def\DefaultHeightofCheckBox{0.5\baselineskip}
%\def\DefaultWidthofCheckBox{0.5\baselineskip}
\usepackage{multirow}                           % for cells with multiple rows
\usepackage{graphicx}                           % needed for the tables
\usepackage{xcolor}                             % to make text in required color
\renewcommand{\familydefault}{\sfdefault}       % use non serif font
\usepackage{helvet}                             % use non serif font
\definecolor{orng}{HTML}{ff6700}                % define colors
\definecolor{grey}{HTML}{F0F0F0}                % define colors
\newcommand{\agencyName}{Agency}                % specific agency name
\newcommand{\mailAddr}{example@test.ch} % mailto addresses list

% Global Styles for the \TextField
\def\DefaultOptionsofText{
        print,
        %bordercolor={0 0 0},
        backgroundcolor=grey,
        width=4.6cm,
        borderwidth=0
        %height=5pt
}


\usepackage{hyperref}  % this is needed for forms and links within the text
\hypersetup{
  pdfauthor   = {XXX},
  pdfkeywords = {XXXXX},
  pdftitle    = {YYYYYYYYY}
}


\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}


\begin{document}
\begin{Form}[action=mailto:\mailAddr{},encoding=html,method=post]

%\begin{table}[!ht]
%\resizebox{\textwidth}{!}{
\noindent
\begin{tabular*}{\textwidth}{l@{\extracolsep{\fill}}r@{\extracolsep{\tabcolsep}}r}
\textcolor{orng}{TITLE MAGIC \agencyName{} XXXX}&
\Submit[color=grey,bordersep={0 1 0}]{Send}&
\Reset[backgroundcolor=grey]{Reset}
\end{tabular*}%}
%\end{table}

%\begin{table}[!ht]
%\begin{small}
\small
\begin{tabular}{llll}
Kunde:&\TextField[name=customer]{}&Einsatzdauer Basis in Stunden:&\TextField[name=onSetTime]{}
\vspace{1mm}\\
Kundennummer:&\TextField[name=customerNr]{}&Einstzfauer Zusatz in Sunden:&\TextField[name=onSetExtras]{}
\vspace{1mm}\\
Anzahl Zimmer:&\TextField[name=roomFromAmount,width=1cm]{} von \TextField[name=roomToAmount,width=1cm]{}&Einsatztag:&\TextField[name=onSetDay]{}
\vspace{1mm}\\
Etage:&\TextField[name=floor]{}&Einsatzzeit:&\TextField[name=seviceTime]{}
\vspace{1mm}\\
Anzahl Stockwerke:&\TextField[name=floorFromAmount,width=1cm]{} von \TextField[name=floorToAmount,width=1cm]{}&Putzfrau:&\TextField[name=employee]{}
\vspace{1mm}\\
Haustiere:&\TextField[name=petAnimals]{}&Rhytmus:&\TextField[name=interval]{}
\vspace{1mm}\\
&&&\\
\multicolumn{4}{l}{asldkjflkasj faslkj flkasdj flksadj fjkasdlj flaskdfj!}\\
\end{tabular}
%\end{small}
%\end{table}

%\begin{table}[!ht]
%\begin{small}
\begin{tabular}{|l|l|@{}C{4ex}@{}|@{}C{4ex}@{}|l|l|l|}
\cline{3-7}
\multicolumn{1}{l}{Anz. sep. WC}        &\TextField[width=3cm,name=toilAmount]{}        &\multirow{3}{*}{\rotatebox{90}{\hfill wöchentlich }} & \multirow{3}{*}{\rotatebox{90}{\hfill täglich }} & \multirow{3}{*}{\rotatebox{90}{\hfill monatlich }} & \multirow{3}{*}{\rotatebox{90}{\hfill bei Bedarf }} & \multirow{3}{*}{\rotatebox{90}{\hfill Zusatzarbeiten }} \\
\multicolumn{2}{l|}{}                   &&&&&\\
\multicolumn{2}{l|}{}                   &&&&&\\
\multicolumn{1}{l}{Anz. Nasszellen}     &\TextField[width=3cm,name=wetCellAmount]{}     &&&&&\\
\multicolumn{2}{l|}{}                   &&&&&\\
\multicolumn{2}{l|}{}                   &&&&&\\

\hline
\multicolumn{2}{|l|}{Nasszellen (Bad / Dusche / Toiletten)}&\CheckBox[borderwidth=0.1mm,name=tblWetCell1,width=4ex,height=1.5ex]{}&\CheckBox[borderwidth=0.1mm,name=tblWetCell2,width=4ex,height=1.5ex]{}& &            &                \\

\hline
\multicolumn{2}{|l|}{Abfalleimer in Küchenabfall leeren} &\CheckBox[borderwidth=0.1mm,name=tblWetCell3,width=4ex,height=1.5ex]{}&\CheckBox[borderwidth=0.1mm,name=tblWetCell4,width=4ex,height=1.5ex]{}          &           &            &                \\
\hline
\multicolumn{2}{|l|}{Wasserhähne polieren}             &             &         &           &            &                \\
\hline
\multicolumn{2}{|l|}{Duschkabine} &             &         &           &            &                \\
\hline
\multicolumn{2}{|l|}{Fliesen entkalken}&             &         &           &            &                \\
\hline
\multicolumn{2}{|l|}{Lavabo inkl. Zahngläser + Seifenschalen}&             &         &           &            &                \\
\hline
\multicolumn{2}{|l|}{Lüftung / Abzug}  &             &         &           &            &                \\
\hline
\multicolumn{2}{|l|}{Radiator für Frottetücher abstauben}&             &         &           &            &                \\
\hline
\multicolumn{2}{|l|}{ } &           &         &           &            &                \\
\hline
\end{tabular}
%\end{small}
%\end{table}

%
%
%\hfill ~\\

\end{Form}
\end{document}
  • 1
    Awesome this is it! Thx – Pfarc Sep 11 '19 at 14:12
  • @Pfarc: You're welcome. Please also see my recent edit. I have added some improvements to other parts of your code as well. For example, I have removed redundant table environments. (they are not needed since you don't want your tables to float/move away from where they were mentioned in the code). I have also removed the resizebox and used tabular* instead to make sure that the table fills the whole textwidth. – leandriis Sep 11 '19 at 14:17
  • Hehe cool, thx! – Pfarc Sep 11 '19 at 14:27
3

You basically have to ensure that the checkbox have the size of the cells:

\documentclass[a4paper,10pt]{article}
\usepackage[ngerman]{babel} 
\usepackage[T1]{fontenc}    
\usepackage[margin=1cm]{geometry} %layout
\usepackage{array}
\usepackage{hyperref}  

\hypersetup{
    pdfauthor   = {XXX},
    pdfkeywords = {XXXXX},
    pdftitle    = {YYYYYYYYY}
}

\begin{document}
    \begin{Form}[action=mailto:xxx.com,encoding=html,method=post]


        \begin{table}[!ht]
           \begin{tabular}{l|@{}p{5mm}@{}|@{}p{5mm}@{}|}
            Kunde:&
            \CheckBox[name=cb1,charsize=12pt,width=5mm,height=\normalbaselineskip]{}&
            \CheckBox[name=cb2,charsize=12pt,width=5mm,height=\normalbaselineskip]{ }\\\hline
            Raum:&
            \CheckBox[name=cb3,charsize=12pt,width=5mm,height=\normalbaselineskip]{}&
            \CheckBox[name=cb4,charsize=12pt,width=5mm,height=\normalbaselineskip]{ }\\\hline        
           \end{tabular}

        \end{table}


    \end{Form}
\end{document}

enter image description here

0

I don't know if this helps, but if i do this:

\documentclass[a4paper,10pt]{article}
\usepackage{amssymb} % needed for math
\usepackage{amsmath} % needed for math
\usepackage[utf8]{inputenc} % this is needed for german umlauts
\usepackage[ngerman]{babel} % this is needed for german umlauts
\usepackage[T1]{fontenc}    % this is needed for correct output of umlauts in pdf
\usepackage[margin=1cm]{geometry} %layout
\usepackage{graphicx}   % to enable \resizebox for table sacling to \linewidth

% specifics
\usepackage{hyperref}  % this is needed for forms and links within the text
%\def\DefaultHeightofSubmit{12pt}
%\def\DefaultWidthofSubmit{2cm}
%\def\DefaultHeightofReset{12pt}
%\def\DefaultWidthofReset{2cm}
%\def\DefaultHeightofCheckBox{0.5\baselineskip}
%\def\DefaultWidthofCheckBox{0.5\baselineskip}
\usepackage{multirow}                           % for cells with multiple rows
\usepackage{graphicx}                           % needed for the tables
\usepackage{xcolor}                             % to make text in pfa color
\renewcommand{\familydefault}{\sfdefault}       % use non serif font
\usepackage{helvet}                             % use non serif font
\definecolor{orng}{HTML}{ff6700}                % define colors
\definecolor{grey}{HTML}{F0F0F0}                % define colors
\newcommand{\agencyName}{Agency}                % specific agency name
\newcommand{\mailAddr}{example@test.ch} % mailto addresses list

% Global Styles for the \TextField
\def\DefaultOptionsofText{
    print,
    %bordercolor={0 0 0},
    backgroundcolor=grey,
    width=4.6cm,
    borderwidth=0
    %height=5pt
}

\hypersetup{
    pdfauthor   = {XXX},
    pdfkeywords = {XXXXX},
    pdftitle    = {YYYYYYYYY}
}

\begin{document}
    \begin{Form}[action=mailto:\mailAddr{},encoding=html,method=post]

        \begin{table}[!ht]
            \resizebox{\textwidth}{!}{
                \begin{tabular}{p{13.5cm}rr}
                    \textcolor{orng}{TITLE MAGIC \agencyName{} XXXX}&
                    \Submit[color=grey,bordersep={0 1 0}]{Send}&
                    \Reset[backgroundcolor=grey]{Reset}
                    \\
            \end{tabular}}
        \end{table}

        \begin{table}[!ht]
            \begin{small}
                \begin{tabular}{llll}
                    Kunde:&\TextField[name=customer]{}&Einsatzdauer Basis in Stunden:&\TextField[name=onSetTime]{}
                    \vspace{1mm}\\
                    Kundennummer:&\TextField[name=customerNr]{}&Einstzfauer Zusatz in Sunden:&\TextField[name=onSetExtras]{}
                    \vspace{1mm}\\
                    Anzahl Zimmer:&\TextField[name=roomFromAmount,width=1cm]{} von \TextField[name=roomToAmount,width=1cm]{}&Einsatztag:&\TextField[name=onSetDay]{}
                    \vspace{1mm}\\
                    Etage:&\TextField[name=floor]{}&Einsatzzeit:&\TextField[name=seviceTime]{}
                    \vspace{1mm}\\
                    Anzahl Stockwerke:&\TextField[name=floorFromAmount,width=1cm]{} von \TextField[name=floorToAmount,width=1cm]{}&Putzfrau:&\TextField[name=employee]{}
                    \vspace{1mm}\\
                    Haustiere:&\TextField[name=petAnimals]{}&Rhytmus:&\TextField[name=interval]{}
                    \vspace{1mm}\\
                    &&&\\
                    \multicolumn{4}{l}{asldkjflkasj faslkj flkasdj flksadj fjkasdlj flaskdfj!}\\
                \end{tabular}
            \end{small}
        \end{table}

        \begin{table}[!ht]
            \begin{small}
                \begin{tabular}{|l|l|l|l|l|l|l|}
                    \cline{3-7}
                    \multicolumn{1}{l}{Anz. sep. WC}        &\TextField[width=3cm,name=toilAmount]{}        &\multirow{3}{*}{\rotatebox{90}{\hfill wöchentlich }} & \multirow{3}{*}{\rotatebox{90}{\hfill täglich }} & \multirow{3}{*}{\rotatebox{90}{\hfill monatlich }} & \multirow{3}{*}{\rotatebox{90}{\hfill bei Bedarf }} & \multirow{3}{*}{\rotatebox{90}{\hfill Zusatzarbeiten }} \\
                    \multicolumn{2}{l|}{}                   &&&&&\\
                    \multicolumn{2}{l|}{}                   &&&&&\\
                    \multicolumn{1}{l}{Anz. Nasszellen}     &\TextField[width=3cm,name=wetCellAmount]{}     &&&&&\\
                    \multicolumn{2}{l|}{}                   &&&&&\\
                    \multicolumn{2}{l|}{}                   &&&&&\\

                    \hline
                    \multicolumn{2}{|l|}{Nasszellen (Bad / Dusche / Toiletten)}&\CheckBox[name=cb1,charsize=12pt,width=5mm,height=5mm]{ }&\CheckBox[name=cb2,charsize=12pt,width=5mm,height=5mm]{ }& &            &                \\

                    \hline
                    \multicolumn{2}{|l|}{Abfalleimer in Küchenabfall leeren} & &         &           &            &                \\
                    \hline
                    \multicolumn{2}{|l|}{Wasserhähne polieren}             &             &         &           &            &                \\
                    \hline
                    \multicolumn{2}{|l|}{Duschkabine} &             &         &           &            &                \\
                    \hline
                    \multicolumn{2}{|l|}{Fliesen entkalken}&             &         &           &            &                \\
                    \hline
                    \multicolumn{2}{|l|}{Lavabo inkl. Zahngläser + Seifenschalen}&             &         &           &            &                \\
                    \hline
                    \multicolumn{2}{|l|}{Lüftung / Abzug}  &             &         &           &            &                \\
                    \hline
                    \multicolumn{2}{|l|}{Radiator für Frottetücher abstauben}&             &         &           &            &                \\
                    \hline
                    \multicolumn{2}{|l|}{ } &           &         &           &            &                \\
                    \hline
                \end{tabular}
            \end{small}
        \end{table}


        \hfill ~\\

    \end{Form}
\end{document}

it looks fine to me, at least in Acrobat. No need for mbox... looks different in other viewers. Result

  • Also looks fine to me. But the person who assigned the task wants it to look like on the screenshot as mentioned in my question and attached above. So no box inside the cell. I think I could fake that effect with hiding the borders of the checkbox, but thats more of a hack than a solution I think. – Pfarc Sep 11 '19 at 13:59
  • Going on a limb here, but i guess those boxes are part of the formular functionality. Dont know if they can be disabled... – Sango Sep 11 '19 at 14:02
  • Not sure I can follow you. Why would I disable CheckBoxes? I need them for the users to input data. – Pfarc Sep 11 '19 at 14:10
  • I meant the borders/boxes can not be disabled. The thing bothering you/your boss is the read square, right? Or the violet color? I think that might be a default thing not in the scope settable by the pdf itself. But thats a guess. – Sango Sep 11 '19 at 14:52
  • Ah I see. They can be changed using bordercolor and borderwidt. – Pfarc Sep 12 '19 at 9:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.