|
|
Alrighty then.
Just wanted to make sure I wasn't off the proverbial rocker.
Thank you.
|
|
|
You should save to another file, because the original file is blocked for writing. This is because PdfDocument.Load loads the file when needed, so it cannot be modified unless the original document is closed. 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 the entire document body. At first, only the cross-reference table is read and all the rest of data is loaded when needed. This is by design behavior. So you may save to byte array, close original file, next save byte array to the file. https://forum.patagames....-locked-pdf-file-problem
|
|
|
Code:private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
var location = @"c:\testform.pdf";
pdfViewer1.LoadDocument(location);
var rand = new Random();
foreach (var field in pdfViewer1.Document.FormFill.InterForm.Fields)
{
if (field.FieldType == Patagames.Pdf.Enums.FormFieldTypes.FPDF_FORMFIELD_TEXTFIELD)
{
field.Value = $"This is a magical field: {rand.Next()}";
}
}
// maybe some other modification...
// attach a file perhaps?
pdfViewer1.Document.Save(location, Patagames.Pdf.Enums.SaveFlags.NoIncremental);
}
That little "save the document" line is not a happy camper. complaining about the pdf being used by another process... the viewer, I imagine. So then, how to go about saving user supplied modifications? Does the PdfViewer component have a "save" method?
|
Important Information:
The Patagames Software Support Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close