السلام عليكم ورحمة الله وبركاته
اريد ان ارفق صورة عند طباعة التقرير بااستخدام ireport مع الجافا طبعاً
شاهدت فيديو يشرح كيفية اضافه الصور وطبقتها ..ولكنها لم تعمل معاي
قمت بتجهيز parameter مع التأكد من انه inputstream
والصوره كذاك..
كتب هذا الكود بناء على ماشهته ولكنه لم تعمل
مع العلم ان الصورة ثابته..اي لا اريد ان تتغير
قبيل طرح هذا الموضوع سألت هذا السؤال بأحد المواضيع الاخرى لكن لم اجد اي تجاوب ..
لذا اعتذر عن اعادة السؤال بموضوع مستقل ...
انا فاهمه الفكره لكنها لا تعمل .. اريدها ان يكون ال path من نفس package لا اريد اضافه ال path بصورة الاصليه
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
Date data = new Date();
String Data = format_data.format(data);
String Time = format_time.format(data);
Map parameters = new HashMap();
try {
String source = "src/kiubo/newReport3.jrxml";
JasperReport jr = JasperCompileManager.compileReport(source);
parameters.put("student_Id","10203394");
parameters.put("date",Data);
parameters.put("time",Time);
parameters.put("image", this.getClass().getResource(image));
//parameters.put("myImg", imgInputStream);
JasperPrint jp = JasperFillManager.fillReport
(jr, parameters, connection_11.getConnection());
JasperViewer jasperViewer = new JasperViewer(jp, false);
jasperViewer.setTitle("Testreport");
jasperViewer.setName("Testreport");
jasperViewer.setAlwaysOnTop(true);
jasperViewer.setVisible(true);
}
catch (Exception e) {
System.out.println(e);
}<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report name" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<parameter name="student_Id" class="java.lang.String">
<defaultValueExpression><![CDATA[]]></defaultValueExpression>
</parameter>
<parameter name="date" class="java.lang.String">
<defaultValueExpression><![CDATA[]]></defaultValueExpression>
</parameter>
<parameter name="time" class="java.lang.String" isForPrompting="false">
<parameterDescription><![CDATA[]]></parameterDescription>
<defaultValueExpression><![CDATA[$P{time}]]></defaultValueExpression>
</parameter>
<parameter name="image" class="java.io.InputStream" isForPrompting="false">
<defaultValueExpression><![CDATA[$P{image}]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[SELECT
student.`StudentId` AS student_StudentId,
student.`ClassLevel_index` AS student_ClassLevel_index,
student.`Age` AS student_Age,
student.`FirstName` AS student_FirstName,
student.`LastName` AS student_LastName,
student.`Location` AS student_Location,
student.`Gender` AS student_Gender,
student.`HomePhoneNumber` AS student_HomePhoneNumber,
classlevel.`ClassLevel` AS classlevel_ClassLevel,
diagnosis_new.`student_Id` AS diagnosis_new_student_Id,
diagnosis_new.`resultOfDiagnosis_EN` AS diagnosis_new_resultOfDiagnosis_EN,
diagnosis_new.`recommendation_EN` AS diagnosis_new_recommendation_EN,
diagnosis_new.`timeOfDiagnosis` AS diagnosis_new_timeOfDiagnosis,
diagnosis_new.`DateOfDiagnosis` AS diagnosis_new_DateOfDiagnosis,
diagnosis_new.`ResultOfDiagnosis_AR` AS diagnosis_new_ResultOfDiagnosis_AR,
diagnosis_new.`questions_answersOfDiagnosis` AS diagnosis_new_questions_answersOfDiagnosis,
diagnosis_new.`Recommendation_AR` AS diagnosis_new_Recommendation_AR
FROM
`classlevel` classlevel INNER JOIN `student` student ON classlevel.`index` = student.`ClassLevel_index`
INNER JOIN `diagnosis_new` diagnosis_new ON student.`StudentId` = diagnosis_new.`student_Id`
WHERE
student.`StudentId` = $P{student_Id}
AND diagnosis_new.`DateOfDiagnosis` = $P{date}]]>
</queryString>
<field name="student_StudentId" class="java.lang.String"/>
<field name="student_ClassLevel_index" class="java.lang.Integer"/>
<field name="student_Age" class="java.lang.Integer"/>
<field name="student_FirstName" class="java.lang.String"/>
<field name="student_LastName" class="java.lang.String"/>
<field name="student_Location" class="java.lang.String"/>
<field name="student_Gender" class="java.lang.String"/>
<field name="student_HomePhoneNumber" class="java.lang.String"/>
<field name="classlevel_ClassLevel" class="java.lang.String"/>
<field name="diagnosis_new_student_Id" class="java.lang.String"/>
<field name="diagnosis_new_resultOfDiagnosis_EN" class="java.lang.String"/>
<field name="diagnosis_new_recommendation_EN" class="java.lang.String"/>
<field name="diagnosis_new_timeOfDiagnosis" class="java.lang.String"/>
<field name="diagnosis_new_DateOfDiagnosis" class="java.lang.String"/>
<field name="diagnosis_new_ResultOfDiagnosis_AR" class="java.lang.String"/>
<field name="diagnosis_new_questions_answersOfDiagnosis" class="java.lang.String"/>
<field name="diagnosis_new_Recommendation_AR" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch">
<image>
<reportElement x="0" y="0" width="410" height="79"/>
<imageExpression><![CDATA[]]></imageExpression>
</image>
</band>
</title>
<pageHeader>
<band height="97" splitType="Stretch">
<staticText>
<reportElement x="0" y="0" width="277" height="97"/>
<textElement>
<font size="24" isBold="true"/>
</textElement>
<text><![CDATA[Test]]></text>
</staticText>
</band>
</pageHeader>
<columnHeader>
<band height="61" splitType="Stretch">
<staticText>
<reportElement x="0" y="41" width="56" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center"/>
<text><![CDATA[ID]]></text>
</staticText>
<staticText>
<reportElement x="56" y="41" width="41" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center"/>
<text><![CDATA[First Name]]></text>
</staticText>
<staticText>
<reportElement x="97" y="41" width="65" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center"/>
<text><![CDATA[Last Name]]></text>
</staticText>
<staticText>
<reportElement x="162" y="41" width="77" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center"/>
<text><![CDATA[class level]]></text>
</staticText>
<staticText>
<reportElement x="345" y="41" width="240" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center"/>
<text><![CDATA[Result]]></text>
</staticText>
<staticText>
<reportElement x="585" y="41" width="82" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center"/>
<text><![CDATA[Date]]></text>
</staticText>
<staticText>
<reportElement x="667" y="41" width="48" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center"/>
<text><![CDATA[Time]]></text>
</staticText>
<staticText>
<reportElement x="715" y="41" width="87" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center"/>
<text><![CDATA[phone number]]></text>
</staticText>
<line>
<reportElement x="0" y="0" width="802" height="1"/>
</line>
<staticText>
<reportElement x="239" y="41" width="106" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center"/>
<text><![CDATA[Questions and answers]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="130" splitType="Stretch">
<textField isBlankWhenNull="false">
<reportElement x="0" y="0" width="56" height="130"/>
<box>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Left"/>
<textFieldExpression><![CDATA[$F{student_StudentId}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="false">
<reportElement x="97" y="0" width="65" height="130"/>
<box>
<leftPen lineWidth="0.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Left"/>
<textFieldExpression><![CDATA[$F{student_LastName}]]></textFieldExpression>
</textField>
<textField pattern="yyyy/MM/dd" isBlankWhenNull="false">
<reportElement x="667" y="0" width="48" height="130"/>
<box>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Left"/>
<textFieldExpression><![CDATA[$F{diagnosis_new_timeOfDiagnosis}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="false">
<reportElement x="162" y="0" width="77" height="130"/>
<box>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Left"/>
<textFieldExpression><![CDATA[$F{classlevel_ClassLevel}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="false">
<reportElement x="715" y="0" width="87" height="130"/>
<box>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Left"/>
<textFieldExpression><![CDATA[$F{student_HomePhoneNumber}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="false">
<reportElement x="56" y="0" width="41" height="130"/>
<box>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Left"/>
<textFieldExpression><![CDATA[$F{student_FirstName}]]></textFieldExpression>
</textField>
<textField pattern="yyyy/MM/dd" isBlankWhenNull="false">
<reportElement x="345" y="0" width="240" height="130"/>
<box>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Left"/>
<textFieldExpression><![CDATA[$F{diagnosis_new_resultOfDiagnosis_EN}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="false">
<reportElement x="585" y="0" width="82" height="130"/>
<box>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Left"/>
<textFieldExpression><![CDATA[$F{diagnosis_new_DateOfDiagnosis}]]></textFieldExpression>
</textField>
<textField pattern="yyyy/MM/dd" isBlankWhenNull="false">
<reportElement x="239" y="0" width="106" height="130"/>
<box>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Left"/>
<textFieldExpression><![CDATA[$F{diagnosis_new_questions_answersOfDiagnosis}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch">
<textField>
<reportElement x="727" y="34" width="75" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$P{date}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="667" y="34" width="60" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$P{time}]]></textFieldExpression>
</textField>
</band>
</pageFooter>
<summary>
<band height="150" splitType="Stretch"/>
</summary>
</jasperReport>