Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/326.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何使用itext向区块添加css_Java_Pdf_Itext - Fatal编程技术网

Java 如何使用itext向区块添加css

Java 如何使用itext向区块添加css,java,pdf,itext,Java,Pdf,Itext,您好,我已经使用索引来移动特定页面,使用第一个图像下面的块如何将css添加到第二个图像中,或者是否有好的方法来进行这种索引设计,以使用itext移动特定页面 Document document = new Document(PageSize.A4.rotate()); // step 2 PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("Test.pdf"));

您好,我已经使用索引来移动特定页面,使用第一个图像下面的块如何将css添加到第二个图像中,或者是否有好的方法来进行这种索引设计,以使用itext移动特定页面

Document document = new Document(PageSize.A4.rotate());
        // step 2
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("Test.pdf"));
        // step 3
        document.open();


        Chunk chunk11 = new Chunk("1");
        chunk11.setLocalGoto("1");
        chunk11.setLocalDestination("1");
        Chunk chunk12 = new Chunk("2");
        chunk12.setLocalGoto("2");
        Chunk chunk13 = new Chunk("3");
        chunk13.setLocalGoto("3");
        Chunk chunk14 = new Chunk("4");
        chunk14.setLocalGoto("4");

        document.add(new Paragraph(chunk11));
        document.add(new Paragraph(chunk12));
        document.add(new Paragraph(chunk13));
        document.add(new Paragraph(chunk14));

        PdfPTable table = new PdfPTable(2);

        table.addCell("Subject ");
        table.addCell(" Obtain marks ");
        result = Student_resultby_parent_daoimp.Details();

        ExaminationDTO examinationDTO = result.get(0);



        table.addCell("Kannada");
        table.addCell(Integer.toString(90));
        table.addCell("English");
        table.addCell(Integer.toString(85));

        table.addCell("Hindi");
        table.addCell(Integer.toString(95));
        table.addCell("Mathematics");
        table.addCell(Integer.toString(85));
        table.addCell("Science");
        table.addCell(Integer.toString(90));

        table.addCell("SocialStudies");
        table.addCell(Integer.toString(60));

        table.addCell("Total marks");
        table.addCell(Integer.toString(550));

        document.add(table);

        Chapter chapter = new Chapter(0);
        document.add(chapter);

        /*
         * XMLWorkerHelper.getInstance().parseXHtml(writer, document, new
         * FileInputStream("index.jsp"));
         */

        Chunk chunk21 = new Chunk("1");
        chunk21.setLocalGoto("1");

        Chunk chunk22 = new Chunk("2");
        chunk22.setLocalDestination("2");
        chunk22.setLocalGoto("2");
        Chunk chunk23 = new Chunk("3");
        chunk23.setLocalGoto("3");
        Chunk chunk24 = new Chunk("4");
        chunk24.setLocalGoto("4");

        document.add(new Paragraph(chunk21));
        document.add(new Paragraph(chunk22));
        document.add(new Paragraph(chunk23));
        document.add(new Paragraph(chunk24));

        table.addCell("Subject ");
        table.addCell(" Obtain marks ");
        result = Student_resultby_parent_daoimp.Details();

     examinationDTO = result.get(1);

     PdfPTable table1 = new PdfPTable(2);

        table1.addCell("Subject ");
        table1.addCell(" Obtain marks ");

        table1.addCell("Kannada");
        table1.addCell(Integer.toString(10));
        table1.addCell("English");
        table1.addCell(Integer.toString(20));

        table1.addCell("Hindi");
        table1.addCell(Integer.toString(30));
        table1.addCell("Mathematics");
        table1.addCell(Integer.toString(40));
        table1.addCell("Science");
        table1.addCell(Integer.toString(50));

        table1.addCell("SocialStudies");
        table1.addCell(Integer.toString(60));

        table1.addCell("Total marks");
        table1.addCell(Integer.toString(110));

        document.add(table1);       

        document.close();

我不明白你的问题。如果您想创建一个类似于标记为“Expecting like this”的图像的表,为什么不在这种意义上创建
PdfPTable
?还有,你为什么要谈论CSS?使用
PdfPTable
PdfPCell
Chunk
和其他iText对象时,不涉及CSS。您可以使用适当的方法定义
PdfPCell
的背景色,但这不是CSS。您可以使用适当的方法更改
块的字体颜色,但这不是CSS。等等请理解你的问题听起来很尴尬。本质上你必须理解,
PdfPTable
不是一个抽象的数据表示,而是一个具体的可视化表格结构。@Bruno Lowagie,我是一个初露头角的程序员,我对itext还不熟悉,甚至我在问题中提到,我必须以何种方式添加颜色,要更改字体大小和字体颜色,我们需要在itext中使用css方法,我不觉得这是一个如此尴尬的问题,请在感到尴尬之前理解其他人试图说什么。你是对的,我想创建一个类似标记为“期望如此”的图像的表,好的,我将使用PdfPTable创建