When someone print a document(with XPS printing path) I want to pause print job and edit SPL(which zipped XPS format) file.
If I edit the file with 7zip and save. If I resume the job that document printing without any problem.
If I open the SPL file with System.IO.Compression.ZipFile class or DotNetZip library or SevenZipSharp library and extract a file from SPL file & remove that filefrom SPL file and add that file again to SPL file it generates perfectly fine zip container. I compared the original SPL file and edited SPL file with 7zip, zipinfo, winrar tools and I didn't see any difference. All files in the container are exactly same. I also checked CRCs.
When I'm opening,editing and saving the zipfile I'm not changing anything about compression method, compression level and etc. As I said two zip files looks like exactly same but If I calculate CRCs of original and edited SPL files they are not same.
After I edited(just extracting a page file, deleting it from container and adding it again to container) If I try to resume print job I see an error in event viewer about PrintProcessor and I can't print it.
I can't figure out what's changing after I edit the file(not changing anything in container). I'm going crazy.
Is there any specification about the Zip format of SPL files?
Problem solves If I use "ZipPackage" class.
using (var pack = ZipPackage.Open(xpsFileName, FileMode.Open, FileAccess.ReadWrite))
{
foreach (var part in pack.GetParts()) if (part.Uri.OriginalString.EndsWith(".fpage"))
{
using (var file = part.GetStream(FileMode.Open, FileAccess.ReadWrite))
{
var page = ProcessPage(XElement.Load(file));
file.Position = 0;
page.Save(file);
file.SetLength(file.Position);
}
}
}