1

我正在实现 Android 应用程序以转换 JPEG 格式的幻灯片。我已经在文本视图中从 SD 卡上传了 PowerPoint 文件,并且还成功计算了他们的幻灯片。但是,当我将所有幻灯片转换为 JPEG 格式时,它会在 Saaspose Sdk 的 Document 类中显示错误。

这是我的文档类:

public class Document {
    public Document(String fileName) 
    {
        this.fileName = fileName;
        gson = new Gson();
    }

public String fileName="";
    Gson gson = null;

public int getSlideCount() {
        try {
            // build URI to get slide count

            String strURI = Product.getBaseProductUri() + "/slides/" + fileName + "/slides";
            String signedURI = Utils.sign(strURI);

            InputStream responseStream = Utils.processCommand(signedURI,"GET");

            String strJSON = Utils.streamToString(responseStream);

            SlidesResponse slidesResponse = gson.fromJson(strJSON,SlidesResponse.class);
            int count = slidesResponse.getSlides().getSlideList().size();
            return count;
        }

        catch (Exception e)
        {

            logger.error(e.getMessage());
            return -1;
        }

    }


public void saveSlideAs(String outputPath, int slideNumber,
            ImageFormat imageFormat)// Returns 100x100 image
    {

        try {

            // build URI to get page count
            String strURI = Product.getBaseProductUri() + "/slides/" + fileName
                    + "/slides/" + Integer.toString(slideNumber) + "?format="
                    + imageFormat.toString().toLowerCase();

            String signedURI = Utils.sign(strURI);

            InputStream responseStream = Utils.processCommand(signedURI, "GET");

            Folder.saveStreamToFile(outputPath,
                    responseStream);



            responseStream.close();

}

        catch (Exception e) {
            logger.error(e.getMessage());
        }
    }
}

这是我的 StorageFolderUploadFile 类

protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.storage_folder_uploadfile);
        init();

btnSubmit.setOnClickListener(new View.OnClickListener()
        {

            @Override
            public void onClick(View arg0)
            {
                // TODO Auto-generated method stub
                if (function_arg1.getText().length() == 0)
                {
                    AlertDialog.Builder dialog = new AlertDialog.Builder(StorageFolderUploadFile.this);
                    dialog.setTitle("Error");
                    dialog.setMessage("Please Enter Require Fields");
                    dialog.setNeutralButton("Ok", null);
                    dialog.show();
                } 

                else

                {
                    System.out.println("*******************");

                    fileName = function_arg1.getText().toString();
                    Log.e("fileName ","-> " + fileName);

                    String[] afterSplit = fileName.split("/");
                    Log.e("String[] ","afterSplit -> " + afterSplit);

                    String mntString=afterSplit[1];
                    Log.e("mntString "," afterSplit -> " + mntString);

                    String sdCardString=afterSplit[2];
                    Log.e("adCardString "," afterSplit -> " + sdCardString);

                    String fileMainName=afterSplit[3];
                    Log.e("fileName "," afterSplit -> " + fileMainName);

                    txtFileNameForSlideCount.setText(fileMainName);

                    System.out.println("********************");


                    //folderName = function_arg2.getText().toString();
                    //folderName="tazeen";

                    Folder obj = new Folder();
                    try 
                    {
                        response = obj.uploadFile(fileName);

                        Log.e("",""+response);

                        if (response) 
                        {
                            result.append("File Uploaded Successfully " );

                            Document docObj1=new Document(txtFileNameForSlideCount.getText().toString());
                            countSlides=docObj1.getSlideCount();
                            Log.e("contSildes is","-> "+countSlides);

                            if(countSlides>0)
                            {
                                result.append(" Numbers Of Slides = " + countSlides);
                                Log.e("File Uploaded Successfully and ","Numbers Of Slides -> " + countSlides);

                            }


                            Document docObj2=new Document(fileMainName);
                            for(int i=1; i <= countSlides ; i++)
                            {

                                /*System.out.println("________________________________________");
                                String strformatName="Slide.png";
                                docObj2.saveSlideAs(strformatName,countSlides,imageFormat);
                                result.append("slide is converted and save to your sdcard");
                                System.out.println("Slides name and number " + strformatName +" "+countSlides);
                                Log.e("Document Object ","-> " + docObj2);*/


                                outputPath = "slide"+i+".png";
                                slideNumber = i;

                                docObj2.saveSlideAs(outputPath, slideNumber, imageFormat);
                                result.append("slide is converted and save to your sdcard");
                            }

                        } 

                        else 
                        {
                            result.append("Oops..Something went wrong");

                        }
                    } 

                    catch (Exception e)

                    {
                        // TODO Auto-generated catch block
                        Toast.makeText(StorageFolderUploadFile.this,
                                "Error occured while performing this task",
                                Toast.LENGTH_LONG).show();
                        result.append("Error Occured");

                    }
                }
            }
        });

    }
}   
4

0 回答 0