Open MarioZ opened 4 years ago
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.
I don't have write-permissions, but I think the "area-System.IO.Compression" should be used, just like in #24962 and #27397.
Any solution to this? having the really same issue
@Chapre how exactly are you creating your XpsDocument
?
In my case, I was able to obtain an XPS stream which enabled me to do this file access change in memory:
MemoryStream xpsStream = ...
var package = Package.Open(xpsStream, FileMode.Open, FileAccess.Read);
var uri = new Uri($"memorystream://{Guid.NewGuid():N}.xps");
PackageStore.AddPackage(uri, package);
this.xps = new XpsDocument(package, CompressionOption.NotCompressed, uri.AbsoluteUri);
this.viewer.Document = this.xps.GetFixedDocumentSequence();
@MarioZ i got the same exception, but when i tried to write the xps document with pagination. And i saw your question on closed issue that looks more like mine. My solution was divide read and write file access
`
....
//saving flow document as xps
using (var xpsDocument = new XpsDocument(TempFileName, FileAccess.Read)) //was FileAccess.ReadWrite
{
FixedDocumentSequence fixedDocSeq = xpsDocument.GetFixedDocumentSequence();
var documentPaginator documentPaginator = fixedDocSeq.DocumentPaginator;
...
using (var newDoc = new XpsDocument(fileName, FileAccess.Write))
{
...
XpsDocumentWriter writer = PrintQueue.CreateXpsDocumentWriter(PrintQueue);
....
writer.Write(documentPaginator);
xpsDocument.Close();
}
}
...
` Something like this in .net 5.0
Sorry for formatting, my first comment ever
I have the same problem,please fix it soon
What's more, I can't print,Using XpsDocument with DocumentViewer
Would you be interested in debugging into it @PeterPandefu ?
Would you be interested in debugging into it @PeterPandefu ?
what should I do?
Would you be interested in debugging into it @PeterPandefu ?
Is such that.
I have the same problem as him@MarioZ. I using XpsDocument with DocumentViewer and FlowDocument in WPF,
LoadXps like this:
using (MemoryStream ms = new MemoryStream()) { using (Package package = Package.Open(ms, FileMode.Create, FileAccess.ReadWrite)) { Uri DocumentUri = new Uri("pack://InMemoryDocument.xps"); PackageStore.RemovePackage(DocumentUri); PackageStore.AddPackage(DocumentUri, package); using (XpsDocument xpsDocument = new XpsDocument(package, CompressionOption.Fast, DocumentUri.AbsoluteUri)) { XpsDocumentWriter writer = XpsDocument.CreateXpsDocumentWriter(xpsDocument); //m_doc is FlowDocument; writer.Write(((IDocumentPaginatorSource)m_doc).DocumentPaginator); docViewer.Document = xpsDocument.GetFixedDocumentSequence(); xpsDocument.Close(); } } } } catch (Exception ex) { throw; }
If My FlowDocument Contain Image ,This error will appear,otherwise no And The issue occurs only in .NET Core, it doesn't occur in the .NET Framework. I don't konw my description is detailed? I wish you can help me.Thanks!
I'm getting an
IOException
and "Entries cannot be opened multiple times in Update mode." message when providingXpsDocument
toDocumentViewer
control.The issue occurs only in .NET Core, it doesn't occur in the .NET Framework.
I'm generating the
XpsDocument
in-memory and displaying it withDocumentViewer
, but this issue can also be reproduced by creating theXpsDocument
from the XPS file, see this repro project.After loading the XPS file, you need to do some actions/movements on the
DocumentViewer
control and eventually, the exception will occur. For instance, you can zoom in and out, hover inside and outside, click inside and outside the control, etc. I didn't determine exactly what action causes the issue, sometimes it is on mouse movement, sometimes it is on mouse click...Anyway, what I did notice is that the issue doesn't occur when file access is
Read
, notReadWrite
. Also, the issue doesn't occur when the XPS content doesn't contain any image.