Midas Huang
Midas Huang

Reputation: 25

About created a pdf file by Core-Plot

Core plot is quite powerful, I use it to create ecg graph. When I create pdf file, I encounter some problems.

Each small grid is square on my App. But when I use -dataForPDFRepresentationOfLayer() to write to the pdf file, small grid is not square. The pdf file's "minorGridLine" on wrong position.

I set up the pixel dimensions of the plot area and number of grid lines. Each small grid is square on my app, but small grid isn't square on the pdf file. How to solve this problem?

Thanks, Midas

App Screenshot

pdf Screenshot

Upvotes: 0

Views: 101

Answers (1)

Eric Skroch
Eric Skroch

Reputation: 27381

You're seeing the effect of aligning the grid lines to pixel boundaries to get crisper edges on the lines. The upper image (the screenshot) looks like a 1x render with blurred minor grid lines and anti-aliasing on the data line. The bottom image (the PDF) has crisp line edges implying a higher resolution (2x or 3x) drawing canvas. When the resolution is high enough to render the line width with an integer number of pixels, Core Plot moves the lines to fall on the nearest pixel boundaries to eliminate the fuzzy edges caused by anti-aliasing.

Possible solutions are to ensure that the pixel dimensions of the plot area are an even multiple of the number of minor tick locations (accounting for the contentsScale of the graph) or adjusting the line width of the minor grid lines so it's not possible to render them with an integer number of pixels. For example, use a line width of 0.4 instead of 0.5.

Upvotes: 1

Related Questions