Need to create a Xps file from several existing FlowDocuments

Hi, i'm working in the API for my company products and i need to create the API in .Xps format. Right now i'm generating all the help files as FlowDocuments but what I need is compact all those FlowDocuments in a single .xps file. Soo please if you had any ideas please let me know.

[323 byte] By [CarlosJC] at [2008-1-9]
# 1

I would think if it's all flow document xml, you could just remove the <FlowDocument> and </FlowDocument> from all of them except the first page's <FlowDocument> and the last page's </FlowDocument> then merge all of the xml into one file. Then you can write it to xps. Not sure how to add page breaks....

file 1

<FlowDocument>

<!Your content -->

</FlowDocument>

file 2

<FlowDocument>

<!Your content -->

</FlowDocument>

result file:

<FlowDocument>

<!Your content -->

<!Your content -->

</FlowDocument>

JDPeckham at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 2

Thanks, it works. But now I'm like to access any page in that .xps using an id (name) and show it in a DocumentViewer. Right now i can access the FixedDocument in the xps (there is only one) and works (but it sows all the pages). I don't know if i can access a FixedPage and show it in a DocumentViewer: I trying using something like this:

FixedDocumentSequence fixDocSeq = m_xpsDoc.GetFixedDocumentSequence();

PageContent pageCont = fixDocSeq.References[0].GetDocument(false).Pages[0];

FixedPage fixPage = pageCont.GetPageRoot(false);

FixedDocument fixDoc = new FixedDocument();

((IAddChild)fixDoc).AddChild(pageCont);

documentViewer1.Document = fixDoc;

But i get an error: (Specified element is already the logical child of another element. Disconnect it first.)

Is there any other way to do this. Can I disconect that child (coz i was trying to do RemoveLogicalChild() and doesn't work).

If I can save each FlowDocument as a different Document in the xps I know that'll solve my problem.

Thanks for the help.

CarlosJC at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 3

I make it work with FixedPages now I have another problem:

I had hyperlinks in the FlowDocumnets (before converting in a xps file), and when I open the xps from the browser or when i use my application to open one of the FixedPages (inside the xps) the hyperlinks doesn't work (there are not clickable).

CarlosJC at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 4

I used another method and worked for my project.


Code Snippet

static public FlowDocument Merge(List<FlowDocument> FlowDocuments)
{
FlowDocument MadeFlowDoc = new FlowDocument();

if(FlowDocuments.Count > 0)
{
for(int i=0; i<FlowDocuments.Count; i++)
{
List<Block> MadeBlockFlowDocuments = new List<Block>(FlowDocuments[i].Blocks);

for(int k=0; k<MadeBlockFlowDocuments.Count; k++)
{
MadeFlowDoc.Blocks.Add(MadeBlockFlowDocuments[k]);
}
}
}

return MadeFlowDoc;
}

flyingmt at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 5

Can you tell please how it make works for you files?

I'm stucking with same problem and I wish if you can help some sample code that shows how this can be done (i.e. merging pxs documents by looping thro pages)

Thanks

JoeM11 at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...

Visual Studio Orcas

Site Classified