I'm struggling to create a Android Module which I can build and use in Unity to render a PDF to an image for a commercial project I'm working on.
I have created a simple java program which works but only on windows due to its awt dependencies, but have now been trying for 2 days to create a version which works in android studio.
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import com.spire.pdf.PdfDocument;
import javax.imageio.ImageIO;
class PDFExporter {
public static void main(String[] args) throws IOException {
//load the sample PDF
PdfDocument doc = new PdfDocument();
doc.loadFromFile(args[0]);
//save every PDF to .png image
BufferedImage image;
for (int i = 0; i < doc.getPages().getCount(); i++) {
image = doc.saveAsImage(i);
File file = new File( String.format(args[1] + "%d.png", i));
ImageIO.write(image, "PNG", file);
}
doc.close();
}
}
I've tried to reproduce this in android studio using their pdfrenderer and an android port of Apache's PDFrenderer. Android's documentation is horrible and Apache's only worked inside of an activity. Any help here would be massively appreciated
EDIT: I should also include that the final destination for the project is the Oculus Quest, hopefully that doesn't rule anything out.