让用户在 IOS swift 中的应用程序外部保存 pdf

2023-12-10

我制作了一个 PDF 并将其保存在我的应用程序中,但我想让用户将 PDF 文档保存在我的应用程序外部的目录中。 (抱歉英语不好,我来自瑞士。)

格式化程序中的标记文本,这很重要吗?我必须使用它来做什么?

我认为 - UIGraphicsBeginPDFContextToFile(pathForPDF, rect, nil) - 将文件保存在我的应用程序的文档目录中,这是正确的吗?

其他问题。我的代码有什么错误吗?我从这里的答案中获取了很多代码,希望我能做对。

import UIKit 
import Foundation

class PdfErstellung {
    static func PdfErstellen(_ auswahlZeilen : [LebensmittelDataTV], _ vitalstoffWerteListe : [LebensmittelDataTV], _ heuteString : String) {
        var html = "<html><head><meta charset='UTF-8'></head><body>Erstelle Vitalstoffwerte PDF</body></html"

        // 1. Create Print Formatter with input text.
        let formatter = UIMarkupTextPrintFormatter(markupText: html)

        // 2. Add formatter with pageRender
        let render = UIPrintPageRenderer()
        render.addPrintFormatter(formatter, startingAtPageAt: 0)

        // 3. Assign paperRect and printableRect

        let page = CGRect(x: 0, y: 0, width: 595.2, height: 841.8) // A4, 72 dpi
        let printable = page.insetBy(dx: 0, dy: 0)
        let rect = CGRect.zero

        render.setValue(NSValue(cgRect: page), forKey: "paperRect")
        render.setValue(NSValue(cgRect: printable), forKey: "printableRect")

        // 4. Create PDF context and draw
        let fileName = "Vitalstoffwerte " + heuteString
        let paths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)
        let documentsDirectory = paths[0]
        let pathForPDF = documentsDirectory.appendingFormat("/" + fileName)

        UIGraphicsBeginPDFContextToFile(pathForPDF, rect, nil)

        // Start Draw of page

        var y = 0

        var stringRechteckX50 = CGRect(x: 50, y: y, width: 100, height: 20)
        var stringRechteckX160 = CGRect(x: 160, y: y, width: 30, height: 20)
        var stringRechteckX170 = CGRect(x: 170, y: y, width: 10, height: 20)
        var stringRechteckX220 = CGRect(x: 220, y: y, width: 100, height: 20)
        var stringRechteckX330 = CGRect(x: 330, y: y, width: 30, height: 20)
        var stringRechteckX340 = CGRect(x: 340, y: y, width: 10, height: 20)

        var paragraphStyle = NSMutableParagraphStyle()

        var font = UIFont(name: "Helvetica Bold", size: 20.0)
        var text = ""

        let attributes = [
            NSAttributedString.Key.paragraphStyle: paragraphStyle,
            NSAttributedString.Key.font: font,
            NSAttributedString.Key.foregroundColor: UIColor.black
        ]

        var attributedString = NSAttributedString(string: text, attributes: attributes)

        // ÜBERSCHRIFT

        font = UIFont(name: "Helvetica Bold", size: 20.0)
        text = "Tagesbedarf in % vom " + heuteString
        paragraphStyle.alignment = .left
        var stringRechteck = CGRect(x: 50, y: 50, width: 300, height: 40)
        attributedString.draw(in: stringRechteck)


        // Vitalstoffwerte Liste

        y = 80

        for zeile in 0..<vitalstoffWerteListe.count {

            let druckenVitalstoffWerte = vitalstoffWerteListe[zeile]

            if druckenVitalstoffWerte.zeilenInfoID == 0 { // Überschrift

                y = y + 10
                font = UIFont(name: "Helvetica Bold", size: 14.0)
                text = druckenVitalstoffWerte.name
                attributedString.draw(in: stringRechteckX50)

            } else { // Detail

                font = UIFont(name: "Helvetica", size: 12.0)
                text = druckenVitalstoffWerte.name
                attributedString.draw(in: stringRechteckX50)

                text = druckenVitalstoffWerte.anzahl
                paragraphStyle.alignment = .right
                attributedString.draw(in: stringRechteckX160)

                text = druckenVitalstoffWerte.masse
                paragraphStyle.alignment = .left
                attributedString.draw(in: stringRechteckX170)

            }
            y = y + 30
        }

        y = 80
        text = "Lebensmittel"
        font = UIFont(name: "Helvetica Bold", size: 14.0)
        paragraphStyle.alignment = .left
        attributedString.draw(in: stringRechteckX220)


        // Lebensmittelliste

        y = 120

        for zeile in 0..<auswahlZeilen.count {

            let auswahlZeilenObjekt = auswahlZeilen[zeile]

            font = UIFont(name: "Helvetica", size: 12.0)
            text = auswahlZeilenObjekt.name
            attributedString.draw(in: stringRechteckX220)

            text = auswahlZeilenObjekt.anzahl
            paragraphStyle.alignment = .right
            attributedString.draw(in: stringRechteckX330)

            text = auswahlZeilenObjekt.masse
            paragraphStyle.alignment = .left
            attributedString.draw(in: stringRechteckX340)

        }
        y = y + 30

         // End Draw of page

        UIGraphicsEndPDFContext()
    }


    // I think the Pdf was saved before, but i do not know exactly
    static func savePdf(_ urlString: String, _ fileName: String) {
        DispatchQueue.main.async {
            let url = URL(string: urlString)
            let pdfData = try? Data.init(contentsOf: url!)
            let resourceDocPath = (FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)).last! as URL
            let pdfNameFromUrl = "YourAppName-\(fileName).pdf"
            let actualPath = resourceDocPath.appendingPathComponent(pdfNameFromUrl)
            do {
                try pdfData?.write(to: actualPath, options: .atomic)
                print("pdf successfully saved!")
            } catch {
                print("Pdf could not be saved")
            }
        }
    }
}

- - 编辑 - - -

我改变了很多。感谢您的链接,我找到了其他链接并有了新的想法。

我的下一个问题是:

Vitalstoff控制器[6161:165020][默认] [错误] 无法确定 URL 是否/用户/lukashedinger/库/开发人员/CoreSimulator/设备/4DE0F1A6-67B7-4909-8C46-78278D403E63/数据/容器/数据/应用程序/D72F4EE0-D330-4B2D-924E-E17FC805EF55/tmp/Vitalstoffwerte 21092018 -21092018.pdf( n)由文件提供商管理

我发现了这个,但不明白我的错误是什么。

UIActivityViewController 错误:无法确定 URL 是否由文件提供程序管理

如何将文件保存到文档文件夹中?

(也许是 IOS 12 的一个错误,我读到:https://forums.developer.apple.com/thread/103198)

我的新代码

    // 5. Save PDF file

    let dateiName = "Vitalstoffwerte " + heuteString

    let path = "\(NSTemporaryDirectory())\(dateiName).pdf"



    pdfData.write( toFile: path, atomically: true)

    print("open \(path)")


    // var fileUrl: URL = URL(fileURLWithPath: NSTemporaryDirectory())
    // fileUrl.appendPathComponent("foo")
    // fileUrl.appendPathExtension("bar")


    let fileUrl: URL = URL(fileURLWithPath: path)

    let directory = "\(NSTemporaryDirectory())"

    let directoryUrl : URL = URL(fileURLWithPath: directory)

    print("open \(fileUrl)")
    print("open \(directoryUrl)")

    let fm = FileManager.default

    //let fileName = String((fileUrl.lastPathComponent)) as NSString
    //let documentsUrl:URL =  fm.urls(for: .documentDirectory, in: .userDomainMask).first!
    //let destinationFileUrl = documentsUrl.appendingPathComponent("\(fileName)")

    //print("open \(documentsUrl)")


    //do {
    //    try fm.removeItem(at: destinationFileUrl)
    //} catch (let deleteError) {
    //    print("Error deleting a file \(destinationFileUrl) : \(deleteError)")
    //}

    //do {
    //    try FileManager.default.copyItem(at: fileUrl, to: destinationFileUrl)
    //} catch (let writeError) {
    //    print("Error creating a file \(destinationFileUrl) : \(writeError)")
    //}

    do {

        //Show UIActivityViewController to save the downloaded file

        let contents  = try fm.contentsOfDirectory(at: directoryUrl, includingPropertiesForKeys: nil, options: .skipsHiddenFiles)

        print("open \(contents)")

        //for i in 0..<contents.count {

            let activityViewController = UIActivityViewController(activityItems: [contents[0]], applicationActivities: nil)
            self.present(activityViewController, animated: true, completion: nil)

                // for IPAD
                if let popOver = activityViewController.popoverPresentationController {
                    popOver.sourceView = self.view
                    //popOver.sourceRect =
                    //popOver.barButtonItem
                }

        //}
        // return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask]lastObject];
    } catch {
        print("Fehler")
    }
}

------- 更新:找到了解决我的问题的方法,但不是文件的方法 -----

我将 pdfData 直接提供给 ViewController,并且不将其保存到文件中。

UIActivityViewController(activityItems: [pdfData], applicationActivities: nil)

我不使用文件,这种方式对我来说已经足够了


我完成了,这是我的代码

函数 SavePdfUser(){

    // Create page rect
    let pageRect = CGRect(x: 0, y: 0, width: 595.28, height: 841.89) // A4, 72 dpi

    // Create PDF context and draw
    let pdfData = NSMutableData()

    UIGraphicsBeginPDFContextToData(pdfData, pageRect, nil)
    UIGraphicsBeginPDFPage()

    // From here you can draw page, best make it in a function
    PdfErstellung.PdfErstellen(auswahlZeilen, vitalstoffWerteListe, heuteString)

    UIGraphicsEndPDFContext()

    // Save pdf DATA through user
    let activityViewController = UIActivityViewController(activityItems: [pdfData], applicationActivities: nil)
    activityViewController.popoverPresentationController?.sourceView = self.view // für IPAD nötig
    self.present(activityViewController, animated: true, completion: nil)

    // save temporary for preview 
    let dateiName = "Vitalstoffwerte " + heuteString
    let fileUrl = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("\(dateiName).pdf")

    do {
        try pdfData.write(to: fileUrl, options: .atomic)
    } catch {
        print(error,"file not save")
    }

    // Preview
    let webview = WKWebView(frame: UIScreen.main.bounds)
    view.addSubview(webview)
    webview.load(URLRequest(url: fileUrl))
}

导入 UIKit 进口基金会

类 PdfEstellung {

static func PdfErstellen(_ auswahlZeilen : [LebensmittelDataTV], _ vitalstoffWerteListe : [LebensmittelDataTV], _ heuteString : String) {

    var y = 0 // Points from above - von oben
    var x = 0 // Points form left - von links
    var width = 0 // length of rect - länge vom rechteck
    var height = 0 // height of rect - höhe vom rechteck
    var stringRechteck = CGRect(x: x, y: y, width: width, height: height) // make rect for text - rechteck für Text

    var paragraphStyle = NSMutableParagraphStyle() // text alignment - text ausrichtung

    var font = UIFont(name: "HelveticaNeue-Bold", size: 10.0) // Important: the font name must be written correct - Wichtig: Textname muss korrekt geschrieben werden
    var text = ""

    let attributes = [
        NSAttributedString.Key.paragraphStyle: paragraphStyle,
        NSAttributedString.Key.font: font,
        NSAttributedString.Key.foregroundColor: UIColor.black
    ]

    // Title - ÜBERSCHRIFT

    font = UIFont(name: "HelveticaNeue-Bold", size: 20.0)
    text = "Tagesbedarf in % vom " + heuteString // heuteString = date/datum
    paragraphStyle.alignment = .left
    x = 50; y = 30; width = 300; height = 40
    stringRechteck = CGRect(x: x, y: y, width: width, height: height)
    text.draw(in: stringRechteck, withAttributes: attributes)


    // List - Vitalstoffwerte Liste

    y = 45

    for zeile in 0..<vitalstoffWerteListe.count {

        let druckenVitalstoffWerte = vitalstoffWerteListe[zeile]

        if druckenVitalstoffWerte.zeilenInfoID == 0 { // Title - Überschrift

            y = y + 5 // distance to above becaus is title - Abstand nach oben, weil Überschrift
            x = 50; width = 80; height = 20
            stringRechteck = CGRect(x: x, y: y, width: width, height: height)
            font = UIFont(name: "HelveticaNeue-Bold", size: 10.0) // change font - verändere schrift
            text = druckenVitalstoffWerte.name
            text.draw(in: stringRechteck, withAttributes: attributes)
            font = UIFont(name: "HelveticaNeue", size: 8.0) // change font back - schrift zurück ändern

        } else { // or detail

            x = 50; width = 90; height = 20
            stringRechteck = CGRect(x: x, y: y, width: width, height: height)
            text = druckenVitalstoffWerte.name
            text.draw(in: stringRechteck, withAttributes: attributes)

            x = 150; width = 40
            stringRechteck = CGRect(x: x, y: y, width: width, height: height)
            text = druckenVitalstoffWerte.anzahl
            paragraphStyle.alignment = .right
            text.draw(in: stringRechteck, withAttributes: attributes)
            paragraphStyle.alignment = .left

            x = 195; width = 20
            stringRechteck = CGRect(x: x, y: y, width: width, height: height)
            text = druckenVitalstoffWerte.masse
            text.draw(in: stringRechteck, withAttributes: attributes)

        }
        y = y + 10 // 10 down for next line - 10 nach unten für nächste Zeile
    }

    // Title - Überschrift

    x = 220; y = 50; width = 100; height = 20
    text = "Lebensmittel"
    font = UIFont(name: "HelveticaNeue-Bold", size: 8.0)
    paragraphStyle.alignment = .left
    stringRechteck = CGRect(x: x, y: y, width: width, height: height)
    text.draw(in: stringRechteck, withAttributes: attributes)
    font = UIFont(name: "HelveticaNeue", size: 8.0)

    // List - Lebensmittelliste

    y = 60

    for zeile in 0..<auswahlZeilen.count {

        let auswahlZeilenObjekt = auswahlZeilen[zeile]

        x = 220; width = 90; height = 20
        stringRechteck = CGRect(x: x, y: y, width: width, height: height)
        text = auswahlZeilenObjekt.name
        text.draw(in: stringRechteck, withAttributes: attributes)

        x = 320; width = 40
        stringRechteck = CGRect(x: x, y: y, width: width, height: height)
        text = auswahlZeilenObjekt.anzahl
        paragraphStyle.alignment = .right
        text.draw(in: stringRechteck, withAttributes: attributes)
        paragraphStyle.alignment = .left

        x = 365; width = 20
        stringRechteck = CGRect(x: x, y: y, width: width, height: height)
        text = auswahlZeilenObjekt.masse
        text.draw(in: stringRechteck, withAttributes: attributes)

        y = y + 10

        if zeile == 75 { // 76 items - Zeilen
            break
        }
    }

    y = 60

     if auswahlZeilen.count > 75 { // new

        for zeile in 76..<auswahlZeilen.count {

            let auswahlZeilenObjekt = auswahlZeilen[zeile]

            x = 390; width = 90; height = 20
            stringRechteck = CGRect(x: x, y: y, width: width, height: height)
            text = auswahlZeilenObjekt.name
            text.draw(in: stringRechteck, withAttributes: attributes)

            x = 490; width = 40
            stringRechteck = CGRect(x: x, y: y, width: width, height: height)
            text = auswahlZeilenObjekt.anzahl
            paragraphStyle.alignment = .right
            text.draw(in: stringRechteck, withAttributes: attributes)
            paragraphStyle.alignment = .left

            x = 535; width = 20
            stringRechteck = CGRect(x: x, y: y, width: width, height: height)
            text = auswahlZeilenObjekt.masse
            text.draw(in: stringRechteck, withAttributes: attributes)

            y = y + 10

            if zeile == 151 { // 76 items - Zeilen
                break
            }
        }
    }
}

}

-- 编辑 -- 问题仅存在于 IOS 12 中。

我不知道为什么,但在某些模拟器中:我可以制作文件,并将 URL 提供给 UIActivityViewController,并且我有自己的文件名,而在其他情况下 URL 失败,我必须直接提供 pdfData。

我的想法:我首先尝试 URL,如果失败,那么我给出 pdfData

do {
        let dateiName = "Vitalstoffwerte " + heuteString
        let fileUrl = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("\(dateiName).pdf")

        do {
            try pdfData.write(to: fileUrl, options: .atomic)
        } catch {
            print(error,"file not save")
        }

        let activityViewController = UIActivityViewController(activityItems: [fileUrl], applicationActivities: nil)
        activityViewController.popoverPresentationController?.sourceView = self.view // für IPAD nötig
        self.present(activityViewController, animated: true, completion: nil)

    } catch {

        let activityViewController = UIActivityViewController(activityItems: [pdfData], applicationActivities: nil)
        activityViewController.popoverPresentationController?.sourceView = self.view // für IPAD nötig
        self.present(activityViewController, animated: true, completion: nil)
    }

我的问题是,我如何知道用户是否可以保存文件(如果他尝试过),我可以在日志中的错误代码之后询问吗?该做的,抓不走。

2018-09-25 15:36:55.787894 + 0200 Vitalstoffcontroller [8656:186334] [默认] [错误]无法确定URL是否/Users/lukashedinger/Library/Developer/CoreSimulator/Devices/45A185C5-6DEA-4A52-B415- 939758FB7F7E/data/Containers/Data/Application/2469BE4A-53B2-4545-B5D7-E64FBCDB383E/tmp/Vitalstoffwerte 25092018-25092018.pdf (n) 由文件提供商管理 2018-09-25 15:36:56.312499+0200 Vitalstoffcontroller[8656:186334] [ShareSheet] 取消请求 - 错误:操作无法完成。无效的论点

- 编辑 -

我的临时解决方案是,在ios12中,我将数据提供给 UIActivityViewController ,否则我将数据保存为文件并将url提供给 UIActivityViewController 。

     if #available(iOS 12.0, *) {

        let activityViewController = UIActivityViewController(activityItems: [pdfData], applicationActivities: nil)
        activityViewController.popoverPresentationController?.sourceView = self.view // für IPAD nötig
        self.present(activityViewController, animated: true, completion: nil)

    } else {

        let dateiName = "Vitalstoffwerte " + heuteString
        let fileUrl = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("\(dateiName).pdf")
        do {
            try pdfData.write(to: fileUrl, options: .atomic)
        } catch {
            print(error,"file not save")
        }
        let activityViewController = UIActivityViewController(activityItems: [fileUrl], applicationActivities: nil)
        activityViewController.popoverPresentationController?.sourceView = self.view // für IPAD nötig
        self.present(activityViewController, animated: true, completion: nil)
    }
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

让用户在 IOS swift 中的应用程序外部保存 pdf 的相关文章

随机推荐

  • 第一个句号之后的参数的自动完成/下拉框

    例如 如果我在 Excel 托管的 VBA 中编写参数 ActiveSheet UsedRange Select Halfway through writing the first part ActiveSheet CTRL SPACE w
  • 打字稿中的管道(|)是什么意思?

    在浏览一些打字稿代码时 ng bootstrap我找到了管道 操作员 export declare const NGB PRECOMPILE typeof NgbAlert typeof NgbTooltipWindow 管道有什么用 打字
  • iOS6 中的 AudioToolBox 泄露?

    当我使用 AudioToolBox 播放音乐时 内存泄漏严重 AVAudioPlayer newMusicPlayer AVAudioPlayer alloc initWithData data error error 我用这个代码来播放音
  • 读取文本文件并在 MSBuild 中分割每一行

    我在 MSBuild 中遇到了以下问题 我有一个文本文件 buildsolutions1 txt 其中包含列表 逐行 其中包含我需要构建的所有解决方案以及以逗号分隔的相关开发人员电子邮件 常见 Common sln am email com
  • VS 代码自动更正

    我正在寻找一种方法来自动替换 VS Code 中经常拼写错误的单词 有没有什么东西 我将如何创建一些东西 我可以添加要查找的特定字符串 要替换的字符串以及要激活的自动更正的语法 文件类型 Example 背景 背景 CSS SCSS 更少
  • 购物车错误(LaravelShoppingcart)

    我在用Crinsane LaravelShoppingcart使用 Laravel 5 当我尝试将商品添加到购物车时 它将显示错误 非静态方法 Gloudemans Shoppingcart Cart add 不应静态调用 假设 this
  • 仅在 chrome 上使用 corsheaders 的 Missing Patch 方法

    我有一个正在使用的 Django 应用程序corsheaders包及其在 settings py 中如下所示 INSTALLED APPS corsheaders MIDDLEWARE on top corsheaders middlewa
  • 将 csv 文件的一些列复制到表中

    我有一个包含 10 列的 CSV 文件 创建包含 4 列的 PostgreSQL 表后 我想将 10 列中的一些复制到表中 我的 CSV 表的列如下 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 我的 PostgreSQL
  • “抛出新的 NotImplementedException();”是什么意思究竟做什么?

    我有一个继承自类 a 的类 b 在类 a 中 有一些代码在事件不为空时执行操作 我需要在应用程序的特定时间在 b 类中触发该代码 所以在 b 中我订阅了一个新的处理程序 事件 如果我将自动生成的事件 按原样 保留在 b 类中throw ne
  • 从 next.js 中的中间件重定向 13 AppDir: true

    当我没有得到 jwt 后端时 我试图进行重定向 我在 next js 13 中appdir active 中间件 ts import NextResponse from next server import type NextRequest
  • React 项目在 Heroku 上崩溃并出现许多分配失败,但在本地开发上运行

    我的 React 日历应用程序在本地开发构建上运行良好 但在部署到 Heroku 时会出现许多分配失败 以下是 Heroku 日志中的错误 2021 08 29T06 50 16 143215 00 00 app web 1 lt Last
  • 使用 NEVPNManager 创建个人 VPN 连接

    我正在尝试在我的应用程序中创建 VPN 连接 我通过这个链接https developer apple com documentation networkextension nevpnmanager但没有找到任何使用NEVPNManager
  • html css 等于 div 高度

    我有一个容器 div 其中并排包含 2 个动态高度 高度尚未设置 div 这 2 个 div 是内容 div 有时一个 div 的内容比另一个 div 的内容多 导致与另一个 div 的距离更长 而那些两个 div 具有不同的颜色 为了具有
  • Python 中的 HTML 文件解析

    我有一个很长的 html 文件 看起来完全像这样 html文件 我希望能够解析该文件 以便获得 tuple 表单中的信息 Example tr td Cech td td Chelsea td td 30 td td 6 4 td tr 上
  • 计算字符串中子字符串出现的次数

    如何计算 Python 字符串中给定子字符串出现的次数 例如 gt gt gt foo bar foo numberOfOccurrences foo 2 To get indices of the substrings see How t
  • 如何在 R 中求 5 分钟间隔的总和

    我有一个数据集 其中包含 6 个不同站点每分钟的降水量记录 我想对每个电台每 5 分钟进行一次汇总 这些是我的数据集的前 5 行 总共 17280 行 P alex P hvh P merlijn P pascal P thurlede P
  • Python加载带有UTF-8 BOM头的json文件

    我需要解析其他工具生成的文件 该工具无条件输出带有 UTF 8 BOM 标头 EFBBBF 的 json 文件 我很快发现这就是问题所在 因为 Python 2 7 模块似乎无法解析它 gt gt gt import json gt gt
  • 绘制 Windrose:制作浓度设置为颜色的污染玫瑰

    尝试绘制风玫瑰图 其中绘制了速度和方向 浓度决定了颜色 不幸的是 matplotlib 仅支持两个变量 可以制作一个很好的散点图来显示我想要的内容 但不确定如何将其分类 以便它像所附图像一样 Halliday et al 2016 应转换为
  • 拦截窗口窃取 Windows 全局焦点的尝试

    我是一名开发人员和长期 Windows 用户 痴迷于让我的系统尽可能方便使用 昨天 我想到了 Windows 中一直让我烦恼并且我认为理所当然的事情 我意识到我对它如何工作有更好的想法 我现在想知道是否有可能调整 Windows 以使其工作
  • 让用户在 IOS swift 中的应用程序外部保存 pdf

    我制作了一个 PDF 并将其保存在我的应用程序中 但我想让用户将 PDF 文档保存在我的应用程序外部的目录中 抱歉英语不好 我来自瑞士 格式化程序中的标记文本 这很重要吗 我必须使用它来做什么 我认为 UIGraphicsBeginPDFC