logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

New Topic Post Reply
Options
Go to last post Go to first unread
lugangxyz  
#1 Posted : Tuesday, October 27, 2020 6:47:40 PM(UTC)
Quote
lugangxyz

Rank: Newbie

Groups: Registered
Joined: 10/15/2020(UTC)
Posts: 8
China

Hi All
Hope this is no so wired to you
What am trying to do is to to change the font color for the part of the text in a text object
The way I am using now is divide the txt obj into 3, is this the right way?

The problem is that new created txt obj are not aligned like the orignal one, I will post my code later

Thanks in advance for your great help
Paul Rayman  
#2 Posted : Tuesday, October 27, 2020 10:13:16 PM(UTC)
Quote
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 961

Thanks: 3 times
Was thanked: 115 time(s) in 112 post(s)
You can do the following:
1.get the coordinates of each individual character in the original object using the PdfTextObject.GetCharRect method;
2. calculate the offset of each character relative to the origin of the text object;
3. create new objects by specifying the offset of each character in the string;
Code:
byte[] offsets = ...
Pdfium.FPDFTextObj_SetText(textObject.Handle, "your text", ofssets);
lugangxyz  
#3 Posted : Thursday, October 29, 2020 10:10:48 AM(UTC)
Quote
lugangxyz

Rank: Newbie

Groups: Registered
Joined: 10/15/2020(UTC)
Posts: 8
China

Hi Paul
Really appreciate your great help

get the coordinates of each individual character in the original object using the PdfTextObject.GetCharRect method;

Seems the GetCharRect will not get the right pos for some special char, for example space, '(', any clue?
maybe something releated with Matrix?


calculate the offset of each character relative to the origin of the text object;

Are you mean call CalcCharPos? I think the returned result is also releated with Matrix?




lugangxyz  
#4 Posted : Thursday, October 29, 2020 6:37:35 PM(UTC)
Quote
lugangxyz

Rank: Newbie

Groups: Registered
Joined: 10/15/2020(UTC)
Posts: 8
China

Hi Paul
Just found a similar link :
https://forum.patagames....ight-and-Char-Rectangles

In the thread above you suggestion use PdfText, could you please share some examples of using PdfText instead of PdfTextObject?
Thanks in advance
Paul Rayman  
#5 Posted : Tuesday, November 3, 2020 2:26:27 AM(UTC)
Quote
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 961

Thanks: 3 times
Was thanked: 115 time(s) in 112 post(s)
Pdf Text will not help you with this task. You will not be able to map PdfText to PdfTextObject to remove unnecessary text.
Quick Reply Show Quick Reply
Users browsing this topic
New Topic Post Reply
Forum Jump  
You can post new topics in this forum.
You can reply to topics in this forum.
You can delete your posts in this forum.
You can edit your posts in this forum.
You cannot create polls in this forum.
You can vote in polls in this forum.