NoClassDefFoundError与boxable插件

时间:2015-09-09 11:38:34

标签: pdfbox

我正在使用带有pdfbox的盒装插件,我正在尝试创建一个teble。我收到了错误:

2015-09-09T10:36:52.453+0200|Severe: java.lang.NoClassDefFoundError: org/apache/pdfbox/pdmodel/edit/PDPageContentStream 

代码行:

BaseTable table = new BaseTable(yStart,yStartNewPage, bottomMargin, tableWidth, margin, doc, page, true, drawContent);

这是pom.xml的一部分,描述了我正在使用的依赖项:

<dependency>
      <groupId>org.apache.pdfbox</groupId>
      <artifactId>pdfbox</artifactId>
      <version>2.0.0-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>com.github.dhorions</groupId>
        <artifactId>boxable</artifactId>
        <version>1.2</version>
    </dependency>

当前版本的依赖项中是否存在错误或者我遗漏了什么?

非常感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

删除它:

 @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        imgview = (ImageView) findViewById(R.id.imageView1);
        Button buttonCamera = (Button) findViewById(R.id.btn_take_camera);
        Button buttonGallery = (Button) findViewById(R.id.btn_select_gallery);

        buttonCamera.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {

                try {
                    saveFullImage();
                } catch (Exception e) {
                    Log.e("error", e.toString());
                }

            }
        });

        buttonGallery.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent intent = new Intent();

                intent.setType("image/*");
                intent.setAction(Intent.ACTION_GET_CONTENT);

                intent.putExtra("crop", "true");
                intent.putExtra("aspectX", 0);
                intent.putExtra("aspectY", 0);
                intent.putExtra("outputX", 200);
                intent.putExtra("outputY", 150);

                try {

                    intent.putExtra("return-data", true);
                    startActivityForResult(Intent.createChooser(intent,
                            "Complete action using"), PICK_FROM_GALLERY);

                } catch (ActivityNotFoundException e) {
// Do nothing for now
                }
            }
        });
    }

    public void saveFullImage() {
        Intent intent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

        File create_dir=new File(Environment.getExternalStorageDirectory()+"/Vsenseloop");
        if(!create_dir.exists()){
            create_dir.mkdir();
        }

        File file=new File(Environment.getExternalStorageDirectory()+"/Vsenseloop", "ssasdasdss.jpg");

        outputFileUri=Uri.fromFile(file);
        intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
        startActivityForResult(intent, TAKE_PICTURE);
    }


    protected void onActivityResult(int requestCode, int resultCode, Intent data) {

        if(requestCode==TAKE_PICTURE){
            performCrop();
            // Check if the result includes a thumbnail Bitmap
            if(data!=null){
                if(data.hasExtra("data")){
                    bitmap=data.getParcelableExtra("data");
                    imgview.setImageBitmap(bitmap);
                }
            }
        }else if(requestCode==PIC_CROP){
            // get the returned data
            Uri imageUri=data.getData();
            if(imageUri==null){
            }else{
                try{
                    bitmap=MediaStore.Images.Media.getBitmap(this.getContentResolver(), imageUri);
                }catch(FileNotFoundException e){
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }catch(IOException e){
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

                // display the returned cropped image
                imgview.setImageBitmap(bitmap);

            }
        } else if (requestCode == PICK_FROM_GALLERY) {
            bitmap = data.getParcelableExtra("data");
            imgview.setImageBitmap(bitmap);
        }
    }


    private void performCrop() {
        try{
            Intent cropIntent=new Intent("com.android.camera.action.CROP", null).setDataAndType(outputFileUri, "image/*").putExtra("crop", "true")
                    .putExtra("aspectX", 1).putExtra("aspectY", 1).putExtra("outputX", 256).putExtra("outputY", 256).putExtra("scale", true)
                    .putExtra("return-data", false).putExtra("scaleUpIfNeeded", true).putExtra(MediaStore.EXTRA_OUTPUT, picUri)
                    .putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
            startActivityForResult(cropIntent, PIC_CROP);
        }catch(ActivityNotFoundException anfe){
            // display an error message
            String errorMessage="Ваше устройство не поддерживает обрезку фото!";
            Toast toast=Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT);
            toast.show();
        }
    }

2.0是未发布的版本,正在开发中,它有不同的API。 Boxable在其自己的pom.xml中有依赖关系,它目前要求1.8.8。 (这不是最新版本,但我认为这对简单的PDF创建很重要)