coordinate outside allowed range iText exception - itext

The llx, lly , urx, ury of co-ordinates are mentioned below
401.74042 747.38 406.18842 753.91815
405.9332 747.38 410.3812 753.91815
410.126 747.38 414.574 753.91815
I am trying to clean up the text in these locations using iText. Only text exists in these locations since I have got these co-ordinates using the renderText method of RenderListener.
The page size is Rectangle: 595.0x842.0 (rot: 0 degrees)
I am getting a "java.lang.IllegalStateException: Coordinate outside allowed range" exception only with this PDF with iText 5.5.11
I found "Exception occur :Reason : Coordinate outside allowed range java.lang.IllegalStateException: Coordinate outside allowed range" and it does not seem to help. Any help would be appreciated
stack trace
java.lang.IllegalStateException: Coordinate outside allowed range
at com.itextpdf.text.pdf.parser.clipper.ClipperBase.rangeTest(ClipperBase.java:119)
at com.itextpdf.text.pdf.parser.clipper.ClipperBase.addPath(ClipperBase.java:192)
at com.itextpdf.text.pdf.pdfcleanup.PdfCleanUpRegionFilter.addRect(PdfCleanUpRegionFilter.java:423)
at com.itextpdf.text.pdf.pdfcleanup.PdfCleanUpRegionFilter.filterFillPath(PdfCleanUpRegionFilter.java:176)
at com.itextpdf.text.pdf.pdfcleanup.PdfCleanUpRegionFilter.filterStrokePath(PdfCleanUpRegionFilter.java:160)
at com.itextpdf.text.pdf.pdfcleanup.PdfCleanUpRenderListener.filterCurrentPath(PdfCleanUpRenderListener.java:387)
at com.itextpdf.text.pdf.pdfcleanup.PdfCleanUpRenderListener.renderPath(PdfCleanUpRenderListener.java:224)
at com.itextpdf.text.pdf.parser.PdfContentStreamProcessor.paintPath(PdfContentStreamProcessor.java:400)
at com.itextpdf.text.pdf.parser.PdfContentStreamProcessor.access$6300(PdfContentStreamProcessor.java:83)
at com.itextpdf.text.pdf.parser.PdfContentStreamProcessor$PaintPath.invoke(PdfContentStreamProcessor.java:1218)
at com.itextpdf.text.pdf.pdfcleanup.PdfCleanUpContentOperator.invoke(PdfCleanUpContentOperator.java:139)
at com.itextpdf.text.pdf.parser.PdfContentStreamProcessor.invokeOperator(PdfContentStreamProcessor.java:310)
at com.itextpdf.text.pdf.parser.PdfContentStreamProcessor.processContent(PdfContentStreamProcessor.java:448)
at com.itextpdf.text.pdf.pdfcleanup.PdfCleanUpProcessor.cleanUpPage(PdfCleanUpProcessor.java:159)
at com.itextpdf.text.pdf.pdfcleanup.PdfCleanUpProcessor.cleanUp(PdfCleanUpProcessor.java:134)
(also here)
graphics state
The graphics state at the time of the exception:
Page Number: 1
Horizontal scaling:1.0
Render Mode: 0
Transformation matrix: 1.0 0.0 0.0
0.0 1.0 0.0
0.0 0.0 1.0
Character spacing: 0.0
Font size: 0.0
Leading: 0.0
Line Cap Style: 0
Line join style: 0
Line wodth: 1.0
Miter limit: 10.0
Rise: 0.0
Word Spacing: 0.0
Color space fill: null
Color space stroke: null
Fill color: null
Font: null
Line dash pattern: null
Stroke color: null
Is knockout: true
(also here)

Related

How to get correct RGB color values from PNG with PLTE palette using NSBitmapImageRep in Swift?

Given a PNG image, I would like to get the RGB color at a given pixel using Swift on macOS.
This is simply done by:
let d = Data(base64Encoded: "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVQImWP4z8AAAAMBAQCc479ZAAAAAElFTkSuQmCC")!
let nsImage = NSImage(data: d)!
let bitmapImageRep = NSBitmapImageRep(cgImage: nsImage.cgImage(forProposedRect: nil, context: nil, hints: [:])!)
let color = bitmapImageRep.colorAt(x: 0, y: 0)
print(color!.redComponent, color!.greenComponent, color!.blueComponent, separator: " ")
// 1.0 0.0 0.0
This minimal example contains a one pixel PNG in RGB encoding with a red pixel in base64 encoding to make this easily reproducible.
printf iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVQImWP4z8AAAAMBAQCc479ZAAAAAElFTkSuQmCC | base64 --decode | pngcheck -v
File: stdin (140703128616967 bytes)
chunk IHDR at offset 0xfffffffffffffffb, length 13
1 x 1 image, 24-bit RGB, non-interlaced
chunk IDAT at offset 0xfffffffffffffffb, length 12
zlib: deflated, 256-byte window, default compression
chunk IEND at offset 0xfffffffffffffffb, length 0
No errors detected in stdin (3 chunks, -133.3% compression).
When changing this PNG to an indexed PNG with a PLTE Palette
printf iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAMAAAAoyzS7AAAAA1BMVEX/AAAZ4gk3AAAACklEQVQImWNgAAAAAgAB9HFkpgAAAABJRU5ErkJggg== | base64 --decode | pngcheck -v
File: stdin (140703128616967 bytes)
chunk IHDR at offset 0xfffffffffffffffb, length 13
1 x 1 image, 8-bit palette, non-interlaced
chunk PLTE at offset 0xfffffffffffffffb, length 3: 1 palette entry
chunk IDAT at offset 0xfffffffffffffffb, length 10
zlib: deflated, 256-byte window, default compression
chunk IEND at offset 0xfffffffffffffffb, length 0
No errors detected in stdin (4 chunks, -600.0% compression).
the snippet above changes to
let d = Data(base64Encoded: "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAMAAAAoyzS7AAAAA1BMVEX/AAAZ4gk3AAAACklEQVQImWNgAAAAAgAB9HFkpgAAAABJRU5ErkJggg==")!
let nsImage = NSImage(data: d)!
let bitmapImageRep = NSBitmapImageRep(cgImage: nsImage.cgImage(forProposedRect: nil, context: nil, hints: [:])!)
let color = bitmapImageRep.colorAt(x: 0, y: 0)
print(color!.redComponent, color!.greenComponent, color!.blueComponent, separator: " ")
// 0.984313725490196 0.0 0.027450980392156862
It produces the unexpected output with a red component close to one and some non-zero blue component. Where does this change in color come from?

body2 is deprecated and shouldn't be used. This is the term used in the 2014 version of material design. - warning message in flutter

If you update flutter SDK from version v1.12.13 to any version after v1.13.8, you will receive several warning messages related to textTheme usage. For example, one of them given below.
info: body2 is deprecated and shouldn't be used. This is the term used in the 2014 version of material design. The modern term is bodyText1. This feature was deprecated after v1.13.8..
what are the changes in the new version? how to migrate?
What are differences between text theme of material specification 2014 and text theme of material specification 2018?
The TextTheme API was originally based on the original material (2014)
design spec, which used different text style names.
Both values are given below.
The 2018 spec - Text styles
NAME SIZE WEIGHT SPACING
headline1 96.0 light -1.5
headline2 60.0 light -0.5
headline3 48.0 regular 0.0
headline4 34.0 regular 0.25
headline5 24.0 regular 0.0
headline6 20.0 medium 0.15
subtitle1 16.0 regular 0.15
subtitle2 14.0 medium 0.1
body1 16.0 medium 0.5 (bodyText1)
body2 14.0 regular 0.25 (bodyText2)
button 14.0 medium 1.25
caption 12.0 regular 0.4
overline 10.0 regular 1.5
The 2014 spec - Text style
NAME SIZE WEIGHT SPACING 2018 NAME
display4 112.0 thin 0.0 headline1
display3 56.0 normal 0.0 headline2
display2 45.0 normal 0.0 headline3
display1 34.0 normal 0.0 headline4
headline 24.0 normal 0.0 headline5
title 20.0 medium 0.0 headline6
subhead 16.0 normal 0.0 subtitle1
body2 14.0 medium 0.0 body1 (bodyText1)
body1 14.0 normal 0.0 body2 (bodyText2)
caption 12.0 normal 0.0 caption
button 14.0 medium 0.0 button
subtitle 14.0 medium 0.0 subtitle2
overline 10.0 normal 0.0 overline
How to use the new TextTheme attributes? (flutter version v1.13.8 and above)
You can use the desired attribute as shown below.
Theme.of(context).textTheme.headline1
Theme.of(context).textTheme.headline2
Theme.of(context).textTheme.headline3
Theme.of(context).textTheme.headline4
Theme.of(context).textTheme.headline5
Theme.of(context).textTheme.headline6
Theme.of(context).textTheme.subtitle1
Theme.of(context).textTheme.subtitle2
Theme.of(context).textTheme.body1
Theme.of(context).textTheme.body2
Theme.of(context).textTheme.button
Theme.of(context).textTheme.caption
Theme.of(context).textTheme.overline
What are attribute names that does not changed?
Only the following two attribute names are common in both Theme classes.
Theme.of(context).textTheme.caption
Theme.of(context).textTheme.overline

TextTheme fields not match Sketch project text styles

I use material design plugin for Sketch to design my app. Now I need to set up my app theme to completely satisfy my prototype. There is no issues with colors. But with text I see mismatch of fields of TextTheme class and generated by plugin styles
Material typography:
headline1
headline2
headline3
headline4
headline5
headline6
subtitle1
subtitle2
body1
body2
button
caption
overline
TextTheme fields:
body1
body2
button
caption
display1
display2
display3
display4
headline
overline
subhead
subtitle
title
What is the correct fields matching here?
Found in reference:
NAME SIZE WEIGHT SPACING 2018 NAME
display4 112.0 thin 0.0 headline1
display3 56.0 normal 0.0 headline2
display2 45.0 normal 0.0 headline3
display1 34.0 normal 0.0 headline4
headline 24.0 normal 0.0 headline5
title 20.0 medium 0.0 headline6
subhead 16.0 normal 0.0 subtitle1
body2 14.0 medium 0.0 body1
body1 14.0 normal 0.0 body2
caption 12.0 normal 0.0 caption
button 14.0 medium 0.0 button
subtitle 14.0 medium 0.0 subtitle2
overline 10.0 normal 0.0 overline

merging two text files into one using batch or perl script

Hello I am new to scripting and searching for a solution. I have two text files with different names and i want to merge them together into a new third text file. The format of each text file will be exactly same and will be like that. each text file will have some (same number of) rows starting with # sign followed by some text. after those rows starting with # signs. I will have rows starting with numbers. these rows will have numbers in three columns separated by space. The numbers in the first two columns will be the same in both files while the numbers in the third column will be different. after few hundred rows i might have rows starting with # sign again followed by rows starting with numbers in three columns like before and this can repeat many times. now here is what i want to do.
I want to create a new text file which will have the rows starting with # sign copied exactly from the first text file. I want to copy the first two columns of numbers exactly as they are. these two columns can be copied from the first text file or the 2nd text file as they will be the same inboth files. Now for the third column in the new text file I want to do add the number in the third column of the first two files
number in third column of new text file = (number in third column of first file + number in third column of 2nd file)
after some rows i might have rows with # sign again and then rows followed by numbers in 3 columns. and this can repeat.
sample Format of only one text file is given below. the 2nd text file will have exact same format.
#
#
#
#
#
#
#
0.0 0.0 4.4226
0.0 5.0 4.4246
0.0 10.0 4.4456
0.0 15.0 4.4876
0.0 20.0 4.4453
0.0 25.0 5.6585
.
.
.
.
#
#
#
#
#
0.0 0.0 0.410135
0.0 5.0 0.745745
0.0 10.0 0.574555
0.0 15.0 0.415675
0.0 20.0 0.575454
0.0 25.0 0.410135
0.0 30.0 0.678768
0.0 35.0 0.410135
0.0 40.0 0.976876
0.0 45.0 0.678678
0.0 50.0 0.410135
0.0 55.0 0.678976
0.0 60.0 0.410135
0.0 65.0 0.687876
0.0 70.0 0.768677
.
.
.
.
.
.
and this format of rows with # sign and numbers in three columns can repeat. the rows with numbers in three columns has columns separated by spaces and in the beginning of the these rows with numbers there is one space as well.
I hope i did a good job explaining. I prefer bacth script as it will be easy for me to run. however perl will also work. Thank you very much for your help. highly appreciated.
New file format will be exactly the same as the other two files with third column being the sum of numbers in third column of the first and 2nd txt files. sample third file format is given below.
#
#
#
#
#
#
#
0.0 0.0 8.4355
0.0 5.0 6.3553
0.0 10.0 6.4327
.
.
.
.
#
#
#
#
#
0.0 0.0 4.832735
0.0 5.0 7.436343
0.0 10.0 0.323325
0.0 15.0 4.876656
.
.
.
.
.
.
Once again thank you very much. I am getting headaches because as i have a lot of these files. your help is much appreciated.
File 1 is here
#
#
#
#
#
#
#
0.0 0.0 5.30562
0.0 5.0 5.30562
0.0 10.0 1.4852
90.0 355.0 1.99511
#
#
#
#
#
0.0 0.0 0.948027
0.0 5.0 0.948027
90.0 355.0 1.54
file 2 is
#
#
#
#
#
#
#
0.0 0.0 1.4621
0.0 5.0 1.4621
0.0 10.0 1.4621
90.0 355.0 3.3359
#
#
#
#
#
0.0 0.0 0.747458
0.0 5.0 0.747458
90.0 355.0 0.550766
now u can check problem i think is with spaces in beginning and in between columns
Try following using awk
awk 'NR==FNR {if($3~/[0-9]+\.[0-9]+/){a[i++]=$3}; next} \
$3~/[0-9]+\.[0-9]+/ {$3=$3+a[j++]} \
1' file1 file2 > file3
Testing on sample input specified in comment:
$ cat file1
# comment here
90.0 355.0 1.54
$ cat file2
# comment here
90.0 355.0 0.550766
$ awk 'NR==FNR {if($3~/[0-9]+\.[0-9]+/){a[i++]=$3}; next} \
? $3~/[0-9]+\.[0-9]+/ {$3=$3+a[j++]} \
? 1' file1 file2 > file3
$ cat file3
# comment here
90.0 355.0 2.09077

Qt Embedded exchanged colors bits: Red and Blue

I'm using QtEmbedded (4.8.0) on an ARM display device with 16bits color depth on the framebuffer (/dev/fb0). At this scenario we are getting the colors bits RED and BLUE exchanged.
We are using the following compile flags:
./configure -embedded arm -xplatform qws/linux-arm-gnueabi-g++ -prefix /home/rchaves/Toolchain -release -opensource -shared -fast -depths 16 -largefile -no-exceptions -no-accessibility -stl -no-sql-mysql -no-sql-psql -no-sql-oci -no-sql-odbc -no-sql-tds -no-sql-db2 -no-sql-sqlite -no-sql-sqlite2 -no-sql-ibase -no-qt3support -no-xmlpatterns -no-multimedia -no-audio-backend -no-phonon-backend -no-svg -no-webkit -no-javascript-jit -no-script -no-scripttools -no-declarative -no-declarative-debug -qt-zlib -qt-libtiff -qt-libpng -qt-libmng -qt-libjpeg -no-openssl -no-nis -no-cups -iconv -no-pch -no-dbus -qt-freetype -no-opengl -qt-gfx-linuxfb -qt-kbd-linuxinput -qt-mouse-tslib -nomake demos -nomake examples
And the following parameters to execute the application:
QWS_DISPLAY=LinuxFb:/dev/fb0:depth=16 ./app -qws
Here there are the application framebuffer (samples) log:
The framebuffer device was opened successfully.
Fixed screen info:
id: DISP3 BG
smem_start: 0x93800000
smem_len: 7864320
type: 0
type_aux: 0
visual: 2
xpanstep: 1
ypanstep: 1
ywrapstep: 0
line_length: 2048
mmio_start: 0x0
mmio_len: 0
accel: 0
The framebuffer device was mapped to memory successfully.
Successfully switched to graphics mode.
Variable screen info:
xres: 1024
yres: 768
xres_virtual: 1024
yres_virtual: 3840
yoffset: 0
xoffset: 0
bits_per_pixel: 16
grayscale: 0
red: offset: 0, length: 5, msb_right: 0
green: offset: 5, length: 6, msb_right: 0
blue: offset: 11, length: 5, msb_right: 0
transp: offset: 0, length: 0, msb_right: 0
nonstd: 0
activate: 64
height: -1
width: -1
accel_flags: 0x0
pixclock: 15385
left_margin: 157
right_margin: 157
upper_margin: 16
lower_margin: 15
hsync_len: 5
vsync_len: 1
sync: 0
vmode: 0
Frame Buffer Performance test...
Average: 43020 usecs
Bandwidth: 174.338 MByte/Sec
Max. FPS: 23.245 fps
Will draw 3 rectangles on the screen,
they should be colored red, green and blue (in that order).
Done.
Better late than never. I had this exact problem with a SAM5 processor using Qt5.5.1 and the linuxfb plugin. Reconfigure or recompile the Qt5 framework will NOT solve the problem.
Apparently the LinuxFB plugin does not support the BGR format. There is an open bug tracking this issue. Check the determineFormat function in ../src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp, in which you will find out that the ImageFormats are hardcoded to **RGB no matter what kind of framebuffer info was provided.
To solve the problem, applying the patch attached to the bug may help you to resolve this issue.
I said "may" because my framebuffer driver was falsely reporting it is in the RBG format. So watch out for that. If that is the case, just hardcode the swapRgb flag until you fix your framebuffer driver.
Update: Try setting -depths generic in ./configure and run with -display linuxfb:genericcolors. This is as per this thread which discusses the problem.
Old answer: It sounds like your endian-ness of the display is swapped.
As per the documentation, you can try to pass the littleendian option to the display string. The other option is to consult the linux fb documentation about performing endian swaps.