In Swift, I'm trying to generate a pdf version of a collectionView, and save that PDF to the temporary directory. However, I'm not sure if I'm doing it right, or actually even saving anything. Here's my code:
func
createPdfFromView(aView: UICollectionView,
saveToDocumentsWithFileName fileName: String)
{
let pdfData = NSMutableData()
UIGraphicsBeginPDFContextToData(pdfData, gridView.bounds,
nil)
UIGraphicsBeginPDFPage()
guard let pdfContext = UIGraphicsGetCurrentContext() else { return
}
aView.layer.render(in: pdfContext)
UIGraphicsEndPDFContext()
let fileName = sampleClass.sampleStruct.samplePDF.rawValue
let template = NSURL(fileURLWithPath:
NSTemporaryDirectory()).appendingPathComponent(fileName)
debugPrint(fileName)
pdfData.write(toFile: String (describing: template), atomically:
true)
}
how can I do this?
Answer for the given Question:
See the below code it may helps to you for the given problem statement
In Swift, I'm trying to generate a pdf version of a collectionView, and save that PDF...
could you please help me with this problem, also I
need a little text so I can understand how you solved the
problem?
import java.io.File; import java.util.Scanner; /** *
This program lists the files in a directory specified by * the
user. The user is asked to type in a directory name. * If the name
entered by the user is not a directory, a * message is printed and
the program ends. */ public class DirectoryList { public static...
Barcelona Restaurant Group Summary: Barcelona Restaurant Group is always trying to attract and retain only those employees who reinforce its service-oriented culture and provide top quality customer service. The manager being interviewed in the video is constantly recruiting and hiring new employees and letting low performers and poor fits go. He also tries to provide job candidates with a realistic description of the company's expectations to ensure that they know what they would be getting into if they took a...