Print Page | Close Window

Shade background

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=1527
Printed Date: 06 Jul 25 at 7:51AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Shade background
Posted By: waynefulcher
Subject: Shade background
Date Posted: 03 Aug 10 at 6:28PM
I want to draw some text (in black) then fill the background with a light gray color.
Can anyone give me an example of how to do that.
I have tried transparency and setfillcolor and nothing seems to work.
Here is a snippet of my code.
 
    x := LeftMargin ;
    PDF.DrawText(x, y, 'Form ID') ;
    PDF.DrawText(x+wFormID, y, 'Form Description') ;
    y := y + LineHeight ;
    PDF.DrawText(x, y, 'Pages') ;
    PDF.DrawText(x+wFormID, y, 'DCN') ;
    y := y + (LineHeight div 4) ;
    PDF.DrawLine(x, y, PDF.PageWidth-RightMargin, y) ;
    // Here is where I want to shade the background and I have no idea what colors make light gray
    PDF.SetFillColor(10,10,10) ;
    PDF.SetTransparency(70) ;
    PDF.DrawBox(LeftMargin, SaveY, PDF.PageWidth-LeftMargin-RightMargin, y-SaveY, 2) ;
    PDF.SetTransparency(0) ;
    y := y + LineHeight ;



Replies:
Posted By: Ingo
Date Posted: 03 Aug 10 at 9:14PM
Hi Wayne!

I've taken some code out of one of my components:
//. . .
var
colr, colg, colb : Double;

  if ( rgb1 = '' ) then
     rgb1 := '1,0';
  if ( rgb2 = '' ) then
     rgb2 := '1,0';
  if ( rgb3 = '' ) then
     rgb3 := '1,0';

  colr := StrToFloat(rgb1);
  colg := StrToFloat(rgb2);
  colb := StrToFloat(rgb3);

  QP2 := TQuickPDF0717.Create;
  try
     QP2.UnlockKey('...');
//   . . .
     QP2.SetFillColor(colr,colg,colb);
//   . . .
     QP2.DrawText(...);
//   . . .
  Finally
     QP2.SaveToFile...;
     QP2.Free;
  end;
//. . .
 
Please keep in mind that we're talking about RGB-colors.
The max-value for R, G and B is 1!
...(1.0, 1.0, 1.0) means white
...(0.0, 0.0, 0.0) means black.
Make some tests with values below 1.0 ...

Cheers, Ingo




Posted By: waynefulcher
Date Posted: 03 Aug 10 at 9:22PM
worked great. I am a bone head I forget what the ranges were for the RGB colors.



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