You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public static void MakeXPS(FixedDocument fixedDoc, PrintTicket ticket, Stream os)
{
using (Package package = Package.Open(os, FileMode.Create))
{
var inMemPackageName = $"memorystream://foo.xps";
Uri packageUri = new Uri(inMemPackageName);
PackageStore.RemovePackage(packageUri);
PackageStore.AddPackage(packageUri, package);
using (XpsDocument xpsDoc = new XpsDocument(package, CompressionOption.Fast, inMemPackageName))
{
var paginator = ((IDocumentPaginatorSource)fixedDoc).DocumentPaginator;
/*paginator.ComputePageCount();
int pageCount = paginator.PageCount;
for (int i = 0; i < pageCount; ++i)
{
DocumentPage docPage = paginator.GetPage(i);
using (docPage)
{
// every FixedPage has its own PrintTicket
//((FixedPage)docPage.Visual)...
}
}*/
XpsPackagingPolicy policy = new XpsPackagingPolicy(xpsDoc);
using (var manager = new XpsSerializationManager(policy, false))
{
policy.PersistPrintTicket(ticket); // original printticket for document with default settings
manager.SaveAsXaml(paginator); // <-- does NOT save the printtickets attached to every FixedPage in the fixedDoc object
manager.Commit();
}
PackageStore.RemovePackage(packageUri);
}
}
}
In the code above you see that we create a new XPS document from a given FixedDocument.
The FixedDocument fixedDoc contains several FixedPages each page having its ownPrintTicket.
The PrintTicket ticket is a PrintTicket on document level (e.g. kind of 'default print settings').
When we use the XpsSerializationManager to create the XPS file, the PrintTickets attached to every page (FixedPage) are gone.
Why does XpsSerializationManager not save the PrintTickets at page level? Do I need to configure anything special?
(+ additional small question: should PackageStore.RemovePackage(packageUri); be done before XpsDocument.Close() or after (outside the using-statement)?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Sample code:
In the code above you see that we create a new XPS document from a given FixedDocument.
The FixedDocument
fixedDoc
contains severalFixedPage
s each page having its ownPrintTicket
.The PrintTicket
ticket
is a PrintTicket on document level (e.g. kind of 'default print settings').When we use the
XpsSerializationManager
to create the XPS file, the PrintTickets attached to every page (FixedPage) are gone.Why does
XpsSerializationManager
not save the PrintTickets at page level? Do I need to configure anything special?(+ additional small question: should
PackageStore.RemovePackage(packageUri);
be done before XpsDocument.Close() or after (outside theusing
-statement)?(also on https://stackoverflow.com/questions/71798390/printtticket-for-every-fixedpage-lost-when-using-xpsserializationmanager )
Beta Was this translation helpful? Give feedback.
All reactions