on 09-19-2016 4:17 PM
Hi Experts,
We have requirement to display Form in different fonts for each company code.
For example,
For Company code 1: Entire Form layout text should be displayed in "Arial" Font
Company code 2: Entire form layout text should be displayed in "MS Gothic" Font
Company code 3: Entire form layout text should be displayed in "Arial Unicode " Font & so on...
I am thinking below two options, but would like to know any other efficient way...
1.
We can use Java script to display dynamic font, but in this case, we have more than 50 elements available in the form, I understand that we need to use Java script for all these elements individually... it would be huge task!!!
2.
Create multiple forms(each form for each Font) and use it.
Seeking for your advise.
Regards,
Kumar
use below javascript on data node, script will change font of all controls on the page.
data::ready:layout - (JavaScript, client)
var totalPages = xfa.layout.pageCount();
var oField, i = 0, j, n;
for (i = 0; i < totalPages; i++) {
oField = xfa.layout.pageContent(i, "field");
n = oField.length;
j = 0;
for (j = 0; j < n; j++) {
oField.item(j).font.typeface = "Courier";
}
oField = xfa.layout.pageContent(i, "draw");
n = oField.length;
j = 0;
for (j = 0; j < n; j++) {
oField.item(j).font.typeface = "Courier";
}
}
Hope this helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Prajesh,
Thank you for reply.
I have added above code @ data node.
1.
It just changed the font for Item level table data only. For rest it has old font only.
(We have different text elements on Master page, Standard texts on Master & body pages, Some text fields on both pages, these fonts also need to be changed)
2.
As I mentioned earlier, I have to restrict font for each company code.
I just added below statement above to your code.
if (structure1.bukrs.rawValue == XXXX)
{
And at the end of your code i have used }. But it has not worked, Can you tell me is this correct statement?
Can you please help on this.
Thank you for your help.
Try below refine code,
data::ready:layout - (JavaScript, client)
var totalPages = xfa.layout.pageCount();
var i = 0;
for (i = 0; i < totalPages; i++) {
setFont("field", 0);
setFont("draw", 0);
setFont("field", 1);
setFont("draw", 1);
}
function setFont(type, page) {
var oField = xfa.layout.pageContent(i, type, page);
var n = oField.length;
var j = 0;
for (j = 0; j < n; j++) {
oField.item(j).font.typeface = "Courier";
}
}
Hope this helps.
Thank you.
Code is working except for the Standard Texts, as this Standard texts using Style & Standard paragraph(Created from SMARTFORMS Tcode).
Can you please let me know is there any way to change the font for these.
Also can you please tell me how to achieve Second point?
2.
I have to restrict font for each company code.
I just added below statement above to your code.
if (structure1.bukrs.rawValue == XXXX)
{
And at the end of your code i have used }. But it has not worked.
Thank you so much for your help.
Regards,
Kumar
for your second point,
and try below:
data::ready:layout - (JavaScript, client)
var companyCode, fontName;
companyCode = BodyPage1.txtCompanyCode.rawValue;
switch(companyCode) {
case '1000':
fontName = "font1 name";
break;
case '1001':
fontName = "font2 name";
break;
case '1002':
fontName = "font3 name";
break;
}
var totalPages = xfa.layout.pageCount();
var i = 0;
for (i = 0; i < totalPages; i++) {
setFont("field", 0);
setFont("draw", 0);
setFont("field", 1);
setFont("draw", 1);
}
function setFont(type, page) {
var oField = xfa.layout.pageContent(i, type, page);
var n = oField.length;
var j = 0;
for (j = 0; j < n; j++) {
oField.item(j).font.typeface = fontName;
}
}
and also learn how retrive company code from below documnets,
If your company code field is on your form then use document.
If you want to get it from the context data document.
Hope this helps.
Thank you so much Prajesh,
It really helped me alot.
For Second point, it is working, however still i am seeing some text font has not get changed. As said earlier this text is coming from standard text.
If i use standard text directly without any styles/Paragraphs in it, it works.
But in my case, i have to use Styles & Paragraphs in that Standard text.
Can you please let me know is there any way to change the font for these types of texts.
Thank you so much.
Regards,
Kumar
Code doesn't care from where your text is coming, it only cares that in which control you bind your text.
Can you tell me how you are using standard text? because i use this Using of Standard Text (SO10) in Adobe Form - ABAP Development - SCN Wiki document and script is working fine for me.
Hope this helps.
Hi Prajesh,
Thank you for reply.
I have used Standard text in similar way. As i said earlier, When i use standard text(without style/paragrpah) it is working...Means, Font getting changed.
But, in the below case: (I have used Standard text & Standard Paragraph, First Para & Style) => This part of text is not getting changed
Thankyou.
Regards,
Kumar
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.