Print Page | Close Window

change color

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=2864
Printed Date: 03 May 24 at 8:53PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: change color
Posted By: juergen
Subject: change color
Date Posted: 10 Apr 14 at 10:04AM
Hello,
 
i try to open a existing pdf and write it into a new pdf (DrawCapturedPage) but the textcolor & fillcolor
must be set to RED (because its a failure notice). SetTextColor & SetFillClor makes no changes.
 
Does anybody know, what I'm doing wrong?
 
Regards
 
Jurgen



Replies:
Posted By: AndrewC
Date Posted: 11 Apr 14 at 4:10PM
Juergen,

CapturePage / DrawCapture page will copy the page as is and redraw it as is at a different scale or size.

Setting TextColor / FillColor will not change the existing text in the PDF.   You need to add extra content using DrawText / SetTextColor / SetFillColor.

Can you try the following code on your PDF.  

  QP.LoadFromFile("before.pdf");
  QP.SelectPage(1);
  QP.NormalizePage(0);
  QP.SetTextColor(1, 0, 0);
  QP.AddStandardFont(4);
  QP.SetTextSize(30):
  QP.SetOrigin(1);
  QP.DrawTetxt(72, 72, "Hello World");
  QP.SaveToFile("After.pdf");

Andrew.


Posted By: juergen
Date Posted: 07 May 14 at 10:50AM
Hello Andrew,
 
thx for your answer and sorry for my delayed reply (I was ill).
Using your code I get a red new text - is ok, but my text is still black. I tried it with setfillcolor & settextcolor and got the same results. What can I do?
 
Juergen


Posted By: AndrewC
Date Posted: 12 May 14 at 3:35AM
Juergen,

It sounds like you want the existing text inside the CapturePage to be turned to red.  This is not possible.  You can only add RED text to an existing PDF.

Andrew.


Posted By: juergen
Date Posted: 12 May 14 at 8:35AM
Hello Andrew,
 
yep, thats the job I have to do. I get a failure notice as pdf file and have to copy it, as a new frame, into another pdf, but it must be there in red color. Is it not possible to change a seperate content into a different color, like "print as black&white" ?
 
regards
 
Juergen


Posted By: AndrewC
Date Posted: 14 May 14 at 3:27AM
Juergen,

It is not easily possible as the capture page contains its own SetFillColor and SetTextColor commands.

You would need to manually parse the content stream for the page and change all the color commands from black to red.    You would need to use GetContentStreamToString and SetContentStreamFromString to extract the drawing comments and then you would need to change any '0 0 0 rg' strings to '1 0 0 rg' to change things to red.  There are other commands that would need changing.  This is assuming that the PDF is in RGB format and not CMYK and that it is using true black and so on...  You might get lucky.  

  QP.ReplaceTag( '0 0 0 rg',  '1 0 0 rg');  // might work.  No guarantees.

  QP.ReplaceTag( '0 0 0 RG',  '1 0 0 RG');  // might work.  No guarantees.

Andrew.



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