pdf manipulation - tagging image or figure - itext

I have a source pdf(untagged.pdf) out of which I would be creating a tagged version(tagged.pdf)
I have information of all the html tags of all contents of the source pdf.
Now I have a figure on page 3. When I programmatically parse, this will not be detected as an image but this is a rectangle with some text and another rectangle like below.
_____________________ ____________________
| Some text inside | ----> | Some other text |
| | ----> | Inside |
|_____________________| ----> |____________________|
Fig 1.x Rectangle 1 to Rectangle 2
Using some other techniques, I have detected this is a figure and bounding coordinates of the same. Lets say the bounding coordinates is [10, 30] and [100, 60], I want to tag the whole thing as a figure(like below)
_____________________________________________________________(100, 60)
| |
| _____________________ ____________________ |
| | Some text inside | ----> | Some other text | |
| | | ----> | Inside | |
| |_____________________| ----> |____________________| |
| |
| Fig 1.x Rectangle 1 to Rectangle 2 |
|_____________________________________________________________|
(10, 30)
Now I want to tag this the entire section as an image. I have checked libraries like itextpdf or pdfbox. They dont have APIs to tag a figure using coordinates.
In other words, are there any ways to tag an element(group of images) as a figure programmatically.

Related

What widget(s) can be used for liquid and fixed columns with column span in Flutter?

I need to do the following:
Apple | 2 kg | button 1 | button 2 |
Orange | 1 kg | info |
Orange | 2 kg | info |
Pear | ? |
...
First column with names must be liquid, and other three column must be fixed size. I planned to use table, but as I found out colspan in tables is not supported currently. Could anyone say what widget(s) I should use for such a task?

Extract the data from txt file with various format speification in matlab

I would like to extract Andy's result from the below txt file. My expectation is extracting 1.033, -0.017, 1.016 and put these into the cell array. Is there any possible way to extract these? I have around 100 files with same format as below.
Total 6 outlier 0
| Thomas | -0.255 | -0.006 | -0.261 |
| Todd | 1.012 | 0.112 | 1.124 |
| Harry | -0.033 | 0.005 | -0.028 |
| Andy | 1.033 | -0.017 | 1.016 |
| Zheng | 0.152 | 0.226 | 0.378 |
| Betsi | -19.409 | 1.010 | -18.399 |
| Andrew | -0.066 | 0.048 | -0.018 |
| Tom | -95.582 | 0.590 | -94.991 |
I assume there is no new line in you text file.
Let's try something:
%Open you file and load the data
fid = fopen('the_path_of_your_file');
line = fgetl(fid);
%We split the data using the '||' delimiter. Each personne's results
%is stored in a cell.
txtSplitCell = strsplit(line,'||');
%Here we check in each cell if 'Andy' appears
indAndy = cellfun(#(c)strfind(c,'Andy')),...
txtSplitCell,'UniformOutput',false);
%We split the content of Andy's results cell with the second sperator '|'
%to get the values
resAndyRaw = strsplit(txtSplitCell{find(indAndy,1)},'|');
% We only select the subsection of the cell array that actually contains
%Andy's results (in other words we remove 'Andy' in the results cell
%and we convert that into matrix;
resAndyTab = cell2mat(resAndyRaw(strcmp(resAndyRaw,'Andy'):end));
%Note: strcmp(resAndyRaw,'Andy') enable locating the postion of
%'Andy' in the resulting cell array of the strsplit function.
% Consequently thus this code should work for thomas as well.
fclose(fid)
print(resAndyTab)
I can't run that code yet (no matlab on my computer). So test it please and correct it if needed.
Bye.

Cross tab with a list of values instead of summation

I want a Cross tab that lists field values and counts them instead of just giving a count for the summation. I know I could make this with groups but I cant list the values vertically that way. From my research I believe I have to use a Display String Formula.
SQL Field Data
-------------------------------------------------
| Play # | Formation |Back Set | R/P | PLAY |
-------------------------------------------------
| 1 | TREY | FG | R | TRUCK |
-------------------------------------------------
| 2 | T | FG | R | RHINO |
-------------------------------------------------
| 3 | D | FG | P | 5 STEP |
-------------------------------------------------
| 4 | D | FG | P | 5 STEP |
-------------------------------------------------
| 5 | K JET | NG | R | DOG |
-------------------------------------------------
Desired report structure:
-----------------------------------------------------------
| Backet & Formation | Run | Pass |
-----------------------------------------------------------
| NG K JET | BULLA 1 | |
| | HELL 3 | |
-----------------------------------------------------------
| FG D | | 5 STEP 2 |
-----------------------------------------------------------
| NG K JET | DOG | |
-----------------------------------------------------------
| FG T | RHINO | |
-----------------------------------------------------------
Don't see why a Crosstab is necessary for this - especially if the entire body of the report is just that table.
Group your records by Bracket and Formation - If that's not
something natively configured in your table, make a new Formula field
and group on that.
Drop the 3 relevant fields into whichever section you need to display. (It might be a Footer, based on whether or not you want repeats
Write a formula to determine whether or not Run or Pass are displayed, and place it in their suppression field. (Good luck getting a Crosstab to do that for you! It tends to prefer 0s over blanks.)
If there's more to the report than just this table, you can cheat the system by placing your "table" into a subreport. And of course you can stretch Line objects across the sections and it will stretch to form the table outlines

Matlab: find inner boundary of set of vertices

I have a set of (x,y) points defined in the following way:
map=[0,0;66,0;66,44;44,44;44,66;110,66;110,110;0,110];
There is then a function that connects these points (which are vertices, i.e. corner points) together to form a closed shape. The example vertices I have given form a shape something like this:
________________________________________
| |
| |
| |
| ____________________|
| |
| |_______
| |
| |
| |
| |
|___________________________|
I would like to now automatically generate a second set of vertices that form a boundary inside the shape, offset by some amount. I.e. this:
inner_boundary=[5,5;61,5;61,39;39,39;39,71;105,71;105,105;5,105];
________________________________________
| ___________________________________ |
| | | |
| | _____________________| |
| | | ____________________|
| | | |
| | | |_______
| | |________ |
| | | |
| | | |
| |______________________| |
|___________________________|
Any ideas on how to do this? I've been racking my brains but can't think of a robust way to do this. I need it to automatically do this for any input set of vertices. Also, to clarify - I am just interested in how to specify the set of vertices, not the drawing part.
Many thanks!
Here is a solution based on Image Processing Toolbox functions. The basic idea is as follows:
Use "poly2mask" to create a BW (0-1) image from the polygon
coordinates
Use "imerode" to erode the mask by 1 pixel
Use "bwboundaries" to trace the new, eroded, boundary
Code example:
x = [4 10 10 4 4];
y = [4 4 10 10 4];
mask = poly2mask(x,y,12,12);
mask_eroded = imerode(mask, 1);
newBnds = bwboundaries(mask_eroded);
newBnds = newBnds{1};
Note that the newBnds will probably contain more points than you want because it traces every single pixel on the boundary. You can write a simple iterative routine to discard non-endpoints.

What is the best way to "paginate" a loooong SVG file on iOS?

I am facing an interesting problem with SVG and iOS.
I need to render very long SVG files (up to about 5mb large), which hasn't been a problem using UIWebView. I also haven't had a problem scrolling them smoothly with JS, but since I'm waiting on my developer program application to be approved I haven't tested the performance on an actual device.
I'm now trying to achieve a page-turning effect like how the iBooks app flips pages. It doesn't have to be as elaborate and intricate, the gist of the idea is that the next section of the svg will "wipe over" the last.
Reason being, I need both "pages" of content to remain static to ease the reading of the content during the "flipping" process. Scrolling very quickly makes the contents of the SVG difficult to read.
Here is a graphic representation of what I would like to achieve:
---------------------------
| |
| |
| |
| 1 |
| |
| |
| |
| |
---------------------------
---------------------------
| | |
| | |
| | |
| 2 | 1 |
| |-> |
| | |
| / |
| / |
---------------------------
---------------------------
| | |
| | |
| | |
| 2 | 1 |
| |-> |
| | |
| / |
| / |
---------------------------
---------------------------
| |
| |
| |
| 2 |
| |
| |
| |
| |
---------------------------
Looking forward to some interesting ideas from you veterans!
I haven't rut to such needs, but from what I know, it could be made by two UIViews (or any of their subclasses). All you have to do is a custom animation on flip(a simple one if you interested in flip only, a harder one if you need the animation actually to go one with the finger). And of course you'll need to put corresponding part of your file to those views. Actually I would suggest using 3 views, so you'll be able to put content of the next "page" while it still offscreen. That will make your animation smoother.