logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
oberon232  
#1 Posted : Monday, March 4, 2019 3:59:20 PM(UTC)
oberon232

Rank: Newbie

Groups: Registered
Joined: 2/23/2019(UTC)
Posts: 6
United States
Location: FL

Thanks: 1 times
I have modified a PDF by adding a comment.
When I try to save using PdfViewer1.Document.Save(Enums.SaveFlags.NoIncremental), the comments don't save.
When I try to save using PdfViewer1.Document.Save(CurrentFile,Enums.SaveFlags.NoIncremental), an error returns that the file is in use.
When I try to save using PdfViewer1.Document.Save(NewFile,Enums.SaveFlags.NoIncremental), it saves to the new file.
My question, is there an option I need to set to either at save or load to be able to save changes to a PDF?
oberon232  
#2 Posted : Monday, March 4, 2019 7:35:31 PM(UTC)
oberon232

Rank: Newbie

Groups: Registered
Joined: 2/23/2019(UTC)
Posts: 6
United States
Location: FL

Thanks: 1 times
I worked around it, by reading the file in to a byte array and loading that as the document, that way there was no file lock on save.
Paul Rayman  
#3 Posted : Tuesday, March 5, 2019 12:48:06 AM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 779

Thanks: 1 times
Was thanked: 97 time(s) in 95 post(s)
Hi,

PdfViewer1.Document.Save(Enums.SaveFlags.NoIncremental)
This is saving in a custom way. When you call this method, the engine fires the PdfDocument.WriteBlock event and pass to the handler the data to being save. So you can save document in any way you want.

PdfViewer1.Document.Save(CurrentFile,Enums.SaveFlags.NoIncremental)
You cant to save the changes to the same file.
This is worth some explanation. Probably you noticed how even a very large PDF document with hundreds thousands of pages loads very fast. This becomes possible because there is not need to parse and load the entire document body. At first, only the cross-reference table is read and all the rest of data is loaded when needed. So the file is locked for write. You can't simultaneously read an object and write an another.
So you should implement an workaround. You can save to in memory byte array or to a temporary file, nex close original document and replace it with the saved copy.
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.