PageSplitter not working as expected
See original GitHub issueWith Aspose.Words 19.7 trying to use DocumentPageSplitter from the samples in order to get each page from a specific document as a new document. The code used is:
static void Main(string[] args)
{
try
{
const string fileName = "problematic_file.docx";
var license = new License();
license.SetLicense(...);
ExtractDocumentToPages(fileName, 1, 1);
}
finally
{
Console.WriteLine("Done!");
Console.ReadLine();
}
}
public static void ExtractDocumentToPages(string docName, int fromPage, int pagesCount)
{
string folderName = Path.GetDirectoryName(docName);
string fileName = Path.GetFileNameWithoutExtension(docName);
string extensionName = Path.GetExtension(docName);
string outFolder = Path.Combine(folderName, "_out");
Console.WriteLine("Processing document: " + fileName + extensionName);
Document doc = new Document(docName);
// Split nodes in the document into separate pages.
DocumentPageSplitter splitter = new DocumentPageSplitter(doc);
Document pageDoc = splitter.GetDocumentOfPageRange(fromPage, fromPage+pagesCount-1);
pageDoc.Save(Path.Combine(outFolder, string.Format("{0} - Out{1}", fileName, extensionName)));
}
The result file contains two pages instead of one. Please note that valid license is applied. The source and the result files are attached to the issue.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7
Top Results From Across the Web
PageSplitter Malfunction Aspose.Words.Net 17.3
I see the source code for PageSplitter.cs is built directly into our project. Is that normal? · Where can I get the latest...
Read more >Page Splitter Redux - KHKonsulting LLC
Split PDF pages in half using either an Acrobat Action or a folder level JavaScript.
Read more >Use of Splitter in pages with Master page.
Hi,. I am not able to get the splitter feature working in a page that contains master page. If I remove the master...
Read more >Javascript not working on mobile but works on desktop
As expected, the screen goes blank on my desktop browser for both local and on heroku, but when I test on mobile, the...
Read more >After adding <Splitter> menu, Back button is not showing ...
The Navigator's next page doesn't have the “Back” Button on top left of the Page (that is the expected behavior). What I noticed...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@nikola-yankov Page splitter mechanism is integrated into Aspose.Words 20.10. Now you can use Document.ExtractPages method. https://apireference.aspose.com/words/net/aspose.words/document/methods/extractpages I am closing the issue. Please feel free to report any further issue here or in the forum.
Hi, I’m using aspose.words 20.10 and I’m trying to fetch the number of pages count for the uploaded document. But It returning very huge and wrong page count.Please help me on this.
private Int32 GetWordPageCount(byte[] docData) { Int32 pages = 1; try { using (MemoryStream dataStream = new MemoryStream(docData)) { StreamReader sr = new StreamReader(dataStream); asw.License lic = new asw.License(); lic.SetLicense(“Aspose.Words.lic”); asw.Document doc = new asw.Document();
asw.DocumentBuilder db = new asw.DocumentBuilder(doc); db.Writeln(sr.ReadToEnd()); sr.Dispose(); sr.Close(); pages = db.Document.PageCount;
} }