Just had to implement PrintToPDF support too and was also struggling with it. It's a year since your original post, but just in case if anybody else is running into the same problems i thought i write my findings here:
The following works for me (using CEF 2704):
procedure TFrameAnalyzer.OnPdfPrintFinished(const path: ustring; ok: Boolean);
begin
showMessage('done printing!');
end;
procedure TFrameAnalyzer.acPrintExecute(Sender: TObject);
var
pSettings : TCefPdfPrintSettings;
begin
pSettings.header_footer_title := CefString('Hello!');
pSettings.page_width:=0;
pSettings.page_height:=0;
pSettings.margin_top:=0;
pSettings.margin_right:=0;
pSettings.margin_bottom:=0;
pSettings.margin_left:=0;
pSettings.margin_type:= PDF_PRINT_MARGIN_DEFAULT;
pSettings.header_footer_enabled:= 1;
pSettings.selection_only:= 0;
pSettings.landscape:= 0;
pSettings.backgrounds_enabled := 1;
crm.browser.Host.PrintToPdfProc ( 'd:\test.pdf', @pSettings, OnPdfPrintFinished );
end;
There seems to be a bug that if you specify any page width/height then the PrintToPDF will just step over the printing without generating the output or calling the callback (This might be fixed in CEF 2840). Also, if you don't initialize the print-settings record then you might run into all kind of other problems and crashes.