ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: "luigi.scarso" <luigi.scarso@logosrl.it>
Subject: Filling forms
Date: Tue, 06 Sep 2005 15:18:10 +0200	[thread overview]
Message-ID: <431D9712.5060107@logosrl.it> (raw)
In-Reply-To: <431D92C0.3020706@gmail.com>

Hi, I'm working on a project that require filling forms.
Every field has  (x,y,width,height) dimension and
ui=(barcode,texEdit) type (textEdit has some attributes too)
I wrote this

%--------------
\unprotect
\definelayer[BackLayer]%
\setupbackgrounds[page][background={BackLayer}]

\setuplayout[topspace=0pt,backspace=0pt,margin=0pt,leftmargin=0pt,location=middle, 

 rightmargin=0pt,header=0pt,footer=0pt,top=0pt,bottom=0pt,
 leftedge=0pt,rightedge=0pt,headerdistance=0pt,footerdistance=0pt,
 topdistance=0pt,leftmargindistance=0pt,rightmargindistance=0pt,
 leftedgedistance=0pt,rightedgedistance=0pt,width=fit,height=fit]

\def\BarcodeThreeOfNine#1{#1} %% todo....

\def\Field[#1]{%
\bgroup
\getparameters[!!][#1]%% collect key/val
%
%
%%%% textEdit
\doifsamestring{\!!ui}{textEdit}{% text field
\setlayer[BackLayer][x=\!!x,y=\!!y ,location=br]{%
\expanded{\getparameters[!!textEdit@][\!!textEdit]}% collect textEdit 
attributes
\expanded{\getparameters[!!para@][\!!para]}% collect para attributes
\ruledvbox to \!!h{\hsize=\!!w %
\vss
\doifsamestringelse{\!!textEdit@multiLine}{0}{% single line
 \doifsamestring{\!!para@hAlign}{}{%
   \hbox to \!!w {\getvalue\s!dummy \vphantom{K}\getvalue\!!name \hss}%
  }%
 \doifsamestring{\!!para@hAlign}{left}{%
   \hbox to \!!w {\getvalue\s!dummy \vphantom{K} \getvalue\!!name \hss}%
 }%
 \doifsamestring{\!!para@hAlign}{right}{%
  \hbox to \!!w {\hss \getvalue\s!dummy  \vphantom{K} \getvalue\!!name}%
 }%
 \doifsamestring{\!!para@hAlign}{center}{%
  \hbox to \!!w {\hss \getvalue\s!dummy  \getvalue\!!name \hss}%
 }%
}{% multiline
\getvalue\s!dummy \getvalue\!!name%
}
%
\vss
}}}%
%%%% barcode
\doifsamestring{\!!ui}{barcode}{% barcode (todo..)
\setlayer[BackLayer][x=\!!x,y=\!!y ,location=br]{%
\doifsamestring{\!!type}{39}{% type of barcode
\ruledvbox to \!!h{\hsize=\!!w
\vss
\centerline{\expanded{\BarcodeThreeOfNine{\getvalue{\!!name}}}}
\vss}
}%
}}
\egroup
}
\protect

%%
%% Macros for filling forms
%%
\def\FillForm{%
%%
%% I have really 200 Fields
%%
\Field[%
name={codicearticolo_len6},%
ui={textEdit},%
textEdit={multiLine={0},},%
%x={0.520in},%
x={0.520in},%
y={0.217in},%
w={3.096in},%
h={0.882in},%
para={vAlign={middle},hAlign={}},%%
]

\Field[%
ui={barcode},%
type={39},%
name={barcode_codice___matricola},%
x={0.434in},%
y={1.259in},%
w={4.210in},%
h={0.651in},%
para={vAlign={middle},hAlign={}},%%
]
}

\starttext
\bgroup
%% I have really 200 \setvalue ....
\setvalue{codicearticolo_len6}{957803}
\setvalue{barcode_codice___matricola}{*9F9578030052201312*}
\hskip1sp%% force flush layer ??
\FillForm\page
\egroup
%% and so on for 1000 /1500 pages...
\stoptext

%----------------
Problems
1) I have 200 fields for a single page;
2) I have 1000/1500 pages
My code it's very slow:  does anybody has another approach ?

Thanks in advance
luigi

  reply	other threads:[~2005-09-06 13:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-06 12:59 strange behaviour of colors Mojca Miklavec
2005-09-06 13:18 ` luigi.scarso [this message]
2005-09-06 14:47   ` Filling forms Taco Hoekwater
2005-09-06 15:09     ` luigi.scarso
2005-09-06 13:46 ` strange behaviour of colors luigi.scarso
2005-09-06 14:42   ` Mojca Miklavec
2005-09-06 16:11 ` Hans Hagen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=431D9712.5060107@logosrl.it \
    --to=luigi.scarso@logosrl.it \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).