Post
Replies
Boosts
Views
Activity
Hi,
The Paid Apps Agreement, tax, and banking are all active in App Store Connect. Thank you.
Hi,
Thanks for your response. I verified all of the above. What further steps could I take?
Just following up. Thank you.
Thank you, I now have this:
@MainActor func render() -> URL {
let renderer = [ImageRenderer(content: pdfView())]
let url = URL.documentsDirectory.appending(path: "output.pdf")
var view = CGRect(x: 0, y: 0, width: 2550, height: 3300)
guard let pdf = CGContext(url as CFURL, mediaBox: &view, nil) else {
return nil // error
}
for image in renderer {
image.render { size, context in
pdf.beginPDFPage(nil)
context(pdf)
pdf.endPDFPage()
}
}
pdf.closePDF()
}
I have two follow up questions:
I'm getting an error shown above for returning a nil value but I'm not sure how to otherwise handle the else statement.
I have a function pdfView that returns the view to be rendered. The syntax to return is -> some View { . Is it possible to return an array of views?
Here's what I've put together so far:
let context = CGContext()
let title = CTLineCreateWithAttributedString(CFAttributedString("Title"))
One thing I don't understand is CGContext has many different of options as for parameters; some has width/height, some has other parameters. Which initializer would be ideal to use and what is the difference between setting the CTFrame (which I also don't know how to initialize) and the width/height of CGContext?
I am also unsure as how to pass a string to CTLineCreateWithAttributedString. I tried this:
let title = CTLineCreateWithAttributedString(CFAttributedString("Title"))
Also, how do I map something like the CTLine to the context?
Thank you for all the help thus far. Can Core Text be used in conjunction with CGContext? Is PDFKit compatible with iOS? If so, would that be better to use?
I found this: https://forums.developer.apple.com/forums/thread/671947
It explains a lot. I just have a few follow up questions:
I'm getting errors with these two lines:
context.setFillColor(NSColor.red.cgColor)
context.addPath(shape.path(in: CGRect(origin: .zero, size: size)))
Additionally, I see a lot of functions on the CGContext documentation page for text under the heading "Drawing Text" that does things such as setting the font, but I don't see a function that does the drawing.
Also, there is code here that downloads a file of type FileDocument. Is there a way to convert the Data type (from the first link) generated with the code provided above to a FileDocument type? Could I also use a .fileExporter call to save the Data type or, is there a better way to save the file (for iOS)?
Hi,
Thank you for your response however I'm not fully following the documentation you provided. I have a few questions:
Listing 13-2 describes drawing a PDF page, but the function is declared with "void". What language is that?
I searched CGContext and found many functions but I'm not sure how to use them. Would I have to create a CGContext object and call the functions on that? Is there a function for plain text?
Listing 13-4 is a larger example, but I don't see any code that specifies the actual content being added to the PDF.
Hi,
Thank you for your response. I did not realize the code I provided was UIKit. I'd prefer to use SwiftUI. Would you be able to provide a solution to do the following:
Generate a PDF composed of data from a SwiftData class
Allow the user to export the PDF to their file app
Hi,
Just following up to see if anyone has any idea how to resolve this. Thank you.
Thanks for your response. Below is what comes up both from cd ./git both the in the project folder.
I don't even see a .git folder in the root directory. I had at least 20-30 files. I don't quite remember all of the steps I took. What I remember is I added a file to one of the branches, and went to switch to see if it only added the file in one of the branches. After that, both ended up empty. I have a revision on my phone and simulator. Is there any way to recover the files with that?
The only files displayed with both branches are below:
Regardless of whether I'm in main or the new branch, the only files are the template files that are generated when creating a new project.
There are two files under "Changes": (Project Name)-Info and build.