latex_Generate_pdf_descriptor

Added by Val Amar about 6 years ago

Hello,

I was scraping most of the web for answers on this matter but i couldn't find a relevant solution.
My aim is to automatically correct multiple choice question based tests on a web platform. The questionnaires themselves are generated using latex with the amc stylefile (amc.sty).
My current approach is to generate a descriptor file with latex that will contain coordinates about regions of interests ( containing mainly test id, questions and their respective answers) that i will use to perform the correction of the document.
My question : is there a way ( are there any commands) i should use that will allow me to write a descriptor file on the output containing the pdf meta-data ?

Thanks in advance for your answer


Replies (11)

RE: latex_Generate_pdf_descriptor - Added by Alexis Bienvenüe about 6 years ago

The automultiplechoice.sty style logs positions of boxes to be ticked into the .xy file. These values are read by AMC-meptex.pl and stored in the data/layout.sqlite database.

RE: latex_Generate_pdf_descriptor - Added by Val Amar about 6 years ago

is it possible to read those coordinates ( positions of the boxes ) without the AMC-meptex.pl? In other words can a script ( written in python for instance ) read from the .xy file?

RE: latex_Generate_pdf_descriptor - Added by Val Amar about 6 years ago

By the way does someone know how to find the .xy file with an online latex editor such as overleaf that i've been using for a couple weeks now? At the beginning the .xy was showing up amongst the output files but recently i can't seem to find it anymore on the output? I thought it had something to do with the compiler i was using but after having gone through all compilers available with overleaf ( pdfLatex, Latex, XeLatex, LuaLatex) it still isn't showing up even though the amc.sty is still in the same directory as my main .tex file.

RE: latex_Generate_pdf_descriptor - Added by Val Amar about 6 years ago

i checked inside the .xy file generated by the pdfLatex compiler but all i could find is this :

\version{AMC 1.3.0+hg2017-07-12 }
\with{codedigit=squarebrackets}
\with{version=AMC 1.3.0+hg2017-07-12 }
\with{ensemble=no}
\with{insidebox=no}
\with{ousidebox=no}
\with{postcorrect=no}
\with{lang=}

there's no mention of the coordinates of the checkboxes
Should i explicitly issue specific commands from within the main.tex in order to write the coordinates in the .xy file?

RE: latex_Generate_pdf_descriptor - Added by Alexis Bienvenüe about 6 years ago

there's no mention of the coordinates of the checkboxes

You need to add the calibration package option to automultiplechoice.

RE: latex_Generate_pdf_descriptor - Added by Val Amar almost 6 years ago

Hello,

So i've done that and it gave me the coordinates for every single square contour on the exam which is neat. The only thing is the coordinates are given in sp as shown on the next line:
\tracepos{1/1:case:Q1.7:10,3}{4347045sp}{12297107sp}{square}
i read somewhere in the amc doc that the transition from sp to inch is such that 1 inch <=> 65536*72.27sp
the real units am looking for are pixels and so far i've been trying to convert from sp to pixels.
Seeing as how the number of pixels per inch changes from laptop to laptop according to its resolution i was wondering whether it's possible to output the coordinates of checkboxes in pixel units
in which case the above sample from the .xy file would look something like this: \tracepos{1/1:case:Q1.7:10,3}{ x_coord px}{y_coord px}{square} where x_coord and y_coord are both pixel values of the checkbox coordinates.
so if there's anyway to do this i'd really appreciate the help cause it's crucial for a project i'm working.
On the off chance that there's no way to directly output coordinates in pixel value, could you please indicate a way to convert sp coordinates of a given checkbox to pixel ones, i tried doing it myself with the aforementioned formula (1 inch <=> 65536*72.27sp) and adding the fact that 1 inch corresponds to 96 pixels. Problem is i kept landing on values in pixel that do not match the actual pixel coordinates as shown with an image editing soft such as paint. Also is there anyway to know what these elements coorespond to in the .xy file : \tracepos{1/1:positionBG} \tracepos{1/1:positionBD} \tracepos{1/1:positionHG} \tracepos{1/1:positionHD} my initial impression being that they are the calibration marks on the corners of the exam sheet and that their center point is used as a reference to locate checkboxes with their sp coordinates.Thanks for the help

RE: latex_Generate_pdf_descriptor - Added by Alexis Bienvenüe almost 6 years ago

Coordinates in the xy file relates to the printed paper, so physical units are used. To convert to pixels, you have to use the density of your bitmap representation of the paper.

RE: latex_Generate_pdf_descriptor - Added by Val Amar almost 6 years ago

In other words i have to use the resolution of the paper to deduce the correspondance between an inch and pixels and also use the formula 1 inch <=> 65536*72.27sp ?
And could you please tell me what these ( \tracepos{1/1:positionBG} \tracepos{1/1:positionBD} \tracepos{1/1:positionHG} \tracepos{1/1:positionHD} ) refer to and if i have to account for them when i'm computing the coordinates ? Thanks again for the help

RE: latex_Generate_pdf_descriptor - Added by Val Amar almost 6 years ago

i found that the paper's resolution is 1654*2339 and that the dimensions of the paper in inch are 13.79 width and 19.49 height.
So if 1 inch <=> 65536*72.27 sp = 4,736,286.72 sp and on the paper i have 120 pixels per inch ( 1654/13.79 = 2339/19.49 = 120 ppi ) i finally 1 px <=> 4,736,286.72 / 120 = 39,469.056 sp.
So when i try converting a given sp coordinate of a checkbox for instance x = 15504958 sp i get x = 392.09 px and that is way off the actual x coord of the checkbox which is at x = 654 px.
Could you please tell me where i got it wrong on the above conversion procedure ?

RE: latex_Generate_pdf_descriptor - Added by Alexis Bienvenüe almost 6 years ago

\tracepos{1/1:positionBG} \tracepos{1/1:positionBD} \tracepos{1/1:positionHG} \tracepos{1/1:positionHD}

These are for the corner marks (circles).

Could you please tell me where i got it wrong on the above conversion procedure ?

Give your formula a try and you will see!

RE: latex_Generate_pdf_descriptor - Added by Val Amar almost 6 years ago

the formula gives me coordinates that are way off of the actual ones in pixel unless the physical coordinates in sp mentioned in the .xy file are with respect to the corner marks.
So is that the case ( sp coordinates are with respect to the corner marks )?

(1-11/11)