We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Pdf Drawing Accuracy Off

The location of text is rendered in different locations for 2 documents of equal width and height. I have found that it is always within a few pixels and always just the Y coordinate that is affected.

The PageInfo height and width are exactly the same on both documents. The Page.Rect is also the same size on both documents. Both are rendering the same text at the same coordinates. On some documents it is exactly right and others are about 5px too high. This is consistent. for all documents (it’s one or the other).

The only difference I see (besides content of the two docs) is that the Rect on one thinks it’s 612x792 (portrait) and the other is 792x612(landscape). BUT, the GetPageRect functions accurately returns 612x792 in both cases (and both are in fact portait). I have no idea if this is somehow throwing it off, but given the relatively small offset and the fact that 612 is only 77% of 792, I don’t think that’s really it.

I have included a pic of 2 files, both identical height and both with “Michael” rendered at the “same” coordinates.

I am using TextBuilder.Append and appending a TextFragment to the Page.

Any ideas?

Hi Michael,

Thanks for your inquiry. We will appreciate it if you please share your sample PDF document and code. So we will look into it and provide you more information accordingly.

We are sorry for the inconvenience caused.

Best Regards,

The code is pretty basic. I have double checked every value coming in and it’s the same numbers. Here is the snippet and I have included the two PDFs:

//Create text fragment
TextFragment textFragment = new TextFragment(text);
textFragment.Position = new Position(convertedBounds.LLX, convertedBounds.LLY);

//Set text properties
textFragment.TextState.FontSize = 22;
textFragment.TextState.Font = FontRepository.FindFont(font);
textFragment.TextState.ForegroundColor = color;

//Create TextBuilder object
TextBuilder textBuilder = new TextBuilder(pdfPage);

//Append the text fragment to the PDF page

Hi Michael,

Thanks for sharing the resource files.

I have tested the scenario and I am able to
notice the same problem. For the sake of correction, I have logged this problem
as PDFNEWNET-37731 in our issue tracking system. We will further
look into the details of this problem and will keep you updated on the status
of correction. Please be patient and spare us little time. We are sorry for
this inconvenience.