Is it possible to count line shapes in a PDF page using iText 7 - itext

How to get the count of all line shapes created by PdfCanvas.stroke() method?
let pdfDictionary = pdfDocument.GetPage(1).GetPdfObject()
let foundObjects = pdfDictionary.GetAsDictionary(PdfName.???)
What 'PdfName' property should be used as a parameter? 'PdfName.Line' does not work.
Maybe I am looking wrong way.
EDIT:
Some PDF pages have one line and some three lines and it is the only one attribute for filtering documents. I need to filter documents by the count of these lines.
Maybe I have to find another way for achieving this goal.
By the way, lines are black and have fixed position and size. Maybe I should check the spot color at certain positions? If it is possible...
Thanks in advance.

Related

Remove value in circle Swiftcharts

At the momtent I try to find out how I can make the table that I would need for my app. I would like to remove the value in the circles.
But now I came across the possibility during my search that it is possible to hide the value in the circle.
This should be possible with LineChartData.drawValuesEnabled = false. However, I can not find the same in the Swiftcharts code, so I wonder if this option has been removed or is it called / works differently?
Values should be removed from DataSet, not from LineChartData.
This code might help you.
let set1 = LineChartDataSet(entries: values)
set1.drawValuesEnabled = false

Swift - print each item in an array to different rows on a UILabel

I am completely new to Swift but am loving my journey so far. I was wondering if anyone could help me with a slight issue of mine.
I am currently trying to print each item in an array to a different row on a UILabel.
I should be using a for loop but I am wondering how to structure the inside of the loop so that each item in the array prints on a separate line of the label.
As a bonus question, would a label even be the best way to display this? (Especially if the array has a lot of items). Maybe a ScrollView?
Thanks in advance for any responses. All help is appreciated.
The easiest way would be the following.
// Label will show as many lines as needed
label.numberOfLines = 0
// Join strings with new line characters so each string is a separate line
label.text = arrayOfStrings.joined(separator: "\n")

cannot find css element in protractor

How do I locate the element with the following html, I have 4 Start buttons each in different color. I tried using css by class and is not working. There are no unique ids as well. Pls help
Start
As Ben Mohorc points out, you really need to give us a bit more to go on. But if you are saying there are multiple start buttons, but only one of each color, it ought to look like this. For now I assume all they say is "Start". If that is only part of what they say, use partial buttontext.If it is background color that differs, you may need to adapt that, too.
var coloredButton = element.all(by.buttonText('Start')).filter(function(elem) {
return elem.getCssValue('color').then(function(color) {
return (color == '#00ff00')//fill in the desired color here, in this format
})
});
Then do your stuff on coloredButton.first(), which will be the only one, according to what you are saying.
For more on the format to expect from the color, see http://www.protractortest.org/#/api?view=webdriver.WebElement.prototype.getCssValue

iTextSharp - Reading PDF with 2 columns

I'm having trouble reading a PDF with header and footer but with 2 columns in your body.
I already have the column widths and height of the header but I need the code to read the pages with columns.
Can anyone provide me a piece of code that reads PDF with columns?
thank you
It's very hard to achieve what you want if you don't know the position of the columns, but I assume that you have its coordinates because you say "I already have the column widths and height". In that case, your question isn't that different from this other question posted on StackOverflow: iTextSharp read from specific position
Suppose that rect is a Rectangle corresponding with the position of a column, then you need this code:
RenderFilter[] filter = {new RegionTextRenderFilter(rect)};
ITextExtractionStrategy strategy = new FilteredTextRenderListener(
new LocationTextExtractionStrategy(), filter);
String single_column = PdfTextExtractor.GetTextFromPage(reader, i, strategy));
Now you have the text in a single column. You need to repeat this for every column on your page.
Extra comment: While in most cases using the RegionTextRenderFilter will work just fine, a few cases (in which columns are created by simply inserting additional space characters in the lines) might require to split the text chunks to process in advance. This can be done e.g. by using the TextRenderInfoSplitter from this answer and wrapping the FilteredTextRenderListener in it. (This comment was provided by mkl.)

stretch a textField to a max height in jasper reports

I think this is more of a general issue. I would like to use a textfield that gets dynamic data and doesn't stretch more than a given max height. For instance, I have a textfield that, if it gets text that fits in one line, the textfield will be one line height, and i have other elements under it, that will move up with float positioning. Or, if I want a 3 line max height and if the text exceeds that space, then the rest will be trimmed.
I don't want to use java expressions to trim that text, as it is not always accurate. I am new to jasper and I am trying to know if there is any way to do this. I did a lot of searches, but maybe there is something that i missed, and i hope someone can help me. Thank you
I managed to solve this by extending net.sf.jasperreports.engine.fill.TextMeasurer and overriding initialize() method; also I had to extend net.sf.jasperreports.engine.util.AbstractTextMeasurerFactory and override the createMeasurer() method.
Now, whenever I want to have max # of lines, with no overflow, I add a property to that text field (e.g. maxLines) which is being passed to my custom TextMeasurerFactory. I hope this helped you.
We had a similar problem at work with JASPER Reports 4.5, where we had an invoice with a header and a table. We wanted the header to have dynamic height based on the lengths of certain fields (like address, partner name, etc,), but not more than a critical limit, otherwise the header will push the table and thus making a mess by splitting it across multiple pages. Also, the invoice shouldn't exceed 1 page.
We eventually had to move the header in the background section, where we also put a background for the table consisting of vertical lines (so it will extend to the end of an A4 page) and a white opaque square.
This way, if the header exceeds the max height it will go underneath the table's background, cropping the text. This was the desired effect we were looking for.
Sounds crazy, but it worked ...