I am using iOS Charts (Daniel Gindi) to generate graphs in an iOS app and I want to be able to generate a PDF report with those graphs included in the body of the report. Can anyone explain how to go about doing this. Ideally I don't want to generate an image from the UIView that shows in the app because the size/resolution would not be suitable for the PDF document.
As I understand it there are a few options:
- use the graphics context for the pdf document to draw the graph on - it's not clear whether this would be possible when using the Charts library
- use a UIView somehow to generate the graph and generate a PDF image data from that, embed this image into the pdf report
It seems like option 1 is probably the preferred way to get best resolution/control - somewhat speculative - doing it this way means you should be able to specify the exact position and size and get the correct font sizes, line thicknesses, etc..
Using option 2 means you have to figure out the scaling between a UIView and the PDF page view and I am not sure how these would map to each other.
Can anyone provide any suggestions on the following:
- Is it possible to use Charts to generate graphs in a PDF document, and if so how?
- If not what other options are there, short of writing custom drawing code.
Copyright Notice:Content Author:「Duncan Groenewald」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/50419999/is-it-possible-to-use-ios-charts-daniel-gindi-to-generate-graphs-in-pdf-docume