ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Alignment of X-axis labels in PDF output
Posted by Tim on Oct-03-2016 19:57
Attachments:
I save the same bar chart into two output formats: PNG and PDF

For the PNG output, the x-axis labels are perfectly aligned, which is expected and great;
for the PDF output, those labels are not aligned, as illustrated in the attachment.

I guess this is to do with the font type/size used by the PDF output. Is there a specific way to force labels alignment?

THANKS A LOT!
03-Oct-16 10-41-26 PM.jpg

  Re: Alignment of X-axis labels in PDF output
Posted by Peter Kwan on Oct-04-2016 04:01
Hi Tim,

The issue is caused by the different method ChartDirector and PDF draws text.

In ChartDirector, the text is drawn to be best looking at a certain pixel size. To do this, the character height and width are often rounded to exact pixel boundary. This method is commonly used to draw short text, such as the text labels on the menu bar or labels on the desktop icons.

For PDF, the text is drawn to have the most accurate position. That means the characters can be fractional width (which makes it blurrer if the font size is small), and the same character at the same font size can look different because the characters can start at different fractional positions and so can be anti-aliased differently. This layout method is most common in word processing.

The small difference in rounded and fractional character widths can accumulate for long text and resulting in non-perfect alignment.

Currently, we have an updated chartdir60.dll that supports a new text layout method so that the PDF should be consistent with the PNG in terms of text width. To use the new layout method, please use the following updated chartdir60.dll. In your license file, please add a second line "@TextAA=PreciseHint" (without quotes). This will enable the new text layout method.

http://www.advsofteng.com/chartdir60p3.zip

Hope this can help.

Regards
Peter Kwan

  Re: Alignment of X-axis labels in PDF output
Posted by Tim on Oct-04-2016 09:30
Attachments:
Many thanks for the detailed explanation and support, Peter. This solves the global label alignment issue.

But I now note a new "text displacement" issue inside the string, and it is really with the very wide letter "W" - please see the attachment. Any fix with that. I am using 64-bit DLL.

Thanks again.
04-Oct-16 12-10-07 PM.jpg

  Re: Alignment of X-axis labels in PDF output
Posted by Tim on Oct-04-2016 12:53
Attachments:
I have a similar issue with line charts in PNG and PDF formats. From your explanation, I assume the reason is similar and it lies in different ways lines are drawn for PNG and PDF formats.

From the attachment, the PDF version shows many (undesirable) spikes for a time series of a dataset, instead of the smooth changes seen in the PNG format.

I prefer the vector-based PDF format, but the PNG format honours a realistic representation. A dilemma.
04-Oct-16 3-38-58 PM.jpg

  Re: Alignment of X-axis labels in PDF output
Posted by Daniel on Oct-04-2016 19:57
Tim wrote:

Many thanks for the detailed explanation and support, Peter. This solves the global label alignment issue.  But I now note a new "text displacement" issue inside the string, and it is really with the very wide letter "W" - please see the attachment. Any fix with that. I am using 64-bit DLL.

Hi to you both,

I have been using the new dll with pdf-text-alignment-corrections with great satisfaction. I can testify that these pdfs can really make a difference at print-time!

They can of course be a bit more difficult and cpu-intensive for the pdf-viewer to handle on big vectorial content (the foxreader technology is much better than the acrobat one..). A great achievement by ASE!

One general remark though: beware of the fonts you are using.

Depending on the font itself, the correction will be handled more or less effectively. It looks like newer fonts deliver a better result!

Possibly there's a reason for such behaviour. And I'd be glad to understand:)

Daniel

  Re: Alignment of X-axis labels in PDF output
Posted by Peter Kwan on Oct-04-2016 23:23
Hi Tim,

Actually, I uploaded the incorrect DLLs to our web server, causing the issue with the text. I have uploaded the correct version now. Please try to download again, and use the latest version.

To make the PDF consistent with the PNG, we have tried two methods:

(a) Adjust the PDF to make it consistent with the PNG. As we cannot control how PDF renders the characters, when we move the characters around to make it consistent with the PNG, the spacing of the characters may look unnatural. I mistakenly uploaded this version to our web server yesterday.

(b) Adjust the PNG to make it consistent with the PDF. This makes the PNG less sharp, but we found that in modern displays, it should be acceptable. Daniel is using this version so the PDF in his case should not have unnatural character spacing. I have now uploaded this version to our web server, so the PDF generated should look more natural.

Regards
Peter Kwan

  Re: Alignment of X-axis labels in PDF output
Posted by Tim on Oct-05-2016 12:23
It is perfect now. Thank you, Peter!

Any comments on the difference between PNG and PDF for the line drawing? An illustration was provided in the previous message.

  Re: Alignment of X-axis labels in PDF output
Posted by Peter Kwan on Oct-06-2016 00:53
Hi Tim,

It is due to the different line joining method used by ChartDirector and by PDF.

ChartDirector uses a special method to join lines. For PDF, the default is to use a miter join. The difference will become noticeable for think lines joining at sharp angles.

It happens the default joining method is configurable in PDF, and our developers have changed it to using "miter join with limits" method. I have tested it, and it seems to produce joins that are quite similar to those of ChartDirector, though not exactly the same. In particular, the sharp corners are cut off. If you would like to try the modified PDF line joining, please use the following DLLs:

http://www.advsofteng.com/chartdir60p4.zip

Hope this can help.

Regards
Peter Kwan

  Re: Alignment of X-axis labels in PDF output
Posted by Daniel on Oct-06-2016 02:55
Hi Peter,

Nice to hear that you are working on the pdf generation process. As you are are aware we are quite pleased with the stuff we currently run when it comes to outputing vectorial pdf output.

At times however we also find light visual differences between the vectorial-pdf output and its raster equivalent png-in-a-pdf. The png is also - from our standpoint - the canonical CD output against which we contrast and visuallt measure the vectorial alternatives:) Do you think it might be worth trying this new code base as well?

Kudos for the great work. The output performance really shines!

Daniel

  Re: Alignment of X-axis labels in PDF output
Posted by Peter Kwan on Oct-07-2016 00:19
Hi Daniel,

Certain things in ChartDirector do not have a representation in SVG and PDF. For example, in ChartDirector you can use a gradient color as the line color, but in both PDF and SVG, a line color must be a flat color. We have tried to emulate the major ChartDirector features  in SVG/PDF using sometimes very complex methods. Still there can be some minor differences.

For the latest code with the "miter join with limits", if you not have the same issue in your current chart, I think there is no need to use the update. It is the same as the earlier code except with this one particular change.

Regards
Peter Kwan

  Re: Alignment of X-axis labels in PDF output
Posted by Tim on Oct-06-2016 19:25
Thanks, Peter. The new PDF configuration for the line chart is great and actually important. In my case, now the sharpness of the lines has gone so the chart presentation exactly matches with the underlying data in PDF output.

Your marvellous support is highly appreciated again.

Best wishes,
Tim

  Re: Alignment of X-axis labels in PDF output
Posted by Daniel on Oct-07-2016 01:45
Tim wrote:
Your marvellous support is highly appreciated again.
Best wishes,
Tim
May I second that!
Cheers - Daniel