[1] I'm trying to implement the pAuthCallback parameter so I can open password protected PDFs, but I'm not able to compile the code below, which is my attempt to implement the callback. Can you help me out with the proper syntax in Delphi.
[2] How do Iget OpenDocumentFromFile to open non-PDF files like image files and office files and automatically convert them into PDFs? Is that possible with this call from the Core Layer?
Code: Select all
function TPDFCoreLayer.OpenDocument(AFileName: String; APasswords: String = ''): Boolean;
procedure AuthCallback(const pDoc: IPXC_Document; nFlags: ULONG_T);
var
AAtom, AStandard: Cardinal;
AStatus: PXC_PermStatus;
begin
AAtom := pDoc.GetSecurityHandlerType(False);
if (AAtom > 0) then
begin
AStandard := INST_PXS.StrToAtom('Standard');
if (AStandard = AAtom) then
begin
AStatus := pDoc.AuthorizeWithPassword(PChar(FPassword));
if (AStatus = Perm_ReqGranted) then //?? How do I handle this?
end;
end;
end;
begin
Result := False;
if FileExists(AFileName) then
begin
FDoc := INST_PXC.OpenDocumentFromFile(PChar(AFileName), AuthCallback, nil, 0, 0);
Result := True;
end;
end;