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

eyvind.almqvist

Members
  • Posts

    14
  • Joined

  • Last visited

eyvind.almqvist'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. I have taken over a system from a previous developer. He tried to show a picture of a static PDF-file in a subreport between the header and footer. The picture is created with an InputStream to an ImageBuilder. But the picture of the PDF-file gets blurry and I can not change the margins and set the correct width (see the attached screenshot). Has the previous developer choosed a wrong way of doing this? Is it recommended to just attach the static PDF-file last in the report instead? I mean without mixing it with header and footer and without the problem of the margins. This could maybe be done with PdfCopy and PdfReader. Here is my code for creating the InputStream: final byte[] pdfImageByteArray = IOUtils.toByteArray(imageBuffer.getInputStream()); // Loading an existing PDF document PDDocument document = PDDocument.load(pdfImageByteArray); final int nrOfImages = document.getDocument().getObjects().size(); PDFRenderer renderer = new PDFRenderer(document); for (int i = 0; i < nrOfImages; i++) { // Rendering an image from the PDF document BufferedImage buf_image; try { buf_image = renderer.renderImage(i); } catch (Exception e1) { break; } imagesFromPDFItem.getImageContentList().add(toByteArray(buf_image, "png")); } Here is my code for the subreport with the picture of the PDF-file: private void createImage(final JasperReportBuilder parentReportBuilder, byte[] contentOfStaticPDF) { JasperReportBuilder reportBuilderForSubreport = report(); final int PAGE_WIDTH = 450; ImageBuilder imageBuilder = cmp.image(getContentAsInputStream(contentOfStaticPDF)); imageBuilder.setFixedWidth(PAGE_WIDTH); imageBuilder.setStretchType(StretchType.CONTAINER_HEIGHT);//needs to be there, otherwise the images of the PDFs get very small MarginBuilder marginBuilder= margin(); int margin=1; marginBuilder.setLeft(margin); marginBuilder.setRight(margin); reportBuilderForSubreport.setPageMargin(marginBuilder); reportBuilderForSubreport.detail(imageBuilder); reportBuilderForSubreport.detail(cmp.pageBreak());//needs to be there, otherwise the images of the PDFs get very small SubreportBuilder subreport = cmp.subreport(reportBuilderForSubreport).setDataSource(createFakeDataSource()); parentReportBuilder.detail(subreport); }
  2. rsneha027, I tested your solution. The only difference in it is that jasperReportBuilder.setPageMargin(margin().setLeft(0).setRight(0).setBottom(0).setTop(0)); is called before jasperReportBuilder.detail() But it is the same problem. The subreport gets the margin of the parent report and the margin I set in the image builder makes no difference. I still can not set the width of the image over a certain value. If I do that, the image is not shown. How can I solve this? This is my new code: private void createImage(final JasperReportBuilder reportBuilder, byte[] content) { //the subreport: JasperReportBuilder jasperReportBuilder = report(); final int PAGE_WIDTH = 455; //set up an imagebuilder: ImageBuilder imageBuilder = cmp.image(getContentAsInputStream(content)); imageBuilder.setFixedWidth(PAGE_WIDTH); imageBuilder.setStretchType(StretchType.CONTAINER_HEIGHT);//needs to be there, otherwise the picture gets very small imageBuilder.setHorizontalImageAlignment(HorizontalImageAlignment.LEFT); imageBuilder.setImageScale(ImageScale.FILL_FRAME); jasperReportBuilder.setPageMargin(margin().setLeft(0).setRight(0).setBottom(0).setTop(0)); //Adds components to the detail band : jasperReportBuilder.detail(imageBuilder); jasperReportBuilder.detail(cmp.pageBreak());//needs to be there, otherwise the picture gets very small //add subreport to the parent report: //creates a a SubreportBuilder from a JasperReportBuilder SubreportBuilder subreport = cmp.subreport(jasperReportBuilder).setDataSource(createFakeDataSource()); //add subreport to report : reportBuilder.detail(subreport); }
  3. I am including an image at the end of a report. It is an image of a PDF-file. The image gets a blurry resolution, because I can not make it bigger and I can not make the margins smaller. I try to increase the width with this: imageBuilder.setFixedWidth(PAGE_WIDTH); But if I set the width over 440, the image is not shown at all. I don't why, because the value 440 does not appear anywhere in my project. I try to make the margins smaller with this: jasperReportBuilder.setPageMargin(margin().setLeft(0).setRight(0).setBottom(0).setTop(0)); but large margins are still shown around the image. I attached a picture of how it looks like. How can I set higher width on the image and set lower margins? This is all my relevant code: private void createImage(final JasperReportBuilder reportBuilder, byte[] content) { JasperReportBuilder jasperReportBuilder = report(); ImageBuilder imageBuilder=cmp.image(getContentAsInputStream(content)); imageBuilder.setFixedHeight(PAGE_HEIGHT); imageBuilder.setFixedWidth(PAGE_WIDTH); imageBuilder.setStretchType(StretchType.CONTAINER_HEIGHT); jasperReportBuilder.detail(imageBuilder); jasperReportBuilder.detail(cmp.pageBreak()); jasperReportBuilder.setPageMargin(margin().setLeft(0).setRight(0).setBottom(0).setTop(0));
  4. It is like Jgust said.Each textfield must to be in a "Group header-band". Choose create group. Then create the group header, but not the group footer. Then put a textfield inside the group header.
  5. I followed the instructions from "rushinde", but it did not solve the issue. The only property related to this in the Textfield documentation link is "textAdjust". That was already set to "StretchHeight", so the information in the documentation did not help. I also tested different stretch types on "appearance". So I believe that "jgust" is correct, that it can not be solved in an easy way. Is it a bug in JasperSoft Studio, which makes this simple issue to difficult to solve?
  6. I need to set the height of the textfields according to the content of the text, so they don't write over the textfields below. There are 3 textfields in my example; "name", "street" and "zipcode_and city". The streetnames can be very long in China and Japan. Then this problem occurs. I have used the test text "Box 1234512345123451....." for the street name. The "zipcode_and city" textfield is written over by this text as my attached picture shows. How can I set the height of the textfields according to the content of the text so the textfields below are not written over? I have tried suggested solutions for this from this forum, like setting "text adjust" to "stretchheight", "position type" to "float", "stretch type" to "relativeToTallestObject", It is also suggested to check the checkbox "stretch with overflow", but no such checkbox exists. I have JasperSoft Studio 6.20.
  7. This does not work, because there is no option "stretch with overflow" in version 6.20
  8. I have tried the solution described here,but no effect! I have version 6.20. Yes, the textfield get bigger, but it collides with the text in the textfield under it.How can it be solved?
  9. Do you mean that I have to add a <pageHeader> with <textField evaluationTime="Master">? Then I should set the font of the page number in that textfield? There is no <pageHeader> in my files. The font of the page number is set nowhere, but it is SansSerif 10. Is this the default page number font, which comes by default from Jasper Studio? Is this where you set the font of the page number? <textField evaluationTime="Master"> <reportElement x="519" y="12" width="233" height="13" uuid="b9164ec1-ad06-4dae-b0ce-3e8151779813"> <property name="com.jaspersoft.studio.unit.y" value="px"/> </reportElement> <textElement textAlignment="Right"> <font fontName="Arial" size="8"/> </textElement>
  10. I don't find any master page, so it is difficult to apply your solution. I took over this project from a consultant, who build it. The subreports are put together by Java code. Do I have to have a master page to set the page number ? I don't find any component related to page number in the pages. How come the page numbers are shown then? Is it default numbering? This is my code: ReportTemplateItem reportTemplateItem = (ReportTemplateItem) item;addPageHeader(reportBuilder, report, messages, reportTemplateItem);addPageFooter(reportBuilder, report, messages, reportTemplateItem);reportHeaderNationalApplication.createSubreport(reportBuilder, report, item, messages);writtenReplyMustBeReceived.createSubreport(reportBuilder, report, item, messages);horizontalLine.createSubreport(reportBuilder, report, item, messages);reportHeaderTemplateText.createSubreport(reportBuilder, report, item, messages);nationalOfficerSignature.createSubreport(reportBuilder, report, item, messages);
  11. I have a report which contains several subreports, so several jrxml files. I assume that page numbering is controlled by the composite element "page number"? I right click on "page number" and then click on layout and settings. But I don't find any way of changing the font.
×
×
  • Create New...