Jump to content
We've recently updated our Privacy Statement, available here ×

ziden

Members
  • Posts

    12
  • Joined

  • Last visited

ziden's Achievements

Apprentice

Apprentice (3/14)

  • Week One Done
  • One Month Later
  • One Year In
  • First Post Rare
  • Collaborator Rare

Recent Badges

0

Reputation

  1. Just posting to show progress. Ive managed to make the whole PDF with the bookmark menu, however i couldnt anchor it correctly. How could i ? Heres the code i have so far: PdfReader reader = new PdfReader(new FileInputStream("C:/Curso.pdf")); Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("C:/Menu.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); // Load existing PDF int paginas = reader.getNumberOfPages(); for(int pag = 1 ; pag <= paginas ; pag ++) { PdfImportedPage page = writer.getImportedPage(reader, pag); document.newPage(); cb.addTemplate(page, 0, 0); } PdfOutline root = cb.getRootOutline(); // Code 3 PdfOutline oline1 = new PdfOutline(root, PdfAction.gotoLocalPage("prof", false),"Profissional"); PdfOutline oline2 = new PdfOutline(root, PdfAction.gotoLocalPage("reconhecimento", false),"Reconhecimento"); oline2.setOpen(false); PdfOutline oline2_1 = new PdfOutline(oline2, PdfAction.gotoLocalPage("2.1", false),"Sub 2.1"); PdfOutline oline2_2 = new PdfOutline(oline2, PdfAction.gotoLocalPage("2.2", false),"Sub 2.2"); PdfOutline oline3 = new PdfOutline(root, PdfAction.gotoLocalPage("opcaolingua", false),"Opção Língua"); document.close(); At my iReport, i added some anchor tags such as <anchorNameExpression>"prof"<\anchorNameExpression> but when i click the following bookmark PdfOutline oline1 = new PdfOutline(root, PdfAction.gotoLocalPage("prof", false),"Profissional"); it doesnt redirects me into the selected anchor. Is there something i am doing wrong ?
  2. Just posting some improvements. Im using the following code to generate an empty pdf for example with that bookmark menu Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("C:/Menu.pdf")); document.open(); document.add(new Chunk("Chapter 1") .setLocalDestination("chappy1")); PdfContentByte cb = writer.getDirectContent(); PdfOutline root = cb.getRootOutline(); PdfOutline oline1 = new PdfOutline(root, PdfAction.gotoLocalPage("chappy1", false),"Go to Chapter 1"); So, this is kinda simple: i can create an anchor and link the bookmark to the anchor on a new PDF. What i need is, to do this onto an existing PDF with previously anchors created. Ireport allows me to create anchors with the <anchorNameExpression> tag, all i would need to do is open that pdf and add the bookmark menu to it but it seems i cannot do that, at least not as im tryng to do. I belive this would be usefull to many of you as well as it would be to me. Does anyone have any idea on how to do that ? My last tryout was doing a Menu.pdf and a Main.pdf, one with anchors other with bookmarks, then i tryed to concat em both using this code: public static void concatenarPdfs(List<InputStream> pdfs, FileOutputStream out) throws Throwable { PdfCopyFields copy = new PdfCopyFields(out); for(int x = 0; x < pdfs.size() ; x++) { //byte [] temp = pdfs.get(x) byte[] bytes = new byte[pdfs.get(x).available()]; // cria vetor de bytes do tamanho dos bytes do pdf pdfs.get(x).read(bytes); // passa os bytes pro vetor PdfReader reader = new PdfReader(bytes); // cria um pdfreader com os bytes do pdf lido copy.addDocument(reader); // junta os 2 } copy.close(); } It concatenates both pdfs nicely, but it doesnt keep the bookmarks :( Does anyone have any ideas on how this could be possible ? Thanx for any attention, i would apreciate it.
  3. Hello there. Is it possible to make iText open a previously made PDF by ireport, and add marks on it ? Im not sure how would be done, heres what ive got: Paragraph cTitle = new Paragraph("This is chapter " + i, chapterFont); writer.setViewerPreferences(PdfWriter.PageModeUseOutlines); Chapter chapter = new Chapter(cTitle, 0); section.add(Chunk.NEXTPAGE); document.add(chapter); is this correct ? how could i open a PDF with some anchors and link them to marks so people who open the pdf can navigate easyly ? Thanx for any attention.
  4. Hello there everyone. Im having a little issue using a pre-made scriptlet, and i belive this is related to classpathing. This is the dir path to the scriptlets: C:\DesenWeb\Acad\acad\WEB-INF\classes\pckAcadRelatorios\Scriptlets this is the classpath ive added into ireport options C:\DesenWeb\Acad\acad\WEB-INF\classes\ then , i added the scriptlet as: pckAcadRelatorios.Scriptlets.HeadingsScriptlet it finds the scriptlet to compile the report. i also add the scriptlet using a parameter REPORT_SCRIPTLET like this: HeadingsScriptlet myscriptlet = new HeadingsScriptlet(); parameters.put("REPORT_SCRIPTLET", myscriptlet); But then, during the report i have the following: <printWhenExpression><![CDATA[(pckAcadRelatorios.Scriptlets.HeadingsScriptlet)($P{REPORT_SCRIPTLET}).addHeading("ShipCountryGroup")]]></printWhenExpression> When i run the application that creates the PDF, it gets me the following error: Error evaluating expression : Source text: (pckAcadRelatorios.Scriptlets.HeadingsScriptlet)($P{REPORT_SCRIPTLET}).addHeading("ShipCountryGroup") Anything am i doing wrong ? Ive tryed adding the wholeclasspath, no deal, tryed many things couldnt make this work. Any ideas ? thanx for any attention ! []´s Ziden
  5. im sorry, how could i transform the byte [] into a InputStream ? Im not familiarized with this things. Thanx for your help !
  6. Hallo there. Im tryng to create a InputStream list of a PDF list. Heres what ive came from so far: JasperPrint rel = JasperFillManager.fillReport(caminhoJasper + "/CertificadoConclusao/CertificadoConclusao.jasper", parameters, relatorioDataSource); JasperExportManager.exportReportToPdfFile(rel ,caminhoStorage + "CertificadoTemporario.pdf"); listStream.add(new FileInputStream(caminhoStorage+"CertificadoTemporario.pdf")); File pdf = new File(caminhoStorage + "CertificadoTemporario.pdf"); if(pdf.delete()) System.out.println("DELETED") else System.out.println("NOT DELETED"); So, actually im doing it the 'noobish' way, since i create the pdf, get its inputstream, adds to a list, then tryes to delete the PDF but it seems i cannot delete the PDF. Anyone got any tips on how could i do this ? Thanx for any help []´s Gabriel
  7. Hallo everyone. Ive got a report that is 510 pixels width. Im using the following code to generate an RTF over this report: JRRtfExporter exporter = new JRRtfExporter(); File rtf = new File( caminho + "Curso.rtf" ); exporter.setParameter( JRExporterParameter.JASPER_PRINT, jPrint ); exporter.setParameter( JRExporterParameter.OUTPUT_FILE, rtf ); exporter.setParameter( JRExporterParameter.IGNORE_PAGE_MARGINS, true ); exporter.setParameter( JRExporterParameter.OFFSET_X, 0 ); exporter.exportReport(); Now, what happens is, the RTF document have a very smaller width then my report, even having loads of free space to write. So a line that was being something like (a textField) "hello, this is a bigger line then a normal one" in RTF comes like "hello, this is a bigger line then a normal one" Is there anyway i can make the RTF bigger, so the report would fit perfectly on it ? Thanx for any help. Regards Ziden.
  8. Hello everyone. Im having a lil trouble making a report i made working correctly in Unix. What happens is the following, my report datasource is a XML comin from a CLOB on a DD2 structure. The XML may contain unicode special characters such as Ç for example. By the time the report is generated on Windows, the unicode is correctly read and i can see proper characters. However, when the report is generated under a Unix SO, the characters are not read as they should, theyr read by the report as hash characters that should represent the original unicode one. Ive read a lil bit about how to add a font on a report specifically, the both ways: Or adding it as a font map into java code (OLD) or creating a font jar to the report, so the Unix could use the same font windows is using. Using the fontmap havent won the deal, the 'jar way of life' havent been tested yet. Still im not sure if, this is a problem of font or its more complicated then that. I wish to know if anyone there has any valuable information that could help me solve this. Thanx for your attention and for any help. Regards, Ziden.
  9. Ive added ARial Unicode on my classpath, embed on PDF, made a JAR out of it and implemented that jar on classpath... still, the PDF aint showing the unicode character =( Post Edited by ziden at 09/27/2010 15:18
  10. Sorry for the double posting. Ive got a 'half way' solution to this. Ive added the following to my code: HashMap fontes = new HashMap(); HashMap fontMap = new HashMap(); FontKey key = new FontKey("Arial", false, false); //(String fontName, Boolean bold, Boolean italic) PdfFont font = new PdfFont("C:/windows/Fonts/ARIAL.TTF", com.lowagie.text.pdf.BaseFont.IDENTITY_H ,true); //(String pdfFontName, String pdfEncoding, Boolean isPdfEmbedded) fontMap.put(key,font); exporter.setParameter(JRPdfExporterParameter.CHARACTER_ENCODING, "UTF-8"); exporter.setParameter(JRPdfExporterParameter.FONT_MAP, fontMap); This way, when i run the PDF throw Java and not thro Ireport, i can see the /u unicode characters. However, i had a simple HTML formatting in strings such as <b> and <br> , witch, dont run anymore if i use those lines. Another problem is, im using Arial witch is a Windows Font. I wish to know if is there any font option that includes Linux OS, witch is our server and DB. Thanx for any help. []´s Gabriel
  11. Hello there. Ive found some topics at this and other forums about this, but im a Jasper begginer and couldnt doit. Ive got a database witch will have a string containing HTML simple tags such as BOLD or ITALIC witch is working perfectly. I also have some Unicodes such as \u2663 , witch in this fact is the "clubs" from card set. The fact is, in Jasper Preview it works perfectly, but when it comes to PDF it doesnt work. Im using jasper 3.7.4 and im not initializing the jasper via Java till now, still only workin at Ireport. Is there any simple solution to this ? Thanx alot for any help. []´s Gabriel Ziden
  12. Hello there. Im having an issue about passing an two dimensional array to jasper so he can build up some sort of table with it. Its a normal table, with 2 variables that represent lines/columns. The array is filled during the Java process and its sent to Jasper as a Class into a JRBeanCollection. What ive needed to do is reading the lines size of the array, then draw some sort of table representing the array positions. Is that possible ? Witch one would be the better way of acomplishing that ? Ive seem some methods on Jasper but im not sure on how to, that would be the CrossTable and the Sub-Report for instance. Thanx for any help. PS: Im using IReport 1.2.6 for this task. I know its an Older Version, but its what we gotta use here to work it out. Thanx. []´s Gabriel Slomka Unicamp - Brazilian State University
×
×
  • Create New...