兼容的pdf操纵器,带有当前的android版本(8.1)

时间:2019-10-15 17:12:38

标签: c# android pdf xamarin

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

我尝试使用Itextsharp,Itext 7和PDF Box,但它们都已过时。

1 个答案:

答案 0 :(得分:0)

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();