[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1543
  • Last Modified:

C# to Delphi code translation for Amyuni HTML to PDF sample

I have downloaded free Amyuni WebkitPDF from here:
http://www.amyuni.com/en/webkitpdf/

The example that comes with it is written in C# and I need to translate it to Delphi 7.

As the minimum, I need a working code in Delphi 7 that will:

1. Open URL or local HTML file
2. Save it to a PDF file.

or using the dll calls:

1. WKPDFInitialize
2. WKPDFOpenURL
3. WKPDFSaveToFile
4. WKPDFTerminate
0
graga
Asked:
graga
1 Solution
 
Sinisa VukCommented:
Try this:

...
function WKPDFInitialize(license: WideString; key: WideString): Integer; stdcall external 'WebKit.dll';
function WKPDFTerminate(): Integer; stdcall external 'WebKit.dll';
function WKPDFOpenURL(url: WideString; var context: Pointer; pageRenderingOptions: Integer; isJavaScriptEnabled: Boolean): Integer; stdcall external 'WebKit.dll';
function WKPDFSaveToFile(fileName: WideString; context: Pointer): Integer; stdcall external 'WebKit.dll';
function WKPDFCloseContext(context: Pointer): Integer; stdcall external 'WebKit.dll';
...

ptr: Pointer;
...
if WKPDFInitialize('', '')<>0 then Exit;
ptr := nil;
if WKPDFOpenURL('http://www.google.com', ptr, 0, False)<>0 then Exit;
if ptr<>nil then
begin
   WKPDFSaveToFile('c:\eee.pdf', ptr);
   WKPDFCloseContext(ptr);
end;

....

Open in new window

0
 
gragaAuthor Commented:
Thanks for the solution. It works fine on web pages, but I can't make it work on local files, like  'file:\\\c:\test.html'. The C# example works fine for local files. Can you look into it as well?
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now