Aspose.Words for Android via Java Limitations and API Differences

Limitations of Aspose.Words for Android via Java API compared to Aspose.Words for Java API

  1. *Document.print *methods are not available.
  2. Saving in TIFF and BMP formats is not supported, though SaveFormat.TIFF and SaveFormat.BMP are available in public Aspose.Words for Android via Java API, but UnsupportedOperationException is thrown when these save formats are used.
  3. Reading TIFF images is not supported.
  4. Signing ODT documents is not supported yet.
  5. Barcodes are not supported.
  6. Gradients along a curve are not supported
  7. Printing is not supported

Public API differences

  • android.graphics.Bitmap is used instead of java.awt.image.BufferedImage;
  • android.graphics.Canvas is used instead of java.awt.image.Graphics2D;
  • android.graphics.RectF is used instead of  java.awt.geom.Rectangle2D.Float;
  • android.graphics.PointF is used instead of java.awt.geom.Point2D.Float;
  • android.graphics.Rect is used instead of java.awt.Rectangle;
  • android.graphics.Point is used instead of java.awt.Point.

See the following Public API methods:

  1. com.aspose.words.DocumentBuilder:
    1. insertImage(Bitmap)
    2. insertImage(Bitmap, double, double)
    3. insertImage(Bitmap, int, double, int, double, double, double, int)
    4. insertOleImage(Bitmap)
    5. insertOleObject(InputStream, String, boolean, Bitmap)
    6. insertOleObject(String, boolean, boolean, Bitmap)
    7. insertOleObject(String, String, boolean, boolean, Bitmap)
  2. com.aspose.words.IBarcodeGenerator:
    1. Bitmap getBarcodeImage(BarcodeParameters)
    2. Bitmap getOldBarcodeImage(BarcodeParameters)
  3. com.aspose.words.ImageData:
    1. setImage(Bitmap)
    2. Bitmap toImage()
  4. com.aspose.words.ImageFieldMergingArgs:
    1. Bitmap getImage()
    2. setImage(Bitmap)
  5. com.aspose.words.Document:
    1. android.graphics.PointF renderToScale(int, Canvas, float, float, float) throws Exception
    2. float renderToSize(int, Canvas, float, float, float, float) throws Exception
  6. com.aspose.words.LayoutEnumerator:
    1. android.graphics.RectF getRectangle() throws Exception
  7. com.aspose.words.NodeRendererBase:
    1. android.graphics.PointF getSizeInPoints()
    2. android.graphics.RectF getOpaqueBoundsInPoints()
    3. public android.graphics.PointF getSizeInPixels(float, float)
    4. android.graphics.Rect getBoundsInPixels(float, float)
    5. android.graphics.Rect getOpaqueBoundsInPixels(float, float)
    6. android.graphics.PointF renderToScale(Canvas, float, float, float)
    7. float renderToSize(Canvas, float, float, float, float)
  8. com.aspose.words.PageInfo:
    1. android.graphics.PointF getSizeInPixels(float, float)
    2. android.graphics.PointF getSizeInPoints()
  9. com.aspose.words.ShapeBase:
    1. android.graphics.RectF adjustWithEffects(android.graphics.RectF)
    2. android.graphics.RectF getBounds() 
    3. android.graphics.RectF getBoundsInPoints() 
    4. android.graphics.RectF getBoundsWithEffects()
    5. android.graphics.Point getCoordOrigin()
    6. android.graphics.PointF getCoordSize() 
    7. android.graphics.PointF getSizeInPoints()
    8. android.graphics.PointF localToParent(android.graphics.PointF)
    9. setBounds(android.graphics.RectF) 
    10. setCoordOrigin(android.graphics.Point)
    11. setCoordSize(android.graphics.PointF)
  10. com.aspose.words.ThumbnailGeneratingOptions:
    1. android.graphics.PointF getThumbnailSize()
    2. setThumbnailSize(android.graphics.PointF)

Aspose.Words for Android via Java additional requirements

In order to use metered licensing feature and load documents or images by http/ftp protocols users should add following permission to their applications <uses-permission android:name=“android.permission.INTERNET” />

Public API Examples

public void testPublicAPI1() throws Exception
    {
        final String imagePath = "myImage.pmg";
        Bitmap image = null;
        try
        {
            image = BitmapFactory.decodeFile(imagePath);
            DocumentBuilder builder = new DocumentBuilder();
            builder.insertImage(image);
        }
        finally
        {
            if (image != null)
                image.recycle();
        }
    }
public void testPublicAPI2() throws Exception
    {
        String gTestDocumentPath = "testDoc.docx";
        String outFile = "out.png";
        Document doc = new Document(gTestDocumentPath);
        Bitmap image = null;
        FileOutputStream fos = null;
        try
        {
            image = Bitmap.createBitmap(1000, 1000, Bitmap.Config.ARGB_8888);
            Canvas gr = new Canvas(image);
            gr.rotate(45);
            doc.renderToSize(0, gr, 0, 0, image.getWidth(), image.getHeight());
            fos = new FileOutputStream(outFile);
            image.compress(Bitmap.CompressFormat.PNG, 100, fos);
        }
        finally
        {
            if (fos != null)
                fos.close();
            if (image != null)
                image.recycle();
        }
    }