diff --git a/cefHtmlSnapshot.dpr b/cefHtmlSnapshot.dpr index 3bbb2ef..c3e2648 100644 --- a/cefHtmlSnapshot.dpr +++ b/cefHtmlSnapshot.dpr @@ -112,13 +112,14 @@ uses procedure RunAsSubProcess; begin - GlobalCEFApp := TCefApplicationCore.Create; - GlobalCEFApp.WindowlessRenderingEnabled := True; - GlobalCEFApp.EnableHighDPISupport := True; - GlobalCEFApp.ShowMessageDlg := False; - GlobalCEFApp.BlinkSettings := 'hideScrollbars'; - GlobalCEFApp.StartSubProcess; - DestroyGlobalCEFApp; + GlobalCEFApp := TCefApplicationCore.Create; + GlobalCEFApp.WindowlessRenderingEnabled := True; + GlobalCEFApp.ShowMessageDlg := False; + GlobalCEFApp.BlinkSettings := 'hideScrollbars'; + GlobalCEFApp.NoSandbox := False; + + GlobalCEFApp.StartSubProcess; + DestroyGlobalCEFApp; end; var @@ -155,6 +156,7 @@ begin Writeln(E.ClassName, ': ', E.Message); end; finally - DestroyGlobalCEFApp; + // just let windows kill the subprocess, it's dirty but faster + // DestroyGlobalCEFApp; end; end. diff --git a/cefHtmlSnapshot.dproj b/cefHtmlSnapshot.dproj index 25135ca..5cedd86 100644 --- a/cefHtmlSnapshot.dproj +++ b/cefHtmlSnapshot.dproj @@ -89,7 +89,7 @@ true false 3 - D:\GC\cefHtmlSnapshot\test\report_4.mhtml test\snapshot4.txt + D:\GC\cefHtmlSnapshot\test\report_4.mhtml test\snapshot4.bmp true cefHtmlSnapshot_Icon.ico true @@ -97,6 +97,8 @@ 8 CompanyName=delphitools.info;FileDescription=$(MSBuildProjectName);FileVersion=0.8.104.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= 104 + false @@ -935,4 +937,12 @@ + + + False + + False + "C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\signtool.exe" sign /n "Eric Grange" /tr http://timestamp.sectigo.com?td=sha256 /du https://delphitools.info/ /fd sha256 /td sha256 /v $(OUTPUTPATH) + False + diff --git a/uCEFBrowserThread.pas b/uCEFBrowserThread.pas index a9f3500..c3ddd59 100644 --- a/uCEFBrowserThread.pas +++ b/uCEFBrowserThread.pas @@ -47,16 +47,14 @@ interface {$ELSE} Windows, Messages, SysUtils, Classes, Graphics, SyncObjs, Math, {$ENDIF} - uCEFChromium, uCEFTypes, uCEFInterfaces, uCEFConstants, uCEFBufferPanel, - uCEFChromiumCore, uCEFMiscFunctions, uCEFSnapshotParameters; + uCEFChromium, uCEFTypes, uCEFInterfaces, uCEFConstants, + uCEFBrowserBitmap, uCEFChromiumCore, uCEFMiscFunctions, uCEFSnapshotParameters; type - TVirtualBufferPanel = class(TBufferPanel) + TVirtualBrowserBitmap = class(TCEFBrowserBitmap) protected FCustomScale : single; - function GetScreenScale : single; override; - public property CustomScale : single read FCustomScale write FCustomScale; end; @@ -64,8 +62,8 @@ TVirtualBufferPanel = class(TBufferPanel) TCEFBrowserThread = class(TThread) protected FBrowser : TChromium; - FPanel : TVirtualBufferPanel; - FPanelSize : TSize; + FBrowserBitmap : TVirtualBrowserBitmap; + FBrowserSize : TSize; FParameters : TSnapshotParameters; FPopUpBitmap : TBitmap; FPopUpRect : TRect; @@ -76,7 +74,6 @@ TCEFBrowserThread = class(TThread) FResizing : boolean; FPendingResize : boolean; FInitialized : boolean; - FSnapshot : TBitmap; FSnapshotText : String; FConsoleMessages : TStringList; FOnSnapshotAvailable : TNotifyEvent; @@ -97,8 +94,6 @@ TCEFBrowserThread = class(TThread) procedure SetErrorText(const aValue : ustring); - procedure Panel_OnResize(Sender: TObject); - procedure Browser_OnAfterCreated(Sender: TObject; const browser: ICefBrowser); procedure Browser_OnPaint(Sender: TObject; const browser: ICefBrowser; kind: TCefPaintElementType; dirtyRectsCount: NativeUInt; const dirtyRects: PCefRectArray; const buffer: Pointer; aWidth, aHeight: Integer); procedure Browser_OnGetViewRect(Sender: TObject; const browser: ICefBrowser; var rect: TCefRect); @@ -160,16 +155,6 @@ implementation CEF_SNAPSHOT_TIMER_MSG = WM_APP + 5; -// ************************************* -// ******** TVirtualBufferPanel ******** -// ************************************* - -function TVirtualBufferPanel.GetScreenScale : single; -begin - Result := FCustomScale; -end; - - // ************************************* // ********* TCEFBrowserThread ********* // ************************************* @@ -181,9 +166,9 @@ constructor TCEFBrowserThread.Create(const parameters : TSnapshotParameters); FreeOnTerminate := False; FInitialized := False; FBrowser := nil; - FPanel := nil; - FPanelSize.cx := parameters.Width; - FPanelSize.cy := parameters.Height; + FBrowserBitmap := nil; + FBrowserSize.cx := parameters.Width; + FBrowserSize.cy := parameters.Height; FParameters := parameters; FPopUpBitmap := nil; FPopUpRect := rect(0, 0, 0, 0); @@ -192,7 +177,6 @@ constructor TCEFBrowserThread.Create(const parameters : TSnapshotParameters); FPendingResize := False; FResizeCS := nil; FBrowserInfoCS := nil; - FSnapshot := nil; FOnSnapshotAvailable := nil; FOnError := nil; FClosing := False; @@ -203,9 +187,8 @@ constructor TCEFBrowserThread.Create(const parameters : TSnapshotParameters); destructor TCEFBrowserThread.Destroy; begin FreeAndNil(FBrowser); - FreeAndNil(FPanel); + FreeAndNil(FBrowserBitmap); FreeAndNil(FPopUpBitmap); - FreeAndNil(FSnapshot); FreeAndNil(FResizeCS); FreeAndNil(FBrowserInfoCS); FreeAndNil(FConsoleMessages); @@ -220,11 +203,11 @@ procedure TCEFBrowserThread.AfterConstruction; FResizeCS := TCriticalSection.Create; FBrowserInfoCS := TCriticalSection.Create; - FPanel := TVirtualBufferPanel.Create(nil); - FPanel.CustomScale := FParameters.Scale; - FPanel.Width := FPanelSize.cx; - FPanel.Height := FPanelSize.cy; - FPanel.OnResize := Panel_OnResize; + FBrowserBitmap := TVirtualBrowserBitmap.Create; + FBrowserBitmap.CustomScale := FParameters.Scale; + FBrowserBitmap.PixelFormat := pf32bit; + FBrowserBitmap.HandleType := bmDIB; + FBrowserBitmap.SetSize(FBrowserSize.cx, FBrowserSize.cy); FBrowser := TChromium.Create(nil); FBrowser.DefaultURL := FParameters.URL; @@ -319,7 +302,7 @@ function TCEFBrowserThread.CopySnapshot(var aSnapshot : TBitmap) : boolean; try FBrowserInfoCS.Acquire; - if assigned(FSnapshot) and not(FSnapshot.Empty) then + if assigned(FBrowserBitmap) and not(FBrowserBitmap.Empty) then begin if (aSnapshot = nil) then begin @@ -328,13 +311,13 @@ function TCEFBrowserThread.CopySnapshot(var aSnapshot : TBitmap) : boolean; aSnapshot.HandleType := bmDIB; end; - if (aSnapshot.Width <> FSnapshot.Width) then - aSnapshot.Width := FSnapshot.Width; + if (aSnapshot.Width <> FBrowserBitmap.Width) then + aSnapshot.Width := FBrowserBitmap.Width; - if (aSnapshot.Height <> FSnapshot.Height) then - aSnapshot.Height := FSnapshot.Height; + if (aSnapshot.Height <> FBrowserBitmap.Height) then + aSnapshot.Height := FBrowserBitmap.Height; - aSnapshot.Canvas.Draw(0, 0, FSnapshot); + aSnapshot.Canvas.Draw(0, 0, FBrowserBitmap); Result := True; end; except @@ -360,8 +343,8 @@ function TCEFBrowserThread.SaveSnapshotToFile(const aPath : ustring) : boolean; if FParameters.OutputFormat = sofTXT then begin Result := FParameters.SaveText(FSnapshotText); end else begin - if assigned(FSnapshot) and not(FSnapshot.Empty) then begin - FParameters.SaveBitmap(FSnapshot); + if assigned(FBrowserBitmap) and not(FBrowserBitmap.Empty) then begin + FParameters.SaveBitmap(FBrowserBitmap); Result := True; end; end; @@ -394,11 +377,6 @@ function TCEFBrowserThread.TerminateBrowserThread : boolean; PostThreadMessage(ThreadID, CEF_CLOSE_BROWSER_MSG, 0, 0); end; -procedure TCEFBrowserThread.Panel_OnResize(Sender: TObject); -begin - Resize; -end; - procedure TCEFBrowserThread.Browser_OnAfterCreated(Sender: TObject; const browser: ICefBrowser); begin if assigned(FBrowserInfoCS) then @@ -424,12 +402,12 @@ procedure TCEFBrowserThread.Browser_OnPaint(Sender: TObject; const browser: ICef begin if FFullRepaintRequested then FPaintedAfterRepaintrequest := True; - if assigned(FResizeCS) and assigned(FPanel) then + if assigned(FResizeCS) and assigned(FBrowserBitmap) then try FResizeCS.Acquire; TempForcedResize := False; - if FPanel.BeginBufferDraw then + if FBrowserBitmap.BeginBufferDraw then begin if (kind = PET_POPUP) then begin @@ -453,11 +431,11 @@ procedure TCEFBrowserThread.Browser_OnPaint(Sender: TObject; const browser: ICef end else begin - TempForcedResize := FPanel.UpdateBufferDimensions(aWidth, aHeight) or not(FPanel.BufferIsResized(False)); - TempWidth := FPanel.BufferWidth; - TempHeight := FPanel.BufferHeight; - TempScanlineSize := FPanel.ScanlineSize; - TempBufferBits := FPanel.BufferBits; + TempForcedResize := FBrowserBitmap.UpdateBufferDimensions(aWidth, aHeight) or not(FBrowserBitmap.BufferIsResized(False)); + TempWidth := FBrowserBitmap.Width; + TempHeight := FBrowserBitmap.Height; + TempScanlineSize := FBrowserBitmap.ScanlineSize; + TempBufferBits := FBrowserBitmap.BufferBits; end; if (TempBufferBits <> nil) and FFullRepaintRequested then @@ -505,11 +483,11 @@ procedure TCEFBrowserThread.Browser_OnPaint(Sender: TObject; const browser: ICef min(FPopUpRect.Right - FPopUpRect.Left, FPopUpBitmap.Width), min(FPopUpRect.Bottom - FPopUpRect.Top, FPopUpBitmap.Height)); - FPanel.BufferDraw(FPopUpBitmap, TempSrcRect, FPopUpRect); + FBrowserBitmap.BufferDraw(FPopUpBitmap, TempSrcRect, FPopUpRect); end; end; - FPanel.EndBufferDraw; + FBrowserBitmap.EndBufferDraw; if (kind = PET_VIEW) then begin @@ -527,12 +505,12 @@ procedure TCEFBrowserThread.Browser_OnPaint(Sender: TObject; const browser: ICef procedure TCEFBrowserThread.Browser_OnGetViewRect(Sender: TObject; const browser: ICefBrowser; var rect: TCefRect); begin - if assigned(FPanel) then + if assigned(FBrowserBitmap) then begin rect.x := 0; rect.y := 0; - rect.width := DeviceToLogical(FPanel.Width, FParameters.Scale); - rect.height := DeviceToLogical(FPanel.Height, FParameters.Scale); + rect.width := DeviceToLogical(FBrowserBitmap.Width, FParameters.Scale); + rect.height := DeviceToLogical(FBrowserBitmap.Height, FParameters.Scale); end; end; @@ -547,12 +525,12 @@ procedure TCEFBrowserThread.Browser_OnGetScreenInfo(Sender: TObject; const brows var TempRect : TCEFRect; begin - if assigned(FPanel) then + if assigned(FBrowserBitmap) then begin TempRect.x := 0; TempRect.y := 0; - TempRect.width := DeviceToLogical(FPanel.Width, FParameters.Scale); - TempRect.height := DeviceToLogical(FPanel.Height, FParameters.Scale); + TempRect.width := DeviceToLogical(FBrowserBitmap.Width, FParameters.Scale); + TempRect.height := DeviceToLogical(FBrowserBitmap.Height, FParameters.Scale); screenInfo.device_scale_factor := FParameters.Scale; screenInfo.depth := 0; @@ -661,14 +639,14 @@ procedure TCEFBrowserThread.Resize; begin if FClosing or Terminated or not(Initialized) then exit; - if assigned(FResizeCS) and assigned(FPanel) then + if assigned(FResizeCS) and assigned(FBrowserBitmap) then try FResizeCS.Acquire; if FResizing then FPendingResize := True else - if FPanel.BufferIsResized then + if FBrowserBitmap.BufferIsResized then FBrowser.Invalidate(PET_VIEW) else begin @@ -709,6 +687,12 @@ procedure TCEFBrowserThread.SetCookies; p := Pos(':', domain); if p > 0 then SetLength(domain, p-1); + p := Pos(':', domain); + if p > 0 then + SetLength(domain, p-1); + p := Pos('@', domain); + if p > 0 then + domain := Copy(domain, p+1) end; var path := fields.Values['path']; @@ -828,27 +812,27 @@ function TCEFBrowserThread.TakeSnapshot : boolean; if FClosing or Terminated or not(Initialized) then exit; - if assigned(FBrowserInfoCS) and assigned(FPanel) and FPanel.BeginBufferDraw then + if assigned(FBrowserInfoCS) and assigned(FBrowserBitmap) and FBrowserBitmap.BeginBufferDraw then try FBrowserInfoCS.Acquire; case FParameters.OutputFormat of sofPDF, sofPrinter : begin - FBrowser.PDFPrintOptions.page_width := FParameters.PDFOptions.page_width; - FBrowser.PDFPrintOptions.page_height := FParameters.PDFOptions.page_height; - FBrowser.PDFPrintOptions.margin_type := FParameters.PDFOptions.margin_type; - FBrowser.PDFPrintOptions.margin_top := FParameters.PDFOptions.margin_top; - FBrowser.PDFPrintOptions.margin_left := FParameters.PDFOptions.margin_left; - FBrowser.PDFPrintOptions.margin_right := FParameters.PDFOptions.margin_right; - FBrowser.PDFPrintOptions.margin_bottom := FParameters.PDFOptions.margin_bottom; + FBrowser.PDFPrintOptions.PaperWidthInch := FParameters.PDFOptions.paper_width; + FBrowser.PDFPrintOptions.PaperHeightInch := FParameters.PDFOptions.paper_height; + FBrowser.PDFPrintOptions.MarginType := FParameters.PDFOptions.margin_type; + FBrowser.PDFPrintOptions.MarginTopInch := FParameters.PDFOptions.margin_top; + FBrowser.PDFPrintOptions.MarginLeftInch := FParameters.PDFOptions.margin_left; + FBrowser.PDFPrintOptions.MarginRightInch := FParameters.PDFOptions.margin_right; + FBrowser.PDFPrintOptions.MarginBottomInch := FParameters.PDFOptions.margin_bottom; if FParameters.Scale <> 1 then - FBrowser.PDFPrintOptions.scale_factor := Round(FParameters.Scale * 100); - FBrowser.PDFPrintOptions.landscape := FParameters.PDFOptions.landscape <> 0; - FBrowser.PDFPrintOptions.header_footer_enabled := (FParameters.PDFTitle <> '') or (FParameters.PDFURL <> ''); - FBrowser.PDFPrintOptions.backgrounds_enabled := FParameters.PDFOptions.backgrounds_enabled <> 0; + FBrowser.PDFPrintOptions.Scale := FParameters.Scale; + FBrowser.PDFPrintOptions.Landscape := FParameters.PDFOptions.landscape <> 0; + FBrowser.PDFPrintOptions.DisplayHeaderFooter := (FParameters.PDFTitle <> '') or (FParameters.PDFURL <> ''); + FBrowser.PDFPrintOptions.PrintBackground := FParameters.PDFOptions.print_background <> 0; if FParameters.Print then FBrowser.Print - else FBrowser.PrintToPDF(FParameters.OutputFilePath, FParameters.PDFTitle, FParameters.PDFURL); + else FBrowser.PrintToPDF(FParameters.OutputFilePath);//, FParameters.PDFTitle, FParameters.PDFURL); end; sofTXT : begin case FParameters.TextSource of @@ -867,28 +851,28 @@ function TCEFBrowserThread.TakeSnapshot : boolean; end; end; else - if assigned(FPanel.Buffer) and not(FPanel.Buffer.Empty) then + if assigned(FBrowserBitmap) and not(FBrowserBitmap.Empty) then begin - if (FSnapshot = nil) then - begin - FSnapshot := TBitmap.Create; - FSnapshot.PixelFormat := pf32bit; - FSnapshot.HandleType := bmDIB; - end; - - if (FSnapshot.Width <> FPanel.BufferWidth) then - FSnapshot.Width := FPanel.BufferWidth; - - if (FSnapshot.Height <> FPanel.BufferHeight) then - FSnapshot.Height := FPanel.BufferHeight; - - FSnapshot.Canvas.Draw(0, 0, FPanel.Buffer); +// if (FBrowserBitmap = nil) then +// begin +// FSnapshot := TBitmap.Create; +// FSnapshot.PixelFormat := pf32bit; +// FSnapshot.HandleType := bmDIB; +// end; +// +// if (FSnapshot.Width <> FBrowserBitmap.BufferWidth) then +// FSnapshot.Width := FBrowserBitmap.BufferWidth; +// +// if (FSnapshot.Height <> FBrowserBitmap.BufferHeight) then +// FSnapshot.Height := FBrowserBitmap.BufferHeight; +// +// FSnapshot.Canvas.Draw(0, 0, FBrowserBitmap.Buffer); Result := True; end; end; finally FBrowserInfoCS.Release; - FPanel.EndBufferDraw; + FBrowserBitmap.EndBufferDraw; end; end; diff --git a/uCEFSnapshotParameters.pas b/uCEFSnapshotParameters.pas index 16e36a7..fca488b 100644 --- a/uCEFSnapshotParameters.pas +++ b/uCEFSnapshotParameters.pas @@ -7,7 +7,7 @@ interface uCEFTypes, uCEFMiscFunctions; const - cChromiumSubFolder = 'Chromium104.0'; + cChromiumSubFolder = 'Chromium112.0'; cDLLSubfolder = 'Libraries'; type @@ -116,6 +116,9 @@ implementation + ' --frame Specifies the name of the frame for text our html output (by default main frame)'#10 ; + cMicronsToInches = 1 / 25400; + cPointsToInches = 1 / 72; + // ParseCommandLineParameters // function ParseCommandLineParameters : TSnapshotParameters; @@ -136,6 +139,24 @@ function ParseCommandLineParameters : TSnapshotParameters; end else Result := ''; end; + function TryParseFloatMicronsToInchesParameter(const name, p : String; var value : Double; mini, maxi : Double) : String; + begin + value := StrToFloatDef(p, mini-1); + if (value < mini) or (value > maxi) then begin + Result := 'Invalid ' + name + ' value: "' + p + '"'; + end else Result := ''; + value := value * cMicronsToInches; + end; + + function TryParseFloatPointsToInchesParameter(const name, p : String; var value : Double; mini, maxi : Double) : String; + begin + value := StrToFloatDef(p, mini-1); + if (value < mini) or (value > maxi) then begin + Result := 'Invalid ' + name + ' value: "' + p + '"'; + end else Result := ''; + value := value * cPointsToInches; + end; + function URLFromURLFile(const fileName : String) : String; var ini : TIniFile; @@ -163,15 +184,15 @@ function ParseCommandLineParameters : TSnapshotParameters; Result.JPEGQuality := 90; Result.PNGCompressionLevel := 7; - Result.PDFOptions.page_width := 210000; - Result.PDFOptions.page_height := 297000; + Result.PDFOptions.paper_width := 210000 * cMicronsToInches; + Result.PDFOptions.paper_height := 297000 * cMicronsToInches; Result.PDFOptions.margin_type := PDF_PRINT_MARGIN_CUSTOM; - Result.PDFOptions.margin_top := 20; - Result.PDFOptions.margin_left := 20; - Result.PDFOptions.margin_right := 20; - Result.PDFOptions.margin_bottom := 20; + Result.PDFOptions.margin_top := 20 * cPointsToInches; + Result.PDFOptions.margin_left := 20 * cPointsToInches; + Result.PDFOptions.margin_right := 20 * cPointsToInches; + Result.PDFOptions.margin_bottom := 20 * cPointsToInches; Result.PDFOptions.landscape := 0; - Result.PDFOptions.backgrounds_enabled := 0; + Result.PDFOptions.print_background := 0; if ParamCount < 2 then begin Result.ErrorText := cHelp; @@ -260,22 +281,22 @@ function ParseCommandLineParameters : TSnapshotParameters; else if p <> '0' then Result.ErrorText := 'Unsupported option "' + p + '" for no-sandbox'; end else if lastP = '-pdf-page-width' then begin - Result.ErrorText := TryParseIntegerParameter('PDF-page-width', p, Result.PDFOptions.page_width, 10000, 10000000); + Result.ErrorText := TryParseFloatMicronsToInchesParameter('PDF-page-width', p, Result.PDFOptions.paper_width, 10000, 10000000); end else if lastP = '-pdf-page-height' then begin - Result.ErrorText := TryParseIntegerParameter('PDF-page-height', p, Result.PDFOptions.page_height, 10000, 10000000); + Result.ErrorText := TryParseFloatMicronsToInchesParameter('PDF-page-height', p, Result.PDFOptions.paper_height, 10000, 10000000); end else if lastP = '-pdf-margins' then begin - Result.ErrorText := TryParseIntegerParameter('PDF-margins', p, Result.PDFOptions.margin_top, 0, 10000); + Result.ErrorText := TryParseFloatPointsToInchesParameter('PDF-margins', p, Result.PDFOptions.margin_top, 0, 10000); Result.PDFOptions.margin_left := Result.PDFOptions.margin_top; Result.PDFOptions.margin_right := Result.PDFOptions.margin_top; Result.PDFOptions.margin_bottom := Result.PDFOptions.margin_top; end else if lastP = '-pdf-margin-top' then begin - Result.ErrorText := TryParseIntegerParameter('PDF-margin-top', p, Result.PDFOptions.margin_top, 0, 10000); + Result.ErrorText := TryParseFloatPointsToInchesParameter('PDF-margin-top', p, Result.PDFOptions.margin_top, 0, 10000); end else if lastP = '-pdf-margin-left' then begin - Result.ErrorText := TryParseIntegerParameter('PDF-margin-left', p, Result.PDFOptions.margin_left, 0, 10000); + Result.ErrorText := TryParseFloatPointsToInchesParameter('PDF-margin-left', p, Result.PDFOptions.margin_left, 0, 10000); end else if lastP = '-pdf-margin-right' then begin - Result.ErrorText := TryParseIntegerParameter('PDF-margin-right', p, Result.PDFOptions.margin_right, 0, 10000); + Result.ErrorText := TryParseFloatPointsToInchesParameter('PDF-margin-right', p, Result.PDFOptions.margin_right, 0, 10000); end else if lastP = '-pdf-margin-bottom' then begin - Result.ErrorText := TryParseIntegerParameter('PDF-margin-bottom', p, Result.PDFOptions.margin_bottom, 0, 10000); + Result.ErrorText := TryParseFloatPointsToInchesParameter('PDF-margin-bottom', p, Result.PDFOptions.margin_bottom, 0, 10000); end else if lastP = '-pdf-landscape' then begin Result.ErrorText := TryParseIntegerParameter('PDF-landscape', p, Result.PDFOptions.landscape, 0, 1); end else if lastP = '-pdf-title' then begin @@ -283,7 +304,7 @@ function ParseCommandLineParameters : TSnapshotParameters; end else if lastP = '-pdf-url' then begin Result.PDFURL := p; // undocumented, does not seem to work end else if lastP = '-pdf-backgrounds' then begin - Result.ErrorText := TryParseIntegerParameter('PDF-backgrounds', p, Result.PDFOptions.backgrounds_enabled, 0, 1); + Result.ErrorText := TryParseIntegerParameter('PDF-backgrounds', p, Result.PDFOptions.print_background, 0, 1); // property scale_factor : integer read Fscale_factor write Fscale_factor default 0; // property header_footer_enabled : boolean read Fheader_footer_enabled write Fheader_footer_enabled default False; // property selection_only : boolean read Fselection_only write Fselection_only default False; diff --git a/uEncapsulatedBrowser.pas b/uEncapsulatedBrowser.pas index 611c7ac..ab9f281 100644 --- a/uEncapsulatedBrowser.pas +++ b/uEncapsulatedBrowser.pas @@ -115,7 +115,6 @@ function CreateGlobalCEFApp(const parameters : TSnapshotParameters; const chromi begin GlobalCEFApp := TCefApplication.Create; GlobalCEFApp.WindowlessRenderingEnabled := True; - GlobalCEFApp.EnableHighDPISupport := True; GlobalCEFApp.ShowMessageDlg := False; // This demo shouldn't show any window, just console messages. GlobalCEFApp.BlinkSettings := 'hideScrollbars=true' // This setting removes all scrollbars to capture a cleaner snapshot @@ -149,6 +148,8 @@ function CreateGlobalCEFApp(const parameters : TSnapshotParameters; const chromi GlobalCEFApp.DeleteCookies := True; GlobalCEFApp.PersistSessionCookies := False; GlobalCEFApp.PersistUserPreferences := False; + GlobalCEFApp.FastUnload := True; + GlobalCEFApp.ReRaiseExceptions := False; Result := GlobalCEFApp.StartMainProcess; end;