DynaPDF Manual - Page 83

Previous Page 82   Index   Next Page 84

Incremental Updates
Page 83 of 874
Hybrid XFA forms could be edited theoretically but this is not recommended since the XFA part
remains in the file after DeleteXFAForm() was called.
Incremental updates in practice
The most important thing that must be considered is that we must already decide whether a
PDF file should be incrementally updated or not when opening the file.
A PDF file that contains a digital signature should be prepared for an incremental update. All
other files, can be opened as usual.
Example (Delphi):
function InternalOpenPDFFile(const FileName: String;
var Pwd: AnsiString;
var PwType: TPwdType): Boolean;
var flags, retval: Integer; FormPwdDialog: TFormPwdDialog;
begin
Result := false;
flags
:= FPDF.GetGStateFlags;
// Enable UTF8 encoded passwords
FPDF.SetGStateFlags(gfAnsiStringIsUTF8, false);
retval := FPDF.OpenImportFile(FileName, PwType, Pwd);
if retval < 0 then begin
if and not FPDF.IsWrongPwd(retval) then Exit;
// Display a password dialog
while FPDF.IsWrongPwd(retval) do begin
FPDF.ClearErrorLog; // Remove the wrong password error message
if FormPwdDialog.ShowModal = mrOK then begin
Pwd
:= UTF8Encode(FormPwdDialog.edPasssword.Text);
PwType := ptOpen;
retval := FPDF.OpenImportFile(FileName, PwType, Pwd);
end else
break;
end;
end;
FPDF.SetGStateFlags(flags, true);
Result := retval >= 0;
end;
function IsSigned(PDF: TPDF): Boolean;
var i: Integer; f: TPDFFieldEx; sig: TPDFSigDict;
begin
Result
:= false;
f.StructSize
:= sizeof(f);
sig.StructSize := sizeof(sig);
for i := 0 to PDF.GetFieldCount -1 do begin
if PDF.GetFieldType(i) = Ord(ftSignature) then begin
if PDF.GetFieldEx(i, f)
and (f.ISignature <> nil)
and PDF.GetSigDict(f.ISignature, sig)
and (sig.ContentsSize > 0) then begin
Result := true;
Exit;
end;
end;
end;
end;
 

Previous topic: Incremental Updates, What is allowed and what is prohibited?

Next topic: Damaged PDF files, Possible errors