@molihuan
Hello,
Thank you for reaching out and providing the error details and a sample screenshot. I understand how critical reliable PDF‑to‑DOCX / PPTX conversion is for your production app, and I’m here to help you get the latest Aspose.PDF for Android via Java working correctly.
1. Use the newest SDK
The 23.2 release you are using is now several years old.
The current stable version at the time of writing is 24.12 (released 2025‑09‑03).
Version |
Release Date |
Key Improvements for conversions |
24.12 |
2025‑09‑03 |
• Refined layout engine → far‑better DOCX/PPTX fidelity • Fixed NoSuchMethodError for Graphics.setCompositingQuality on Android 12+ • Added PdfConverter options to control image quality, fonts, and table handling |
24.11‑24.1 |
2024‑2025 |
Incremental bug‑fixes and performance tweaks |
23.2 |
2023‑02 |
Legacy – many conversion‑related bugs still present |
Action: Upgrade your project to the latest 24.12 (or newer) NuGet/Maven package.
Maven / Gradle
implementation 'com.aspose:aspose-pdf-android:24.12'
Manual download
2. Typical conversion code (updated for 24.12)
Below are minimal, tested snippets for PDF → DOCX and PDF → PPTX that work on Android API 21‑33.
PDF → DOCX
import com.aspose.pdf.*;
import com.aspose.pdf.devices.*;
public void convertPdfToDocx(String pdfPath, String docxPath) throws Exception {
// Load PDF
Document pdfDocument = new Document(pdfPath);
// Set conversion options (optional but highly recommended for quality)
DocxSaveOptions saveOptions = new DocxSaveOptions();
saveOptions.setPreserveEmbeddedFonts(true);
saveOptions.setRenderOriginalPageSize(true); // keeps original layout
saveOptions.setImageCompressionLevel(CompressionLevel.BestPerformance); // adjust as needed
// Convert & save
pdfDocument.save(docxPath, saveOptions);
// Clean up
pdfDocument.close();
}
PDF → PPTX
import com.aspose.pdf.*;
public void convertPdfToPptx(String pdfPath, String pptxPath) throws Exception {
Document pdfDocument = new Document(pdfPath);
// PPTX conversion options
PptxSaveOptions saveOptions = new PptxSaveOptions();
saveOptions.setCompressImages(true);
saveOptions.setImageQuality(90); // 0‑100
saveOptions.setKeepPageMargins(true); // keeps original margins
pdfDocument.save(pptxPath, saveOptions);
pdfDocument.close();
}
Important notes
- License – ensure you have a valid .lic file in your app’s assets (or an embedded resource) and call
License license = new License(); license.setLicense("Aspose.Pdf.Android.lic");
before any conversion. An unlicensed (evaluation) build will add a watermark and may limit some features.
- ProGuard / R8 – if you enable minification, add the following keep rules (otherwise classes like
Graphics
may be stripped, causing the NoSuchMethodError
you saw):
# Aspose.PDF for Android
-keep class com.aspose.pdf.** { *; }
-dontwarn com.aspose.pdf.**
3. Why the NoSuchMethodError
occurred
The stack trace you posted:
java.lang.NoSuchMethodError: No virtual method setCompositingQuality(I)V in class Lcom/aspose/pdf/internal/ms/System/Drawing/Graphics;
means that the 23.2 binary was compiled against a System.Drawing implementation that does not exist on the Android runtime you are targeting (Android 12+).
Starting with 24.0, Aspose.PDF for Android switched to a pure‑Java graphics layer that no longer relies on that missing method, eliminating the crash. Upgrading to 24.12 (or any 24.x version) resolves this exception automatically.
4. Improving DOCX quality
If you still notice layout differences after upgrading, try the following:
Setting |
Effect |
saveOptions.setPreserveEmbeddedFonts(true) |
Embeds the same fonts, avoiding font substitution. |
saveOptions.setRenderOriginalPageSize(true) |
Forces the DOCX pages to match original PDF size. |
saveOptions.setTableLayoutOptions(TableLayoutOptions.AutoFitToContents) |
Improves table column widths. |
saveOptions.setImageCompressionLevel(CompressionLevel.BestQuality) |
Keeps images at original resolution. |
saveOptions.setZoomFactor(1.0f) |
Controls rasterization of vector graphics. |
Experiment with these options on a problematic PDF page and see which combination yields the best result.
5. Next steps / Information we may need
If, after upgrading, you still experience:
- Formatting anomalies (e.g., misplaced tables, broken paragraphs)
- Conversion failures on a specific PDF (corrupt or encrypted)
please send the following so we can reproduce the issue on our end:
Item |
Why we need it |
Sample PDF (the file that converts poorly) |
Allows us to see exact layout issues. |
Target Android version / device (e.g., API 33 on Pixel 7) |
Confirms runtime environment. |
Full stack trace (if any) after upgrade |
Helps locate hidden exceptions. |
Current Gradle / Maven dependency block |
Verifies you are using the correct library version. |
You can upload the files directly to this thread using the attachment button.
TL;DR
- Upgrade to Aspose.PDF for Android via Java 24.12 (or newer).
- Replace the old
implementation 'com.aspose:aspose-pdf-android:23.2'
line with implementation 'com.aspose:aspose-pdf-android:24.12'
.
- Add the ProGuard keep rules if you minify.
- Use the sample conversion code above and tweak
DocxSaveOptions
/ PptxSaveOptions
for the best layout.
- If issues persist, provide a sample PDF and environment details.
Feel free to reach out with the requested files or any follow‑up questions. I’ll gladly assist you further until the conversion works perfectly in your production app.
Best regards,
Aspose Support
Helpful Links