【问题标题】:Where to start: Creating a PDF in my Android application从哪里开始:在我的 Android 应用程序中创建 PDF
【发布时间】:2018-03-05 06:07:50
【问题描述】:

我正在创建一个 Android 应用程序,其最终目标是能够根据从用户那里收集的数据生成 PDF。哪里是开始我的研究的好地方?是否有我应该研究的 API 或工作室插件?

谢谢,周末愉快!

【问题讨论】:

    标签: android pdf pdf-generation


    【解决方案1】:

    你需要的android.graphics.pdf库参考页是https://developer.android.com/reference/android/graphics/pdf/package-summary.html 你可以使用下面的代码

     // create a new document
     PdfDocument mydocument = new PdfDocument();
    
     // crate a page description
     PageInfo mypageInfo = new PageInfo.Builder(new Rect(0, 0, 100, 100), 1).create();
    
     // start a page
     Page mypage = mydocument.startPage(mypageInfo);
    
     // draw something on the page
     View content = getContentView();
     content.draw(mypage.getCanvas());
    
     // finish the page
     mydocument.finishPage(mypage);
     . . .
     // add more pages
     . . .
     // write the document content
     mydocument.writeTo(getOutputStream());
    
     // close the document
     mydocument.close();
    

    【讨论】:

    猜你喜欢
    • 2010-11-30
    • 2010-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多