指点成金-最美分享吧

登录

如何破解aspose.words

佚名 举报

篇首语:本文由小编为大家整理,主要介绍了如何破解aspose.words相关的知识,希望对你有一定的参考价值。

参考技术A

    1、打开aspose.words.dll下载并解压aspose.words.dll

    2、它是Aspose.Words 6.5 for .Net的破解文件,能够完美破解该报告控件,使用时只需将它引用到项目中就可以了

如何在 Aspose.Words 中插入自定义页码

【中文标题】如何在 Aspose.Words 中插入自定义页码【英文标题】:How to insert custom page number in Aspose.Words 【发布时间】:2015-05-05 16:05:27 【问题描述】:

我想使用 Aspose.Words 将自定义页码(如 1/2、2/2)添加到 Word 文档。但我找不到 c# 语言的任何示例。我试图覆盖页脚,但我无法为页码提供格式。请帮忙!谢谢!


编辑


在我尝试了第一个答案后,它按我想要的方式工作,但又出现了另一个问题。我将子文档添加到主文档。我只能格式化主文档的编号。子文档仍然有普通的页码。这里是代码示例;

   public void AddChildDocs (System.IO.Stream parentStream, List childStreams)            doc = new Aspose.Words.Document(parentStream);        if (Items.Count > 0)                    WordReplacer evaluator = new WordReplacer(this);            doc.Range.Replace(new Regex(ReplaceRegex), evaluator, false);                foreach (var item in childStreams)                    Aspose.Words.Document childDoc = new Aspose.Words.Document(item);            if (Items.Count > 0)                            WordReplacer evaluator = new WordReplacer(this);                childDoc.Range.Replace(new Regex(ReplaceRegex), evaluator, false);                        doc.AppendDocument(childDoc, ImportFormatMode.KeepSourceFormatting);                DocumentBuilder builder = new DocumentBuilder(doc);        builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);        builder.InsertField("PAGE", "");        builder.Write(" / ");        builder.InsertField("NUMPAGES", "");    

【问题讨论】:

【参考方案1】:

您可以从 Aspose 文档中的 this page 获得想法。以下是取自同一页面的示例代码,但仅与自定义页码有关。

String src = dataDir + "Page numbers.docx";String dst = dataDir + "Page numbers_out.docx";// Create a new document or load from diskAspose.Words.Document doc = new Aspose.Words.Document(src);// Create a document builderAspose.Words.DocumentBuilder builder = new DocumentBuilder(doc);// Go to the primary footerbuilder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);// Add fields for current page numberbuilder.InsertField("PAGE", "");// Add any custom textbuilder.Write(" / ");// Add field for total page numbers in documentbuilder.InsertField("NUMPAGES", "");// Import new documentAspose.Words.Document newDoc = new Aspose.Words.Document(dataDir + "new.docx");// Link the header/footer of first section to previous documentnewDoc.FirstSection.HeadersFooters.LinkToPrevious(true);doc.AppendDocument(newDoc, ImportFormatMode.UseDestinationStyles);// Save the documentdoc.Save(dst);

我与 Aspose 合作,担任开发人员宣传员。

【讨论】:

感谢您的回复,我有一个主文档,我正在向其中添加其他文档。有了这个解决方案,我可以只添加页码主文档。有什么办法可以添加页码子文档。 页码在页眉/页脚中设置。每个部分都有自己的页眉/页脚。每当您添加新文档时,都会创建一个新部分,因此其页眉/页脚可能与主文档不同。一种解决方案是为所有导入的文档调用 LinkToPrevious(true)。这将使您的所有页面保持一致。 我已经更新了答案并将一个新文档导入到 main.js 中。我调用了 LinkToPrevious(true),这样它就会保持与主文档相同的页码样式。 非常感谢,这完全符合我的要求!我无法投票赞成这个答案,因为我的声誉很低。但是在我有足够的声誉之后,我会的。祝你有美好的一天。 对于添加页码这样简单的东西,这可能是有史以来最糟糕的 API。为什么文档中没有像 .addFooter(new SimplePageNumberFooter()) 这样的简单方法?这就像自我记录代码的概念不仅被忽略了,而且完全被反对。如果没有对这些神奇的单词和对象的具体知识,这似乎是故意使人感到困惑和无法使用的。【参考方案2】:

这是在aspose.word 中设置自定义页码的代码,当您设置页边距和起始页码时,当该特定页面区域完成时,它会自动获取下一页。试试这个,它会工作的......

section.PageSetup.PaperSize = PaperSize.Letter;section.PageSetup.LeftMargin = 10;section.PageSetup.RightMargin = 10;section.PageSetup.TopMargin = 00;section.PageSetup.BottomMargin = 0;section.PageSetup.HeaderDistance = 50;section.PageSetup.FooterDistance = 50;section.PageSetup.Borders.Color = Color.Black;section.PageSetup.PageStartingNumber = 1;

【讨论】:

以上是关于如何破解aspose.words的主要内容,如果未能解决你的问题,请参考以下文章