Problem with pdf rendering

0

Hello,

As you can see in the attached pdf file, the last  character of the many cells going on the line down.

When I launch the preview report it's ok, this don't happen.

Below the code of the method. I use jasperReports-4.02 and iText-2.1.7. 

Where I'm wrong? 

Thank you for your time.

 

Code:
    public ActionForward stampaJR1(ActionMapping mapping,
                                ActionForm form,
                                HttpServletRequest request,
                                HttpServletResponse response) throws Exception
    {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
 
        //HERE SOME PARAMETER FOR JASPER
        String pathFile = request.getSession().getServletContext().getRealPath("") + "/WEB-INF/report/report1.jasper";
        String pathFileImg = "niente";
 
        Map<String, String> lParameters = new HashMap<String, String>();
 
        lParameters.put("pathImg", pathFileImg);
 
        log.debug("PATH JAPSER: " + pathFile);        
 
        try 
        {
            // CREATE AND FILL THE DATASOURCE
            JRDataSource dataSource = null;
 
            AutoriModel autoriModel = new AutoriModel();
 
            java.util.Collection <Tautori> beanCollection = new ArrayList <Tautori> ();
 
            Tautori autori = new Tautori();
            ArrayList elencoAutori = autoriModel.getElencoAutoriNoQL();
 
            if ( elencoAutori != null)
            {
                beanCollection.addAll( elencoAutori ) ;
            }
            dataSource = new JRBeanCollectionDataSource( beanCollection );
 
            // FILL REPORT AND CREATE PDF STREAM
            if ( dataSource != null )
            {
 
                log.debug("STO RIMPIENDO IL JASPER");
 
                JasperPrint jasperPrint = JasperFillManager.fillReport( pathFile, lParameters, dataSource );
                log.debug("HO RIEMPITO IL JASPER");
 
                JasperExportManager.exportReportToPdfStream( jasperPrint, out );
            }
        } catch ( JRException e ) {
            log.error( e, e );
        } catch ( Exception exc ) {
            log.error( exc, exc );
        }
 
        // WRITE THE STREAM IN THE RESPONSE
        response.setContentType( "application/vnd.pdf" );
        response.setHeader( "Content-Disposition", "attachment; filename=reportElencoAutori.pdf" );
 
        ServletOutputStream output = response.getOutputStream();
        out.writeTo( output );
        output.flush();
 
        return mapping.findForward( SUCCESS );
    }



Post Edited by uliss3 at 04/22/2011 03:27



Post Edited by uliss3 at 04/22/2011 05:42
uliss3's picture
4
Joined: Apr 21 2011 - 7:36pm
Last seen: 8 years 10 months ago

10 Answers:

0

Can somebody at least tell me what I must search ?

Thank you.



Post Edited by uliss3 at 04/22/2011 18:36
uliss3's picture
4
Joined: Apr 21 2011 - 7:36pm
Last seen: 8 years 10 months ago
1

The same thing is happening to me. This is probably an iReport bug. When I upgrade from iReport 4.0.0 to 4.0.2, the bug occurs. When I revert to 4.0.0, the bug does not occur. Here is the problem. Some of the text from my report does not render correctly in PDF when I use 4.0.2. However, it does render correctly in the internal viewer. This means that iReport no longer renders text the same in PDF as in the internal viewer. I hope that someone can fix this!  I can send screen shots that illustrate the bug, if needed.

Bob M.

bobjasper's picture
Joined: Mar 10 2011 - 6:16am
Last seen: 6 years 1 month ago
0

The most common reason for a problem like this is fonts. You have one font in use at design time in iReport (maybe on Windows). You don't have this font available at run time on your server (maybe on Linux). The Windows/Linux difference is not required to have the problem... it's just a common situation.

This is surely the case for uliss3's problem. His jrxml file indicates that the font for some fields is Liberation Serif. But the PDF shows that only Helvetica (the default PDF font) is used in this file.

The solution: use font extensions.

Bob, it's not clear to me if your issue is identical or not. Presumably your iReport 4.0.0 and 4.0.2 are configured differently. Perhaps different classpaths. Look at the PDF files that come from each iReport. Do they use fonts the same way?

Font extensions ought to solve it for you as well. But if they don't... then it's possible there's a bug somewhere. You'll need to log a bug if you want someone to consider it. Be sure to include enough for someone to reproduce the problem.

Regards,
Matt

mdahlman's picture
11520
Joined: Mar 13 2007 - 2:43am
Last seen: 5 years 3 months ago
0

Bob I tried your instructions, but it's don't work. I solved the problem in the manner below descibed.

Thanks anyway for your reply.

uliss3's picture
4
Joined: Apr 21 2011 - 7:36pm
Last seen: 8 years 10 months ago
0

Thanks Matt, I solved the problem with "font extensions".

I write the complete instructions for other people.

ADD MISSING FONTS TO YOUR PROJECT (through iReport):

  • provide fonts in iReport : tools -> option-> iReport-> font -> install font-> selection the fonts
  • create .jar that's contains the fonts for your application. At the same window of the previous step, selection the font that you need and click on "export as extension" and save it in some place with the .jar "extension"
  • go in your IDE and insert the previous .jar in:

             1) Library, if your application is a web application

             2) otherwise, classes folder

Done... I hope :-)

 

Matt In the previous message you write that the problem is about the path where JRE search the fonts.

I have Debian Linux and Netbeans, how can I set this path for JRE (or my IDE) ?

 

Thank you again.

Alfonso.

 

 

 

            

 

 

    

 

 

 

uliss3's picture
4
Joined: Apr 21 2011 - 7:36pm
Last seen: 8 years 10 months ago
0
hi,
"font extensions"(followinf "uliss3" explanations) does not really work for me too.
I'm using font files from c:\\windows\\fonts\\, for example Calibri: creating jar, placing at classpath, recompile, etc.
In the final PDF file I see only Helvetica font, even thought in the iReport PDF Preview all fonts looks great(Calibri).
So may be the issue with exportReportToPdfStream() ?

Appreciate the help!
--Vitaly.
vitsin's picture
6
Joined: Jul 23 2010 - 11:52am
Last seen: 9 years 7 months ago
0

Im having the same problem... i had to made the downgrade to 4.0.1 to make it work... exporting the font dont work for me... maybe it could be a bug...

lucassorrentino's picture
Joined: May 13 2010 - 7:45am
Last seen: 9 years 9 months ago
0

JasperReports Guys! Can you please bring a light on it?

thanks.

vitsin's picture
6
Joined: Jul 23 2010 - 11:52am
Last seen: 9 years 7 months ago
0

Same problem at my report. Can anybody please give a note on that?

THX

 

thezeb's picture
18
Joined: Jun 10 2011 - 1:16am
Last seen: 8 years 8 months ago
0
Hi together,

the bug has already been reported:
http://jasperforge.org/projects/jasperreports/tracker/view.php?id=5200

thezeb's picture
18
Joined: Jun 10 2011 - 1:16am
Last seen: 8 years 8 months ago
Feedback
randomness