相同的行正在打印

时间:2020-06-03 06:11:47

标签: java apache-poi

我正在使用apache poi来制作自己的文档查看器,例如Google文档。我几乎只面对一个问题就完成了,那个问题是同一行被打印三次。我不知道该如何纠正。 下面是我尝试为文档查看器打印文本的代码 用于查看文档的Google文档 Google document viewer

我的文档查看器 My document viewer 有人可以帮忙吗?

private void textViews(XWPFParagraph paragraph,List<IRunElement> runElements) {
    String paragraphText = paragraph.getParagraphText();

    int size;
    UnderlinePatterns u;
    Boolean b;
    String ff;

    for (IRunElement runElement : runElements) {
        if (runElement instanceof XWPFRun) {
            XWPFRun run = (XWPFRun) runElement;
            System.out.println("runClassName " + run.getClass().getName());
            System.out.println("run " + run);


            para.append(run);
            paras.add(para);

            Log.i("font family", run.getFontFamily());
            Log.i("font class", run.getFontName());

            size = run.getFontSize();
            u = run.getUnderline();
            b = run.isBold();
            ff = run.getFontFamily();


                if (paragraphText.length() > 1) {

                    addTextViews(paragraphText, size, b, u, ff);

                }


        }
    }

}

public  void addElements(XWPFPictureData pictureData,long w,long h){


    ArrayList<ImageView> imageViews = new ArrayList<>();

    ImageView image = new ImageView(this);
    image.setLayoutParams(new RelativeLayout.LayoutParams((int)(w/2800),(int)(h/2800)));
    image.setMaxHeight((int)h/2800);
    image.setMaxWidth((int)w/2800);


    InputStream inputStream = new ByteArrayInputStream(pictureData.getData());

    Bitmap bitmap = BitmapFactory.decodeStream(inputStream);

    image.setImageBitmap(bitmap);
    mainUI.addView(image);


    // Adds the view to the layout
    LinearLayout imageLayout = new LinearLayout(getApplicationContext());
    RelativeLayout.LayoutParams params = new 
    RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, 
    RelativeLayout.LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.BELOW, image.getId());
    imageLayout.setLayoutParams(params);
    mainUI.addView(imageLayout);




}

用于textViews函数的控制台输出。

I / System.out:遍历身体元素

I / System.out:PARA org.apache.poi.xwpf.usermodel.XWPFParagraph@a4e07b4

I / System.out:runClassName org.apache.poi.xwpf.usermodel.XWPFRun

I / System.out:运行Flutter Work

我/字体家族:Times New Roman

I / font class:Times New Roman

I / System.out:PARAINDICES2

TRAVERSE RUN ELEMENTS

runClassName org.apache.poi.xwpf.usermodel.XWPFRun

I / System.out:运行Flutter Work

我/字体家族:Times New Roman

I / font class:Times New Roman

I / System.out:PARA org.apache.poi.xwpf.usermodel.XWPFParagraph@a23ea4d

I / System.out:runClassName org.apache.poi.xwpf.usermodel.XWPFRun

I / System.out:首先运行

我/字体家族:Times New Roman

I / font class:Times New Roman

I / System.out:runClassName org.apache.poi.xwpf.usermodel.XWPFRun

run day ,

我/字体家族:Times New Roman

I / font class:Times New Roman

I / System.out:runClassName org.apache.poi.xwpf.usermodel.XWPFRun

I / System.out:运行第二天和第三天–

我/字体家族:Times New Roman

I / font class:Times New Roman

I / System.out:PARAINDICES7

TRAVERSE RUN ELEMENTS

runClassName org.apache.poi.xwpf.usermodel.XWPFRun

run First 

我/字体家族:Times New Roman

I / font class:Times New Roman

I / System.out:runClassName org.apache.poi.xwpf.usermodel.XWPFRun

I / System.out:运行日,

我/字体家族:Times New Roman

I / font class:Times New Roman

I / System.out:runClassName org.apache.poi.xwpf.usermodel.XWPFRun

run  Second day and Third day –

我/字体家族:Times New Roman

I / font class:Times New Roman

I / System.out:PARA org.apache.poi.xwpf.usermodel.XWPFParagraph@73c6902

I / System.out:runClassName org.apache.poi.xwpf.usermodel.XWPFRun

run Watched out the flutter tutorials on the YouTube channel – the net 

ninja

我/字体家族:Times New Roman

I / font class:Times New Roman

I / System.out:PARAINDICES12

TRAVERSE RUN ELEMENTS

runClassName org.apache.poi.xwpf.usermodel.XWPFRun

I / System.out:运行观看YouTube频道上的入门教程

–网络忍者

我/字体家族:Times New Roman

I / font class:Times New Roman

I / System.out:PARA org.apache.poi.xwpf.usermodel.XWPFParagraph@6438213

runClassName org.apache.poi.xwpf.usermodel.XWPFRun

I / System.out:在接下来的几天内运行,制作了各种应用程序,例如–

我/字体家族:Times New Roman

I / font class:Times New Roman

I / System.out:PARAINDICES15

TRAVERSE RUN ELEMENTS

runClassName org.apache.poi.xwpf.usermodel.XWPFRun

I / System.out:在接下来的几天内运行,制作了各种应用程序,例如–

我/字体家族:Times New Roman

I / font class:Times New Roman

I / System.out:PARA org.apache.poi.xwpf.usermodel.XWPFParagraph@a125c50

I / System.out:runClassName org.apache.poi.xwpf.usermodel.XWPFRun

I / System.out:运行1个Quotes应用程序–一个显示不同内容的基本应用程序

引用及其作者

我/字体家族:Times New Roman

I / font class:Times New Roman

I / System.out:PARAINDICES18

TRAVERSE RUN ELEMENTS

runClassName org.apache.poi.xwpf.usermodel.XWPFRun

I/System.out: run 1 Quotes app – A basic app which displays different 

quotes along with their authors 

I/font family: Times New Roman



I/font class: Times New Roman

I/System.out: PARA org.apache.poi.xwpf.usermodel.XWPFParagraph@7d1de49

I/System.out: runClassName org.apache.poi.xwpf.usermodel.XWPFRun

I/System.out: run Learnt about 

I/font family: Times New Roman

I/font class: Times New Roman

I/System.out: runClassName org.apache.poi.xwpf.usermodel.XWPFRun

I/System.out: run listview

I/font family: Times New Roman

I/font class: Times New Roman

I/System.out: runClassName org.apache.poi.xwpf.usermodel.XWPFRun

I/System.out: run  in flutter 

I/font family: Times New Roman

I/font class: Times New Roman


I/System.out: PARAINDICES23

TRAVERSE RUN ELEMENTS

runClassName org.apache.poi.xwpf.usermodel.XWPFRun

I/System.out: run Learnt about 


I/font family: Times New Roman

I/font class: Times New Roman

I/System.out: runClassName org.apache.poi.xwpf.usermodel.XWPFRun

I/System.out: run listview

I/font family: Times New Roman

I/font class: Times New Roman

I/System.out: runClassName org.apache.poi.xwpf.usermodel.XWPFRun

I/System.out: run  in flutter 

I/font family: Times New Roman

I/font class: Times New Roman

I/System.out: PARA org.apache.poi.xwpf.usermodel.XWPFParagraph@b8c134e

0 个答案:

没有答案
相关问题