Jump to content

farrukh.najm

Members
  • Posts

    2
  • Joined

  • Last visited

farrukh.najm's Achievements

Newbie

Newbie (1/14)

  • Week One Done
  • One Month Later
  • One Year In
  • First Post Rare
  • Conversation Starter Rare

Recent Badges

0

Reputation

  1. @hozawa Thanks for your help. Can you be more specific as to what the code would look like if I want to set default font for normal, bold, italic, boldItalic font face and sepcifu pdf Encoding and whether the font is embedded or not for my entire report. I created a FontFamily using code below but then I do not know how to set this as the default for my entire PDF report: SimpleFontFace fontFace = new SimpleFontFace(_reportContext); fontFace.setTtf(REPORT_FONTS_PATH + "arial.ttf"); fontFamily.setNormalFace(fontFace); fontFace = new SimpleFontFace(_reportContext); fontFace.setTtf(REPORT_FONTS_PATH + "arialbd.ttf"); fontFamily.setBoldFace(fontFace); fontFace = new SimpleFontFace(_reportContext); fontFace.setTtf(REPORT_FONTS_PATH + "ariali.ttf"); fontFamily.setItalicFace(fontFace); fontFace = new SimpleFontFace(_reportContext); fontFace.setTtf(REPORT_FONTS_PATH + "arialbi.ttf"); fontFamily.setPdfEncoding("Cp1252");At this point I have a FontFamily all good to go but how to I set this for my entire report as default? How can I pass this FontFamily to my JRPdfExporter?
  2. I am migrating some legacy JasperReports client code from Jasper 3.7 to Jasper 6.3. The code uses PdfFont class to do font mapping when exporting report to PDF. The font mapping API in Jasper 6.3 seems to have changed a lot from 3.7 and I cannot find any examples of how to replace code to match new API. The current code looks like this: String jasperTemplateFileName = ....; JasperPrint jp = JasperFillManager.fillReport( jasperTemplateFileName, _jasperParams ); File generatedPDFFile = ...; String outputFileName = generatedPDFFile.getAbsolutePath(); JRExporter exporter = new JRPdfExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp); exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, outputFileName); //Do font mapping. This is where I am having trouble HashMap fontMap = new HashMap(); PdfFont boldPdfFont = new PdfFont(REPORT_FONTS_PATH + "arialbd.ttf", "Cp1252", true); FontKey fontKey = new FontKey("SansSerif",true,false); fontMap.put(fKey, boldPdfFont); exporter.setParameter(JRExporterParameter.FONT_MAP, fontMap); exporter.exportReport();[/code] There is no PdfFont class in Jasper 6.3 and the replacement code is not obvious to me. Here is what I have so far: Exporter exporter = new JRPdfExporter(); exporter.setExporterInput(new SimpleExporterInput(jp)); exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(outputFileName)); SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration(); configuration.setPermissions(PdfWriter.ALLOW_COPY | PdfWriter.ALLOW_PRINTING); //How to do font mapping here?? exporter.exportReport();[/code] TIA for any guidance.
×
×
  • Create New...