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.)
Related
I want to create a pdf document using the TPPDF package in swift.
Is it possible to add in a specific cell multiple items?
I want to add a checkmark as image / Symbol and a related text behind it.
(No accessable element just indicator)
Column A
Column B.
'text'
image + 'text'
'text'
image + 'text'
I needed to split related information's in two rows which get split by the page break.
is it possible to avoid this?
e.g. ObjectA is indicated in 2 rows [row 1 & 2] with some vertical and horizontal merges.
when it comes to a page break, the vertical merges sometimes are divided by the page break.
[Sample Table Image Page break]
[Sample Table Image one object needs 2 rows]
I am new here. Any advice to improve this question to get better support appreciated.
The documents and APIs I noticed did not support anything like this.
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.
I've created a BIRT report in Eclipse (Juno) using BIRT v 4.2. The report has four tables, all tables are contained within grids. When I preview the report all the data displays properly, but if I select run as .pdf only a 2-3 rows of each table are displaying. I can export the report as html, xls and view it in web viewer without an issue. Has anyone else experienced this? (I've validated the sizing of the grid and tables).
I had the same issue and to overcome the problem I simply increased the size of the grid to fit the page manually.
If your rows are going to another page you need to script your way around that issue and you can find the solution here:
data cut when exporting as PDF
Update to cover broken link:
Quoting Michael Willians:
The PDF won't adjust like the GUI because of the fixed size constraint. To get a long, unbroken string to break, you'll have to add break characters of your own, either in a computed column or using a dynamic text box to write the script to break the long text up. Once you've broken the long text up, it should wrap to multiple lines within your PDF.
As an example, you could do something like this in a computed column, replacing "data1" with your column's name:
temp = "";
i=0;
while (i<row["data1"].length){
if (row["data1"].length - 10 < i){
temp = temp + row["data1"].substring(i,row["data1"].length);
}
else{
temp = temp + row["data1"].substring(i,i+10) + "\n";
}
i += 10;
}
temp;
To apply changes in the entire report, you could do a script in your beforeFactory method, stepping through your data elements, changing their expression. The easiest way would be to name your data elements, element1, element2, element2, etc., in the property editor. Then, you can easily access them by name, in your script.
Here's were you can edit the beforeFactory method, or any other:
You may also maintain a separate script with all your changes, as you can see on the resources directory:
Remember to add it as a Javascript resource:
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 ...
I am new to gwt and I am trying to check if the dynamic string document id that i am retrieving will will fit on the gwt label or not. Now I am checking for the number of characters and if the number exceeds 15 I am appending ... after 12 characters and displaying the actual id in the tooltip. I need to know how do i achieve this without calculating the number of characters. Please help
The width of a label does not only depend on the string size, but on the font used.
You could write you string in a temporary label attached to the dom and query the size using the method 'getClientWidth' of the element or gwtquery, and remove recursively the last character until you get the appropriate size.
In my opinion the easier way would be to use css and define a fixed width of your label and set the property overflow to hidden, so you see just the chars which fit in the label and you dont have to deal with a different string.