wpf - PageBreak in flow documents at runtime -
this first post.... have problem in task…..iam able text file on flow document have divide contents in proper pagebreaks @ runtime i.e if contents huge shud in number of pages @ runtime.
please help….. iam attaching initial code:
using system; using system.collections.generic; using system.linq; using system.text; using system.windows; using system.windows.controls; using system.windows.data; using system.windows.documents; using system.windows.input; using system.windows.media; using system.windows.media.imaging; using system.windows.navigation; using system.windows.shapes; namespace textonflowdoc { /// <summary> /// interaction logic page1.xaml /// </summary> public partial class page1 : page { public page1() { initializecomponent(); paragraph paragraph = new paragraph(); paragraph.inlines.add(system.io.file.readalltext(@"c:\lis.txt")); paragraph.fontfamily = new fontfamily("couriernew"); flowdocument document = new flowdocument(paragraph); // flowdocumentreader rdr = new flowdocumentreader(); flowdocscl.document = document; } } }
now "flowdocscl" flow document , needs breaked pages @ runtime. in advance.
thanks lot advice. have used code in following manner , achieved wanted.
var pages = ts.split(new string[] { "\f" }, stringsplitoptions.none); (int = 0; < pages.length; i++) { if (i != pages.length - 1) { cmbpagenbr.items.add(i + 1); } } if (cmbpagenbr.items.count > 0) { cmbpagenbr.selectedindex = 0; } loadpagewisedata(cmbpagenbr.selectedindex); } private void loadpagewisedata(int pagenbr) { var pages = ts.split(new string[] { "\f" }, stringsplitoptions.none); flowdocument document = new flowdocument(); document.blocks.add(new paragraph(new run(pages[pagenbr])) { breakpagebefore = true }); document.fontfamily = new system.windows.media.fontfamily("courier new"); document.fontsize = 12; docviewer.document = document; }
Comments
Post a Comment