本文介绍了在用PDF编写时以字符串格式退格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试用PDF打印两列信息,其中包含用户输入的一些字符串。这是我到目前为止的代码:

I'm trying to print in PDF two columns of information that contain some strings that the user inputs. This is my code so far:

string s = "";                                                                  
s = s + string.Format("{0,-60}", "Name: " + name);
s = s + string.Format("{0,15}","AAA: ");
p1.Add(s);
document.Add(p1);

string p = "";                                                                 
p = p + string.Format("{0,-60}", "Surname: " + surname);
p = p + string.Format("{0,15}","BBB: ");
p2.Add(p);
document.Add(p2);

string r = "";                                                        
r = r + string.Format("{0,-60}", "School: " + school);
r = r + string.Format("{0,15}","CCC: ");
p3.Add(r);
document.Add(p3);



如果用户输入,例如John Edward Jr.为了名字,Pascal Einstein W. Alfi为姓氏,圣约翰为学校,然后预期的输出是这样的:



姓名:John Edward Jr .________________ AAA:



姓:Pascal Einstein W. Alfi_______BBB:



学校:圣约翰____________________CCC:

我想每个字符串名称,姓氏和学校的空格都是问题所在。我怎么处理这个?



预期产量:



姓名:John Edward Jr ._________________ AAA:



姓:Pascal Einstein W. Alfi_______BBB:



学校:圣约翰________________________ CCC:


If the user enters, for example, "John Edward Jr." for name, "Pascal Einstein W. Alfi" for surname and "St. John" for school, then the expected output is something like this:

Name: John Edward Jr.________________AAA:

Surname: Pascal Einstein W. Alfi_______BBB:

School: St. John___________________CCC:
I suppose the spaces in every string name, surname and school are the problem. How can I deal with this?

EXPECTED OUTPUT:

Name: John Edward Jr._________________AAA:

Surname: Pascal Einstein W. Alfi_______BBB:

School: St. John________________________CCC:

推荐答案


这篇关于在用PDF编写时以字符串格式退格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 16:41