Do you own a Debenu Quick PDF Library 12/11/10/9/8/7? Upgrade to Debenu Quick PDF Library 13!

Foxit Quick PDF Library

Frequently Asked Question:

Return to FAQ Index

Clip text to a rectangle

Question

Is there anyway to clip text to a rectangle when using DrawText or similar? In other words, the text I want to draw may be too long for the available space, and I'd like to simply clip it so that it doesn't run into the next column of text. I don't want to wrap or resize the text, simply truncate it to the available space.

Answer

There isn't currently a function that would let you directly clip text to a rectangle.

However, with a little bit of work you could programmatically truncate your text strings so that they did not exceed a predefined width. This could be done by taking the predefined width and comparing it to the width of your text string (returned by the GetTextWidth function) and then chopping the required amount off of the text string so that it matched the required width.

Then you could add the truncated text string to the PDF using the DrawText function.


© 2015 Debenu & Foxit. All rights reserved. AboutBuyContactBlogNewsletterSupportFAQProduct UpdatesForum