We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to TXT file branch convert Image ----using Aspose

If inscribe
i have a txt file ,There are one hundred rows in the file,
Now i need The 50 lines of these areas convert a Image .
The remaining 50 lines converting another Image


Thanks for your inquiry. Please note that Aspose.Words mimics the behavior of MS Word. You can use PageSetup.LayoutMode property to set the layout mode of this section as LineGrid and set number of lines per page.

The PageSetup.LinesPerPage property is used to get or set the number of lines per page in the document grid. Minimum value of the property is 1. Maximum value depends on page height and font size of the Normal style. Minimum line pitch is 136 percent of the font size. For example, maximum number of lines per page of a Letter page with one-inch margins is 39.

Following code example shows how to set the page height of document, set the lines per page, and save the pages to PNG image. Hope this helps you.

Document doc = new Document(MyDir + "in.txt");
doc.FirstSection.PageSetup.PageHeight = 1000;
doc.FirstSection.PageSetup.LinesPerPage = 50;
doc.FirstSection.PageSetup.LayoutMode = SectionLayoutMode.LineGrid;


ImageSaveOptions options = new ImageSaveOptions(SaveFormat.Png);
options.PageSavingCallback = new HandlePageSavingCallback();

doc.Save(MyDir + "18.11.png", options);

private class HandlePageSavingCallback : IPageSavingCallback
    public void PageSaving(PageSavingArgs args)
        args.PageFileName = string.Format(MyDir + @"Page_{0}.png", args.PageIndex);
1 Like

Thank you for code