Using Print TO PDF file in TChromium (Chromium Embedded)? - delphi

In Delphi XE7/XE8 with TChromium (DCEF3), I need to programmatically print (i.e. save) the current web page to a PDF document file (optionally without user interaction) to a predefined local path. Currently I can do this only indirectly by using a custom PDF printer driver and opening the printer dialog programmatically:
procedure TMainForm.btnPrintToPDF(Sender: TObject);
begin
// open the printer dialog:
crm.Browser.Host.Print;
end;
However, this has two disadvantages:
I cannot assume that the end user has a PDF printer driver installed
The end user has to select the file path in a file dialog, while the file path should be predefined.
But Chrome has a built-in PDF printer driver and print preview which is displayed with the keyboard shortcut CTRL+P. However, when I press CTRL+P in the guiclient TChromium demo application then nothing happens, no print preview like in Chrome is displayed.
So how can I call the PDF print preview in TChromium, possibly with a preset output path (without showing the file dialog)?

Related

How to disable print dialog in Chromium?

There is web page, that has the "Print" button. I load it using DCEF3. If user clicks the button, the Printer selection dialog is shown. I want to disable printing once and for all.
I have been trying to pass command line parameters using the example.
So, I tried the following:
--disable-print-preview
--kiosk
--kiosk-printing
But none of them did the trick. Am I missing something?
CEF3 doesn't support "silent" printing, that is, printing without a printer selection dialog.
All you can do is :
Print to a temporal PDF file and then print the PDF file.
Take a snapshot from the browser and print the bitmap.
Modify the CEF3 libraries to hide the printer selection dialog.
These functions are much easier to use with CEF4Delphi or OldCEF4Delphi. To print in a PDF file all you have to do is call TChromium.PrintToPDF and to take a snapshot you need to call TChromium.TakeSnapshot
Not all the Chromium flags or command line switches are supported by CEF3. --kiosk and --kiosk-printing are not supported as you can see here.
You may even have to modify the JavaScript code in that web page to replace the "print" button function with a custom JavaScript extension registered with CEF3. That extension would send a message to the main browser process to print using your custom function.

How to run .swf file in any pc? without any movie player

I hv a done a project in FLASH for a client. I hv used ActionScript 3 to hide mouse and used full screen code in FRAME 1 in flash file. But the client is saying he is not getting the full screen and Mouse hide after opening the .SWF file. But It is running well in my PC. My code is given below.
(1) Pls any one provide some guide in this situation.
(2) How the client can open the .swf file in his pc.
In some PC it does not open (unknown file format)?
Any plugin is required to easily run .SWF file?
/* Used in Action on first frame */
stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
stage.scaleMode = StageScaleMode.SHOW_ALL;
Mouse.hide();
For ActionScript, you can make your swf on fullscreen mode using fscommand() :
fscommand('fullscreen', 'true');
fscommand('allowscale', 'false');
Mouse.hide()
And then, you can export your swf as a projector ( an .exe file, including the swf and Flash Player, which your final user can open in any windows machine ) which will be opened in fullscreen mode automatically.
From Flash IDE, you can make a projector by going to menu File > Publish Settings ... > Publish - Other Formats > Win Projector and then type the name of your exe file as Output file and press the publish button to save your exe in same dir as your swf.
Then you have just to distribute the projector to your final users.
Hope that can help.
In latest version of Adobe Flash Professional CC, the Create Prejector/ Export as Projector can be done by installing "Export as Projector" Add-on (it is free)

cxgrid custom menuitem (open with) for Image field

In cxGrid i have a column which is "Image" type.(properties=Image,GraphicClassName=TJpegImage).
To the PopUpMenuLayout - MenuItems I have added a CustomMenuItem called "Open With...".
How can I implement this custom menu item so that it opens my underlying image with Paint (windows Paint)? Or at least trigger the "Open with.." windows dialog.
If you have your image stored in a database then you will first have to save it into image file on your computer.
Then you can then simply use ShellExecute for opening this image with default image viewing/editing program. ShellExecute works basically the same as if user would have double-clicked on your file. The problem is that usually doublec-licking on image file opens a preview of it so if you need to edit that image using of ShellExecute might not be the best way.
Now in order to be sure that the image is opened for editing rathen than just in preview you would have to read windows registry to get information about which program is used for viewing and editing of that specific image format and then use CreateProcess API cal instead.
You could also make sure that image is opened with specific program by starting that program using CreateProcess API call and passing image location as startup parameter (most image editing programs treat first parameter as file to open upon startup

How to read PDF document in windows phone 7?

When I click on button need to read the PDF file in windows phone 7, I am saving the PDF file in a folder and given the specified path in Database.
How can I read the PDF document on a windows phone 7?
There are 3 ways to open PDF file on Windows Phone:
Use "native" PDF viewer - Adobe Reader
To do that, you need a location URI of your PDF file, and then you
can either use the HyperlinkButton
<HyperlinkButton Content="Click here to open PDF"
NavigateUri="URI of your PDF" TargetName="_blank" Margin="10,60,0,0"/>
or you could use the WebBrowser task to browse to the PDF which will
invoke the PDF viewer:
WebBrowserTask browser = new WebBrowserTask();
browser.URL = "URI of your PDF";
browser.Show();
Use ComponentOne control for viewing PDFs
http://www.componentone.com/SuperProducts/PdfViewerPhone/
This will cost you some money, but should work OK.
Write your own control for rendering PDFs :)))

Using PDFSharp to print: how can I suppress Adobe window?

I have a simple C# utility that invokes PDFSharp to send a PDF file to a printer. However, it seems to behave inconsistently on a Windows 7 machine. Here's the code
PdfFilePrinter.AdobeReaderPath = "C:\\Program Files\\Adobe\\Reader 10.0\\Reader\\AcroRd32.exe";
PdfFilePrinter printer = new PdfFilePrinter(fileToPrint, printerName);
try
{
printer.Print();
When testing I launch the utility from the command line several times in a row processing a bunch of PDF files one file at a time. During some of these runs, a small Adobe window pops up. I don't have a link to what it looks like but it's a window with standard Adobe Reader X menus, a "Open a recent file" list on bottom left and "Acrobat.com services" on bottom right. Unless I manually close this window, printer.Print(); will never complete, which is a problem since I need to batch process hundreds of files at a time.
When this happens seems to be random. Sometimes it happens when the 1st test file is being processed and sometimes it's the 5th or the 7th.
How can I either ensure that this window does not appear or suppress it automatically if it does?
Any chance your printer supports PDF natively? If so, you could just send it directly to the printer either via LPR/RAW 9100 or through a Windows print queue: How to send raw data to a printer

Resources