Print Page | Close Window

Pad Text To A Specific Length

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=2375
Printed Date: 13 May 25 at 9:08AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Pad Text To A Specific Length
Posted By: MrPopup
Subject: Pad Text To A Specific Length
Date Posted: 20 Aug 12 at 1:52AM
Using QuickPDF 8.16 ActiveX.
I am generating a document with an index page and have the index entry text on the left and the related page number of the right. How can I extend the index text (padded with '.' (periods)) to the page number? Example:
"Monthly Results...................................................................................109"
Thank you for any assistance rendered.Smile



Replies:
Posted By: AndrewC
Date Posted: 20 Aug 12 at 12:34PM

You should be able to calculate using something based on the code below.  You will need to determine the value of totalColumWidth your self.  It assumes you have the required font currently selected.

  double left = QP.GetTextWidth("Monthly Results");
  double right = QP.GetTextWidth("109");

  double dotWidth = QP.GetTextWidth(".");

  gapToFill = totalColumWidth - left - right;
  dotsRequired = gapToFill / dotWidth;

  text = left + DotString(dotsRequired) + right;

  QP.DrawText(x, y, text);



Posted By: MrPopup
Date Posted: 20 Aug 12 at 8:19PM
Thank you AndrewC. Appreciate the help. Smile



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk