priPrinter: Replace Text - priPrinter

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Replace Text

#1 User is offline   godiest 

  • Member
  • PipPip
  • Group: Senior Members
  • Posts: 25
  • Joined: 29-January 11

Posted 19 March 2015 - 09:52 AM

Hi,
I want to replace some text on document before printing with script.
Example document is attached.
On document I want to do these:
1. Add Value of BIAYA ADMIN with 700 (Value of BIAYA ADMIN on example is 1800), so BIAYA ADMIN will become 2.500
2. Add Value of TOTAL TAGIHAN with 700 (Value of TOTAL TAGIHAN on example is 41300), so TOTAL TAGIHAN will become 42.000

Please help, Thanks,,, :)/>

Edit: I forget to mention that value of BIAYA ADMIN and TOTAL TAGIHAN is sometimes different.

Attached File(s)


This post has been edited by godiest: 19 March 2015 - 10:03 AM

0

#2 User is offline   Alex 

  • Administrator
  • Group: Administrators
  • Posts: 238
  • Joined: 28-February 10
  • LocationHungary

Posted 19 March 2015 - 02:48 PM

Sounds complicated. Let me think.
0

#3 User is offline   godiest 

  • Member
  • PipPip
  • Group: Senior Members
  • Posts: 25
  • Joined: 29-January 11

Posted 19 March 2015 - 02:55 PM

Ok, i'm waiting :)
0

#4 User is offline   Alex 

  • Administrator
  • Group: Administrators
  • Posts: 238
  • Joined: 28-February 10
  • LocationHungary

Posted 23 March 2015 - 07:52 AM

We can't replace text, but we may extract it from page, delete text and print new one in the same place.
For the first one code will be following:
function GetNumber(str)
{
 local index=str.find("Rp");
if(index!=null)
{
    str=str.slice(index+2);
    while(str.slice(0,1)==".")
	{
	      str=str.slice(1);
	}
	return str.tofloat();  
}
 return 0;
}
function toString(n)
{
local n1=n%1;
local n2=n-n1;
n1*=1000;
local text=""+n1;
text="."+n2+"."+text;
while(text.len()<14)text="."+text;
text="Rp"+text;
return text;
}


local doc=window.GetDocument();
local page=doc.GetPage(0);
local r=Rect(160.4,39,194,42.5);
local font=Font("Courier New");
font.Height=9.6;
local text=page.GetText(r,{charArea=0.8});
local num=GetNumber(text);
num+=0.700;
local text2=toString(num);
page.DeleteRect(r);
page.font=font;
page.cursor=Point(161.5,41.9);
page.Print(text2);


For second you can do the same, just change rectangle of text and modify font to the bold one.
0

#5 User is offline   godiest 

  • Member
  • PipPip
  • Group: Senior Members
  • Posts: 25
  • Joined: 29-January 11

Posted 23 March 2015 - 04:28 PM

Okay, that's enough for me, thanks.
Will Replace Text implemented for next build of priPrinter? Or it's impossible?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users