【问题标题】:Compatible pdf manipulator with current android version (8.1)与当前 android 版本 (8.1) 兼容的 pdf 操纵器
【发布时间】:2019-10-15 17:12:38
【问题描述】:

我正在开发一个 .pdf 应用程序,该应用程序需要通过填写现有 .pdf 表单插入应用程序中的信息来生成 .pdf。 我可以使用什么与 xamarin 当前的 android 版本一起使用

我尝试过 Itextsharp、Itext 7 和 PDF Box,但它们都已经过时了。

【问题讨论】:

    标签: c# android pdf xamarin


    【解决方案1】:

    Android 有一个内置的 PDF 生成类。看: https://developer.android.com/reference/android/graphics/pdf/PdfDocument

    API 的典型用法如下所示[移植到 C#]:

            // create a new document
            PdfDocument document = new PdfDocument();
    
            // crate a page description
            PageInfo pageInfo = new PageInfo.Builder(100, 100, 1).Create();
    
            // start a page
            Page page = document.StartPage(pageInfo);
    
            // draw something on the page
            View content = FindViewById(Android.Resource.Id.Content);
            content.Draw(page.Canvas);
    
            // finish the page
            document.FinishPage(page);
            // add more pages
            // write the document content
            FileStream fileOutputStream = new FileStream(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), FileMode.CreateNew);
            document.WriteTo(fileOutputStream);
    
            // close the document
            document.Close();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-11
      • 1970-01-01
      • 1970-01-01
      • 2020-03-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多