图像转换为PDF中的Android [英] Convert image to PDF in Android
本文介绍了图像转换为PDF中的Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要一个发送图像以PDF文件的形式在我的Android应用程序,但我没有想法如何位图转换为PDF格式。
I need to send an image as in form of PDF file in my Android application but I dont have idea how to convert bitmap to PDF.
我可以用文字写的PDF而已。
I am able to write pdf with text only.
有没有什么解决办法吗?
Is there any solution?
推荐答案
我认为你正在使用iText库的文本PDF转换。使用此图像转换为PDF格式。
I think you are using iText Library to convert the text to pdf. Use this to convert image to pdf.
import java.io.*;
import com.lowagie.text.*;
import com.lowagie.text.pdf.*;
public class imagesPDF
{
public static void main(String arg[])throws Exception
{
Document document=new Document();
PdfWriter.getInstance(document,new FileOutputStream("YourPDFHere.pdf"));
document.open();
Image image = Image.getInstance ("yourImageHere.jpg");
document.add(new Paragraph("Your Heading for the Image Goes Here"));
document.add(image);
document.close();
}
}
这篇关于图像转换为PDF中的Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文