我有两份文件,一份用西班牙语,一份用英语(英语是西班牙语原文的翻译版本)。我要从这两个文档中创建第三个文档,每个文档在均匀编号的页面上包括西班牙文,在相反的奇数编号的页面上包含相应的英语翻译。
我正在用尽整个页面的两边,除了一章的末尾(每个新章节都有分页符,因此它可以从页面顶部开始)。诚然,为了用尽整个页面,有时文本的某些部分位于下一页(也就是说,有时在西班牙语的第18页底部显示的内容的英文翻译出现在顶部)而不是在第19页的底部)。
我目前正在手动执行以下操作来完成此操作,同时打开了所有三个Open Office文档(Spanish.odt,English.odt和SpanishEnglish.odt):
0) Cut and paste exactly one page of material from Spanish.odt to the next (even-numbered) page of SpanishEnglish.odt
1) Mash the Enter key to move to the next (odd-numbered) page
2) Cut and paste exactly one page of material from English.odt to the next (odd-numbered) page of SpanishEnglish.odt
3) Mash the Enter key to move to the next (even-numbered) page
另外,我会定期(到达章节末尾)插入分页符;如果本章的结尾在西班牙英语.odt上的西班牙语或英语页面上都不合适(当然另一种页面不适合),我会减小太长页面的字体大小(从Verdana 10到Verdana) 9)强制将其限制在该页面上,以使各章并排开始(西班牙语在左边/偶数,英语在右边/奇数),而没有任何空白页。
您可以想像到-特别是对于大型文档-此过程很快变得非常乏味。有没有办法在C#中以编程方式完成相同的事情?
Shujaat Siddiqui,我想你的意思是更改最后几行:
The Dangerous Pelican Movie
. . .
La película de los pelícanos peligrosos
...对此:
The Dangerous Pelican Movie&&&&
. . .
La película de los pelícanos peligrosos&&&&
...在最后一行后面加上“ &&&&”-Correctomundo?但是在许多情况下,此附加文本(“ &&&&”)会将内容推到下一页(一个或多个“&”号将流到下一页),不是吗?
有点棘手。我正在尝试给您基本的想法。
这里是一个示例代码,只是为了向您提供基本的逻辑。
string Doc1Read = //read from english file
string Doc2Read = // read from Spanish file
string exp = @"[\w\s\n\r\t\.\(\)\,\[\]\-\;\:\%\@\#]*(?=&&&&)";
var Doc1matches = Regex.Matches(Doc1Read, exp);
var Doc2matches = Regex.Matches(Doc2Read, exp);
for (int i = 0; i < Doc1matches.Count; i++)
{
**// open third document file and write**
Doc1matches[i].Value; // write english version of page i
Doc2matches[i].Value; // write spanish version of page i
}
&&&&用于逐页获取文本。这样,当您使用时Doc1matches[i].Value;
,基本上可以得到写在页码i上的内容,即{1,2,3 ...}。
希望对您有帮助。
PS:您也可以使用&&&&string.Split("&&&&");
来中断字符串。并可以实现逻辑。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句