I developed a report in jasper wherein it displays a check symbol(✓) for existing records (i.e. list of requirements).
It seems like I would never had a problem displaying it since the check symbol is visible during preview in the iReport. But once I viewed the report in PDF format, the check symbol is no longer visible. I even tried unicode characters instead of the check image, even unicode for square root.
What configuration am I missing here?
Embedding the font in the report might solve your issue. This article discusses how to embed fonts using iReport and not using it: Embedding fonts into PDF generated by JasperReports
This is the way to add image of (check-mark) and build
To create parameter paramImage and set the image expression property as $P{paramImage}.
To passing value to this variable as
String imagePath = FacesContext.getCurrentInstance().getExternalContext().getRealPath("/images/IMAGE.jpg");
Then put parameters as given below
paramaters.put("paramImage",imagePath);
Related
I am working with BIRT(4.6) and Eclipse mars2(4.5).
I am creating a report using EngineConfig object and creating the report in HTML, PDF and EXCEL formats.
The number of the tables and data inside the table I am filling dynamically.
I am creating the CellHandle for each column in my report and adding the LabelHandle inside it. I was setting the width of a LabelHandle based on the size of the String that I am going to set it and All three reports(PDF, HTML and EXCEL) were displaying properly. But setting the LabelHandle width based string size, is not a good practice and sometimes data is missing in the reports.
So Tried with 'canShrink' property on LabelHandle as shown below.
labelHandleObj.setProperty("canShrink", "True");
The above statement automatically adjust LableHandle width based on the String size and this avoids me to set the LableHandle size manually based string size.
With the canShrink property my HTML report is generating properly with no data loss and No extract space/padding in cell. This is the way I want the report.
But when it comes to PDF and EXCEL, Tables are not displaying properly and all columns are shirked and data is not displaying properly. You can see the PDF Report by clicking the below link.
PDF Report after setting the canShrink property on LableHandle
Can any one kindly suggest me, how to get the data properly in PDF and Excel Report. But I want to use the CanShrink property, because it is creating the proper HTML report.I tried with both True and False value for CanShrink but no use with PDF and EXCEL.
Is there any way to get the three reports properly without using CanShrink.
Thanks in Advance.
When something like this happens you should try copy your table and insert it under original table, then hide original table from PDF using the visibility tab, then hide the copy from everything but PDF. I've done this a lot of times and it really solves the problem, but major disadvantage of this is that if you want to change something you have to do in two tables. Example report:
I need to get the number of lines in pdf file using java.
I used itext-2.1.7.jar to get the page count.
Is there any way to get the count of lines in pdf.
There's no easy way to do this, only aproximations. That problem is that a pdf page is a canvas with drawings at arbitrary locations and some of them happen to be fonts and text.
An approach is to extract the text and from the text location build a list of what you will consider a line. Use LocationTextExtractionStrategy to get this result but you'll have to use the more recent jar, itext 2.1.7 is too old and doesn't work that well with text extraction.
I have a library which generates pdf document with images.
I want to be able to add text after each image. What is the syntax for that? How to insert text into pdf documents?
I have to use the library I have, not another one.
First of all, mkl is correct, have a look at the specification for all of the details. PDF is an exact language, if you make mistakes they will routinely be punished severely once you open the PDF in viewers.
Secondly, when you think about putting text on the page, don't forget that besides the text operators to draw the text on the page, you'll also have to specify the font to use to draw this text. Which will include making sure there is a font resource included in the PDF file if your library doesn't automatically handle all of that for you.
If you want to cut corners (I shiver while writing this) and perhaps don't read the specification as thoroughly, try this.
1) Create a PDF file that looks more or less like what you want.
2) Use a tool such as pdfToolbox from callas (http://www.callassoftware.com/callas/doku.php/en:download) or Browser from Enfocus (http://www.enfocus.com/en/products/browser). Both of these tools allow you to investigate the low-level structure of a PDF file, including looking at the actual page description code. This will show you how fonts are embedded (if you have to do it yourself that could be very handy) and how text is rendered on the page (and how you set the font, size, color etc... to use).
In my application I have to fill a predefined PDF form with data from DB. We are using Java and Pdfbox. The filling itself is not a problem.
The problem is that in resulting PDF-file all texts in the form are invisible (or hidden, also grey rectangles) unless field clicked.
How can I solve this problem?
I had the same problem when I tried to programmatically fill PDF forms using pdfbox. I add this answer to a rather old question as all the other answers manipulate the original PDF, which is not always an option.
The problem with invisible form fields just appeared in Acrobat PDF, other PDF renderers showed it fine. If using pdfbox 1.8.x you have to set Need Appearances as explained here:
PDAcroForm form = docCatalog.getAcroForm();
form.getDictionary().setItem(COSName.getPDFName("NeedAppearances"), COSBoolean.TRUE);
If using pdfbox 2 this is simplified to:
PDAcroForm form = docCatalog.getAcroForm();
form.setNeedAppearances(true);
I read this on a forum and worked for me:
Using Adobe Acrobat Pro, I exported the form using "Export Data" to a XML and then imported it back from XML-file with "Import Data". Those commands are under Forms/Manage Forms Data
This is the link to the post: http://forums.adobe.com/thread/637421
I had this exact problem with a form I was filling with PDFBox in Java.
I fixed it by opening the original (blank) PDF form in Acrobat Pro and changing some options for each of the problem text fields. The options might vary for you, but here's what worked for me:
In the Acrobat Pro menu bar go to Forms > Add or edit fields.
Right click the text field in Acrobat Pro and select properties, then:
In the 'Options' tab:
Untick all options except 'scroll long text'
Add a few space characters in to the Default Value box
In the 'Appearance' tab:
Set the font size to 'auto'
Click 'close form editing' and save the file.
I just ran across this and tried a combination of things before one very simple thing worked. I have Adobe Acrobat 9.0 and I couldn't find some of the options written here.
What I ended up doing was a two-pronged process: I went to Forms > Manage Form Data > Export Data; I then saved that file on my desktop. Next, I went back to Forms > Manage Form Data but instead selected Import Data, and selected that file I'd just saved. Bingo! Everything filled in properly.
I don't quite know how you can stop it happening in the future but a resolution to getting the file working, similar to g-eorge is to open it in adobe acrobat pro, in tools on the right hand menu select "Interactive objects" and choose select object.
When you highlight the first field you want to fix, you should then be able to control-a to select all interactive objects. Once all are selected, right click on one field and select properties.
In the "general" tab the bottom option should have "common properties" which has the option "form field" change this to hidden and then back to visible. This will then restore all visibility to the form.
This has worked for me on all the rare instances when I receive this, and hasn't failed me once. Hope it does the same for you,
BoB
in the appearance tab of each erroneously hidden object you will see the "fill color" set to none. set it to none again (just click on it) and save the PDF and these fields will show up normally. I can't believe adobe has let this error persist for so long. It happens constantly when viewing/saving with multiple pdf readers.
Nothing I tried here worked - except to change software.
I was using PDFElement 6 Pro (trial) and couldn't make it work. Tried all sorts of things with PDFBox plus all suggestions above.
Ended up trying https://www.pdfescape.com/ and it all worked just fine.
In my case I solved it by changing the font to Arial (or one of the standard in windows set), in the 'Appearance' tab, in properties.
Before, it was set Helvetica which was not embedded in the file and that I think generated the problem.
Libraries/Tools used:
1) Jasper Reports
2) iReport
3) Java
I've already generated some standard barcodes for my reports, but this time, I'm trying to generate a custom barcode, for which I've a font file custom-barcode.ttf. As of now, iReport supports 2 barcode libraries - Barcode4j and Barbecue, which don't support the custom barcode that I need. Any ideas to get started, without much overhead of using some new library (I'm using Barcode4j already)?
BTW, I'm aware that a similar question (custom barcode font) exists on this site already.
Just tried #mdahlman's answer and it worked. I generated the value "CODE123" using a barcode39 font (free) and Jaspersoft Barbecue.
Setting the size is not very easy using the font but the result is the same. I verified the barcode using Barcode Scanner on my Android phone (can see it's visually similar too). The reason this worked for me, probably same reason #bchetty's test didn't work, is because Barcode39 doesn't have a check-digit. It is a 1-to-1 translation except with a leading and trailing asterisk (*) appended to the data. If you want to use a ttf to generate a barcode type that has a check-digit you'll need a function (external jar like you mentioned) to encode it. Barcode39 doesn't need a function since it's just "*" + V${data} + "*".
Given that you have custom-barcode.ttf, it really can be treated as text. So your steps are like this:
Create a font extension in iReport for custom-barcode.ttf.
Create a Text Field in the report with a relevant expression.
Set the font for the Text Field to "custom-barcode" (or whatever you call your font extension). Play with the font size to get the desired output.
Using a custom font for a barcode could be considered a bit of a hack. But what it lacks in flexibility it makes up for in simplicity.