Click here to Skip to main content
15,911,360 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I am generating an xps document using XpsDocumentWriter by writing a visual object into it.

I would like to see some suggestion on, let's say I have a page long of visual image. However, if I want to put a pagebreak in the middle, and actually produce an xps document with 2 pages.

How can I do that?

If I break that visual object into 2, how can I add 2 pages into one xps document?

Code Snippet
C#
private DrawingVisual visual;
    private DrawingContext drawingContext;
     visual = new DrawingVisual();
      drawingContext = visual.RenderOpen();
      XpsDocument doc = new XpsDocument(PackageName,FileAccess.ReadWrite);
      XpsDocumentWriter writer = XpsDocument.CreateXpsDocumentWriter(doc);
      drawingContext.DrawText(new FormattedText(text,CultureInfo.GetCultureInfo("en-us"),
                              FlowDirection.LeftToRight,new Typeface("Microsoft Sans Serif"),
                              size,brush),new Point(36,36));

      writer.Write(visual);
     Viewer.Document = doc.GetFixedDocumentSequence();


Thanks in advance...
Posted
Updated 29-Jan-12 19:14pm
v3
Comments
Anuja Pawar Indore 30-Jan-12 1:15am    
Removed extra spaces...

1 solution

see this link, this may helps you
Here[^]

Thanks
--RA
 
Share this answer
 
Comments
sajithnet 30-Jan-12 3:40am    
many thanks for ur help here iam creating every thing in fly.

i used DocumentPaginator and set the pagesize(10,10)expecting the page will
get break after this size but no result

DocumentPaginator paginator = ((IDocumentPaginatorSource)doc.GetFixedDocumentSequence()).DocumentPaginator;
paginator.PageSize = new System.Windows.Size(10,10);
DocumentPage page = paginator.GetPage(0);//This is still showing original size not size(10,10)
return doc;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900