Headless Chrome: save page to pdf |
|||||||||||
Issue descriptionAdd option to save webpages as pdf files.
,
May 4 2016
,
Jun 6 2016
,
Aug 1 2016
Hello. What's needed to support saving the page to PDF? Is it a matter of dev-tools adding support for it in the backend? Is there an ETA?
,
Aug 2 2016
this would be a good thing, since I like in future to use Headless Chrome as a substitute for wkhtmltopdf to save page as PDF. Would be good if Headless Chrome can also control by API the other aspects of rendering, as margins, CSS media type. anything to insert the header and footer in the PDF would be great. are any plan to support this in the future? (or at least not implement the things so that it is difficult to add this in the future)
,
Aug 2 2016
In terms of graphical output we're currently working on more flexible screenshots ( bug 625577 ). I suspect we'll look at PDFs once screenshots are resolved.
,
Aug 9 2016
For a certain use cases, it would also be really nice to have an interface that either returned (or called back with) a SkCanvas an or SKP bytestream. Basically the opposite of #5. Make it easy to perform transformations on the canvas after it is rendered, but before it is passed to Skia's PDF backend (or other backends). Scaling / clipping / augmentation (headers/footers), whatever, are isolated and done post-render.
,
Aug 22 2016
,
Aug 22 2016
+halcanary since there is mentioning of SKPs.
,
Aug 23 2016
therealkenc@, Take a look at https://codereview.chromium.org/2265483002.
,
Nov 30 2016
I think our current idea for printing support in headless would be to pretty much expose the options of the browser's print (to-pdf) dialog through a DevTools command. Looks like the relevant code is currently quite tightly coupled with the printing preview, though, and will undergo architectural changes to support OOPIF soon (see crbug.com/455764 ).
,
Dec 5 2016
,
Jan 19 2017
,
Feb 22 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/f3b6d48d62cd94949132a97e03155dfd7a9cdf86 commit f3b6d48d62cd94949132a97e03155dfd7a9cdf86 Author: jzfeng <jzfeng@chromium.org> Date: Wed Feb 22 09:10:48 2017 DevTools: allow embedder handling async remote debugger commands. This feature will be used by print to pdf command. BUG= 603559 Review-Url: https://codereview.chromium.org/2708563002 Cr-Commit-Position: refs/heads/master@{#451947} [modify] https://crrev.com/f3b6d48d62cd94949132a97e03155dfd7a9cdf86/content/browser/devtools/devtools_session.cc [modify] https://crrev.com/f3b6d48d62cd94949132a97e03155dfd7a9cdf86/content/browser/devtools/devtools_session.h [modify] https://crrev.com/f3b6d48d62cd94949132a97e03155dfd7a9cdf86/content/browser/devtools/protocol/page_handler.cc [modify] https://crrev.com/f3b6d48d62cd94949132a97e03155dfd7a9cdf86/content/browser/devtools/protocol/page_handler.h [modify] https://crrev.com/f3b6d48d62cd94949132a97e03155dfd7a9cdf86/content/browser/devtools/protocol_config.json [modify] https://crrev.com/f3b6d48d62cd94949132a97e03155dfd7a9cdf86/content/public/browser/devtools_manager_delegate.cc [modify] https://crrev.com/f3b6d48d62cd94949132a97e03155dfd7a9cdf86/content/public/browser/devtools_manager_delegate.h [modify] https://crrev.com/f3b6d48d62cd94949132a97e03155dfd7a9cdf86/third_party/WebKit/Source/core/inspector/browser_protocol.json [modify] https://crrev.com/f3b6d48d62cd94949132a97e03155dfd7a9cdf86/third_party/WebKit/Source/core/inspector/inspector_protocol_config.json
,
Apr 8 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/0cbec8b353f24515cc77a67ee95addc4f7a714ab commit 0cbec8b353f24515cc77a67ee95addc4f7a714ab Author: jzfeng <jzfeng@chromium.org> Date: Sat Apr 08 01:59:02 2017 Let users to print a webpage into pdf through PrintToPDF devtools command under headless chrome. This patch includes: 1) adding a new print manager, i.e., HeadlessPrintManager to handle all the printing related IPCs for headless. 2) plumbing through the pdf data from HeadlessPrintManager to HeadlessDevToolsManagerDelegate to handle the PrintToPDF command. 3) adding a new option to PrintWebViewHelper on Mac to return all the printed pages in the first PrintHostMsg_DidPrintPage message as a single file. This makes it conform to Linux and Windows, which simplify the logic in HeadlessPrintManager. This patch guarantees that HeadlessPrintManager is the only IPC entry point. In the future, if there are requirements to support the same devtools command in regular chrome, we may consider a framework to ensure multiple print managers to work properly under a content embedder. BUG= 603559 Review-Url: https://codereview.chromium.org/2780433002 Cr-Commit-Position: refs/heads/master@{#463105} [modify] https://crrev.com/0cbec8b353f24515cc77a67ee95addc4f7a714ab/build/args/headless.gn [modify] https://crrev.com/0cbec8b353f24515cc77a67ee95addc4f7a714ab/components/printing/renderer/print_web_view_helper.cc [modify] https://crrev.com/0cbec8b353f24515cc77a67ee95addc4f7a714ab/components/printing/renderer/print_web_view_helper.h [modify] https://crrev.com/0cbec8b353f24515cc77a67ee95addc4f7a714ab/components/printing/renderer/print_web_view_helper_mac.mm [modify] https://crrev.com/0cbec8b353f24515cc77a67ee95addc4f7a714ab/content/public/browser/devtools_manager_delegate.cc [modify] https://crrev.com/0cbec8b353f24515cc77a67ee95addc4f7a714ab/content/public/browser/devtools_manager_delegate.h [modify] https://crrev.com/0cbec8b353f24515cc77a67ee95addc4f7a714ab/headless/BUILD.gn [modify] https://crrev.com/0cbec8b353f24515cc77a67ee95addc4f7a714ab/headless/app/headless_shell.cc [modify] https://crrev.com/0cbec8b353f24515cc77a67ee95addc4f7a714ab/headless/app/headless_shell.h [modify] https://crrev.com/0cbec8b353f24515cc77a67ee95addc4f7a714ab/headless/app/headless_shell_switches.cc [modify] https://crrev.com/0cbec8b353f24515cc77a67ee95addc4f7a714ab/headless/app/headless_shell_switches.h [modify] https://crrev.com/0cbec8b353f24515cc77a67ee95addc4f7a714ab/headless/lib/browser/DEPS [modify] https://crrev.com/0cbec8b353f24515cc77a67ee95addc4f7a714ab/headless/lib/browser/headless_devtools_manager_delegate.cc [modify] https://crrev.com/0cbec8b353f24515cc77a67ee95addc4f7a714ab/headless/lib/browser/headless_devtools_manager_delegate.h [add] https://crrev.com/0cbec8b353f24515cc77a67ee95addc4f7a714ab/headless/lib/browser/headless_print_manager.cc [add] https://crrev.com/0cbec8b353f24515cc77a67ee95addc4f7a714ab/headless/lib/browser/headless_print_manager.h [modify] https://crrev.com/0cbec8b353f24515cc77a67ee95addc4f7a714ab/headless/lib/browser/headless_web_contents_impl.cc [modify] https://crrev.com/0cbec8b353f24515cc77a67ee95addc4f7a714ab/headless/lib/headless_content_main_delegate.cc [modify] https://crrev.com/0cbec8b353f24515cc77a67ee95addc4f7a714ab/headless/lib/headless_content_main_delegate.h [add] https://crrev.com/0cbec8b353f24515cc77a67ee95addc4f7a714ab/headless/lib/renderer/DEPS [add] https://crrev.com/0cbec8b353f24515cc77a67ee95addc4f7a714ab/headless/lib/renderer/headless_content_renderer_client.cc [add] https://crrev.com/0cbec8b353f24515cc77a67ee95addc4f7a714ab/headless/lib/renderer/headless_content_renderer_client.h [add] https://crrev.com/0cbec8b353f24515cc77a67ee95addc4f7a714ab/headless/lib/renderer/headless_print_web_view_helper_delegate.cc [add] https://crrev.com/0cbec8b353f24515cc77a67ee95addc4f7a714ab/headless/lib/renderer/headless_print_web_view_helper_delegate.h
,
Apr 8 2017
Hi. The commit in the previous comment (c#16) is causing a compile error for me:
[14185/18748] ccache ../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/llvm-build/Release+Asserts/bin/clang++ -MMD -MF obj/headless/headless_lib/headless_print_manager.o.d -DV8_DEPRECATION_WARNINGS -DUSE_AURA=1 -DUSE_PANGO=1 -DUSE_CAIRO=1 -DUSE_GLIB=1 -DUSE_NSS_CERTS=1 -DUSE_X11=1 -DDISABLE_NACL -DFULL_SAFE_BROWSING -DSAFE_BROWSING_CSD -DSAFE_BROWSING_DB_LOCAL -DCHROMIUM_BUILD -DENABLE_MEDIA_ROUTER=1 -DFIELDTRIAL_TESTING_ENABLED -DCR_CLANG_REVISION=\"298539-1\" -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -DHEADLESS_IMPLEMENTATION -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32 -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_26 -DGL_GLEXT_PROTOTYPES -DUSE_GLX -DUSE_EGL -DGOOGLE_PROTOBUF_NO_RTTI -DGOOGLE_PROTOBUF_NO_STATIC_INITIALIZER -DHAVE_PTHREAD -DV8_USE_EXTERNAL_STARTUP_DATA -DU_USING_ICU_NAMESPACE=0 -DU_ENABLE_DYLOAD=0 -DU_STATIC_IMPLEMENTATION -DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -DENABLE_IPC_FUZZER -DSK_IGNORE_LINEONLY_AA_CONVEX_PATH_OPTS -DSK_SUPPORT_GPU=1 -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src -Igen -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/khronos -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/gpu -Igen/shim_headers/ffmpeg_shim -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/breakpad/src -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/protobuf/src -Igen/protoc_out -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/protobuf/src -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/boringssl/src/include -I/usr/include/nss -I/usr/include/nspr -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/ced/src -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/icu/source/common -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/icu/source/i18n -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/libwebm/source -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/skia/config -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/skia/ext -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/include/c -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/include/config -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/include/core -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/include/effects -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/include/images -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/include/lazy -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/include/pathops -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/include/pdf -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/include/pipe -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/include/ports -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/include/utils -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/include/gpu -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/src/gpu -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/src/sksl -Igen -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/WebKit -Igen/third_party/WebKit -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/v8/include -Igen/v8/include -fno-strict-aliasing -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -funwind-tables -fPIC -pipe -D_FORTIFY_SOURCE=2 -fomit-frame-pointer -fno-omit-frame-pointer -fcolor-diagnostics -m64 -march=x86-64 -pthread -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-covered-switch-default -Wno-unneeded-internal-declaration -Wno-inconsistent-missing-override -Wno-undefined-var-template -Wno-nonportable-include-path -Wno-address-of-packed-member -Wno-unused-lambda-capture -Wno-user-defined-warnings -Ofast -fno-fast-math -fno-ident -fdata-sections -ffunction-sections -fomit-frame-pointer -g1 -fvisibility=hidden -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Wno-header-guard -fvisibility-inlines-hidden -std=gnu++11 -fno-rtti -fno-exceptions -c ../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/headless/lib/browser/headless_print_manager.cc -o obj/headless/headless_lib/headless_print_manager.o
FAILED: obj/headless/headless_lib/headless_print_manager.o
ccache ../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/llvm-build/Release+Asserts/bin/clang++ -MMD -MF obj/headless/headless_lib/headless_print_manager.o.d -DV8_DEPRECATION_WARNINGS -DUSE_AURA=1 -DUSE_PANGO=1 -DUSE_CAIRO=1 -DUSE_GLIB=1 -DUSE_NSS_CERTS=1 -DUSE_X11=1 -DDISABLE_NACL -DFULL_SAFE_BROWSING -DSAFE_BROWSING_CSD -DSAFE_BROWSING_DB_LOCAL -DCHROMIUM_BUILD -DENABLE_MEDIA_ROUTER=1 -DFIELDTRIAL_TESTING_ENABLED -DCR_CLANG_REVISION=\"298539-1\" -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -DHEADLESS_IMPLEMENTATION -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32 -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_26 -DGL_GLEXT_PROTOTYPES -DUSE_GLX -DUSE_EGL -DGOOGLE_PROTOBUF_NO_RTTI -DGOOGLE_PROTOBUF_NO_STATIC_INITIALIZER -DHAVE_PTHREAD -DV8_USE_EXTERNAL_STARTUP_DATA -DU_USING_ICU_NAMESPACE=0 -DU_ENABLE_DYLOAD=0 -DU_STATIC_IMPLEMENTATION -DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -DENABLE_IPC_FUZZER -DSK_IGNORE_LINEONLY_AA_CONVEX_PATH_OPTS -DSK_SUPPORT_GPU=1 -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src -Igen -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/khronos -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/gpu -Igen/shim_headers/ffmpeg_shim -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/breakpad/src -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/protobuf/src -Igen/protoc_out -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/protobuf/src -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/boringssl/src/include -I/usr/include/nss -I/usr/include/nspr -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/ced/src -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/icu/source/common -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/icu/source/i18n -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/libwebm/source -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/skia/config -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/skia/ext -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/include/c -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/include/config -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/include/core -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/include/effects -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/include/images -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/include/lazy -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/include/pathops -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/include/pdf -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/include/pipe -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/include/ports -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/include/utils -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/include/gpu -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/src/gpu -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/src/sksl -Igen -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/WebKit -Igen/third_party/WebKit -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/v8/include -Igen/v8/include -fno-strict-aliasing -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -funwind-tables -fPIC -pipe -D_FORTIFY_SOURCE=2 -fomit-frame-pointer -fno-omit-frame-pointer -fcolor-diagnostics -m64 -march=x86-64 -pthread -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-covered-switch-default -Wno-unneeded-internal-declaration -Wno-inconsistent-missing-override -Wno-undefined-var-template -Wno-nonportable-include-path -Wno-address-of-packed-member -Wno-unused-lambda-capture -Wno-user-defined-warnings -Ofast -fno-fast-math -fno-ident -fdata-sections -ffunction-sections -fomit-frame-pointer -g1 -fvisibility=hidden -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Wno-header-guard -fvisibility-inlines-hidden -std=gnu++11 -fno-rtti -fno-exceptions -c ../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/headless/lib/browser/headless_print_manager.cc -o obj/headless/headless_lib/headless_print_manager.o
../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/headless/lib/browser/headless_print_manager.cc:113:17: error: unknown type name 'PrintMsg_PrintPages'; did you mean 'PrintMsg_Print_Params'?
rfh->Send(new PrintMsg_PrintPages(rfh->GetRoutingID()));
^~~~~~~~~~~~~~~~~~~
PrintMsg_Print_Params
../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/components/printing/common/print_messages.h:35:8: note: 'PrintMsg_Print_Params' declared here
struct PrintMsg_Print_Params {
^
../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/headless/lib/browser/headless_print_manager.cc:113:17: error: no matching constructor for initialization of 'PrintMsg_Print_Params'
rfh->Send(new PrintMsg_PrintPages(rfh->GetRoutingID()));
^ ~~~~~~~~~~~~~~~~~~~
../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/components/printing/common/print_messages.h:37:3: note: candidate constructor not viable: no known conversion from 'int' to 'const PrintMsg_Print_Params' for 1st argument
PrintMsg_Print_Params(const PrintMsg_Print_Params& other);
^
../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/components/printing/common/print_messages.h:36:3: note: candidate constructor not viable: requires 0 arguments, but 1 was provided
PrintMsg_Print_Params();
^
2 errors generated.
,
Apr 10 2017
The problem is that enable_basic_printing is set to false in your args.gn. I will fix that soon.
,
Apr 10 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/143099e30f56d3d41c6e1fb49230586472751aac commit 143099e30f56d3d41c6e1fb49230586472751aac Author: jzfeng <jzfeng@chromium.org> Date: Mon Apr 10 20:18:09 2017 make headless lib complie when enable_basic_printing is set to false There is a bug that headless lib doesn't complie when users set enable_basic_printing to false in their args.gn file. The patch ensure that the printing support is only avaliable when enable_basic_printing is true. When it is false, the PrintToPDF devtools command would return an error instead. BUG= 603559 Review-Url: https://codereview.chromium.org/2808653002 Cr-Commit-Position: refs/heads/master@{#463381} [modify] https://crrev.com/143099e30f56d3d41c6e1fb49230586472751aac/headless/BUILD.gn [modify] https://crrev.com/143099e30f56d3d41c6e1fb49230586472751aac/headless/lib/browser/headless_devtools_manager_delegate.cc [modify] https://crrev.com/143099e30f56d3d41c6e1fb49230586472751aac/headless/lib/browser/headless_web_contents_impl.cc [modify] https://crrev.com/143099e30f56d3d41c6e1fb49230586472751aac/headless/lib/renderer/DEPS [modify] https://crrev.com/143099e30f56d3d41c6e1fb49230586472751aac/headless/lib/renderer/headless_content_renderer_client.cc
,
Apr 11 2017
Hi, I tried out the pdf generation in headless chrome and it is pretty awesome. But It doesn't seem to honor the --window-size or the print media size, Also there is no options for printing the pdf with header and footer, background images, paper size and so on in devtools protocols but are present in the actual chromes print preview , Is this something planned or is there any workaround which will work now.
,
Apr 11 2017
Thanks for using this feature. Yes, it is in my plan. I will add the printing settings as parameters of the devtools command.
,
Apr 20 2017
Hi, I would just like to add that I really appreciate your work here and this is the only headless browser PDF generation system that I am aware of (and we've done plenty of looking) that actually works! Plus 1 to the printing settings and parameters features when you are able to add them. Thanks!
,
Apr 20 2017
There's also https://www.w3.org/TR/css3-page/. Not sure how much of it is supported in Chrome though.
,
Apr 20 2017
This is awesome!! We use phantomjs to generate PDFs currently. This will be a huge upgrade for us, eliminating ugly bugs and increasing rendering speed. Our feature request: It would be amazing if we had the ability to set a DPI to keep our rendering consistent across platforms and with our legacy phantomjs documents.
,
Apr 21 2017
Good to hear the interests! The customized print setting is still in progress.
,
Apr 21 2017
hey, were can i find an example or documentation how to print a page as pdf? i would like to test this feature :)
,
Apr 24 2017
The command is chrome --headless --print-to-pdf="path/to/pdf" https://your_url or chrome --headless --remote-debugging-port=9222 https://your_url and then send the Page.printToPDF devtools command to get the pdf base64 data.
,
Apr 24 2017
Thanks for the work on this.
To add another use case:
- Phantomjs supports printing to pdf. There are phantomjs - selenium wrappers that achieve this.
- An extension (or an api available in headless) that somewhat reads: window.printToPdf('/path/to/pdf') or var bytes = window.printToPdf(); could be useful in selenium context.
,
Apr 27 2017
Hi all. Saving page to PDF using headless chrome is awesome and it will definitly change the way we generate PDF here.
I am currently running some tests, and I cannot seem to find a way to define the output page format.
It seems the "@page { size: A4; }" is understood by headless chrome but the generated PDF isn't a A4 format. Is there an option I am missing?
Here is the command I am using:
google --headless --disable-gpu --print-to-pdf=test.pdf http://localhost:8081/test1.html
Thanks for your help
,
Apr 27 2017
We're working on exposing some more configuration parameters, including the page size :) Pending patch by jzfeng@ here: https://codereview.chromium.org/2829973002/
,
May 2 2017
We're using PhantomJS to render flyers for our clients. I'd very much like to use Chrome --headless instead, but we rely on being able to specify orientation, page height/width. These PDFs are also being sent to print shops so 300dpi photos are a must.
,
May 2 2017
I'm running the tip of of tree with the chrome-headless image and requesting the prd conversion using the node.js chrome-remote-interface module. The data I receive back renders blank when viewed in a browser. Also, whatever, file I attempt to convert, the data received in the response is always the same, identical string. Is this a known issue? Many thanks, otherwise, this is ace!
,
May 2 2017
#33: This sounds like a new issue. Feel free to file another bug with reproduction steps :)
,
May 2 2017
Regarding #32, it looks like Chrome --headless embeds your images as-is in the PDF, so getting the 300dpi resolution you require should only be a matter of using appropriately sized images.
,
May 2 2017
#33 may also be caused due to the current tab not being active. Here is an issue and reproduction steps if anyone wants to create a bug. https://github.com/cyrus-and/chrome-remote-interface/issues/92
,
May 2 2017
,
May 9 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/3d83dad2db679c3924ffe74599cfd48a03211778 commit 3d83dad2db679c3924ffe74599cfd48a03211778 Author: jzfeng <jzfeng@chromium.org> Date: Tue May 09 03:44:18 2017 add customized printing setting for headless 1) Add parameters to printToPDF command, which let the user to specify printing settings like paper size, margin size, etc. 2) PrintWebViewHelper::PrintPageInternal and PrintWebViewHelper::RenderPage feed print_preview_context_.total_page_count() to PrintHeaderAndFooter. However, HeadlessPrintManager issues PrintMsg_PrintPages IPC message, which leaves print_preview_context_ uninitialized. To solve the problem, add page_count as an arg to these two methods. 3) Added unit test and browser test for print to pdf. BUG= 603559 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation Review-Url: https://codereview.chromium.org/2829973002 Cr-Commit-Position: refs/heads/master@{#470159} [modify] https://crrev.com/3d83dad2db679c3924ffe74599cfd48a03211778/chrome/browser/resources/print_preview/settings/scaling_settings.html [modify] https://crrev.com/3d83dad2db679c3924ffe74599cfd48a03211778/components/printing/renderer/print_web_view_helper.cc [modify] https://crrev.com/3d83dad2db679c3924ffe74599cfd48a03211778/components/printing/renderer/print_web_view_helper.h [modify] https://crrev.com/3d83dad2db679c3924ffe74599cfd48a03211778/components/printing/renderer/print_web_view_helper_linux.cc [modify] https://crrev.com/3d83dad2db679c3924ffe74599cfd48a03211778/components/printing/renderer/print_web_view_helper_mac.mm [modify] https://crrev.com/3d83dad2db679c3924ffe74599cfd48a03211778/components/printing/renderer/print_web_view_helper_pdf_win.cc [modify] https://crrev.com/3d83dad2db679c3924ffe74599cfd48a03211778/components/resources/BUILD.gn [modify] https://crrev.com/3d83dad2db679c3924ffe74599cfd48a03211778/components/resources/printing_resources.grdp [modify] https://crrev.com/3d83dad2db679c3924ffe74599cfd48a03211778/content/browser/devtools/protocol/page_handler.cc [modify] https://crrev.com/3d83dad2db679c3924ffe74599cfd48a03211778/content/browser/devtools/protocol/page_handler.h [modify] https://crrev.com/3d83dad2db679c3924ffe74599cfd48a03211778/headless/BUILD.gn [modify] https://crrev.com/3d83dad2db679c3924ffe74599cfd48a03211778/headless/app/headless_shell.cc [modify] https://crrev.com/3d83dad2db679c3924ffe74599cfd48a03211778/headless/lib/DEPS [modify] https://crrev.com/3d83dad2db679c3924ffe74599cfd48a03211778/headless/lib/browser/headless_devtools_manager_delegate.cc [modify] https://crrev.com/3d83dad2db679c3924ffe74599cfd48a03211778/headless/lib/browser/headless_devtools_manager_delegate.h [modify] https://crrev.com/3d83dad2db679c3924ffe74599cfd48a03211778/headless/lib/browser/headless_print_manager.cc [modify] https://crrev.com/3d83dad2db679c3924ffe74599cfd48a03211778/headless/lib/browser/headless_print_manager.h [add] https://crrev.com/3d83dad2db679c3924ffe74599cfd48a03211778/headless/lib/browser/headless_printing_unittest.cc [modify] https://crrev.com/3d83dad2db679c3924ffe74599cfd48a03211778/headless/lib/headless_web_contents_browsertest.cc [modify] https://crrev.com/3d83dad2db679c3924ffe74599cfd48a03211778/headless/lib/renderer/headless_print_web_view_helper_delegate.cc [modify] https://crrev.com/3d83dad2db679c3924ffe74599cfd48a03211778/third_party/WebKit/Source/core/inspector/browser_protocol.json
,
May 9 2017
Is there any documentation about how to utilize the pdf print with the options as I would like to look into whether it is possible to replace wkhtmltopdf with Chrome headless. Are all the
,
May 9 2017
in addition to above: In which version those options will appear in chrome/chromium? It seems that many people are interested in using headless mode for pdf printing (including me)
,
May 9 2017
#39: The options should be pretty self-explanatory from descriptions in the devtools protocol: https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-printToPDF All you need to do is send the printToPDF command via devtools (using --headless and --remote-debugging-port=xxxx). We don't currently have a way to use --print-to-pdf with these options. As mentioned above, we also don't have a DPI setting, since this is not supported in the printing architecture. AFAIK all pixel-graphics are printed in as-is resolution, so no up/downscaling occurs.
,
May 9 2017
#40: They'll be available in dev builds shortly and should make it into M60 beta/stable builds provided we don't discover any major problems :)
,
May 9 2017
#42: awesome! can't wait to try it.
,
May 9 2017
Do you intend to provide a way for custom headers and footers?
,
May 9 2017
yeah it's pretty awesome, but adding those to -print-to-pdf switch is a must, at least for my kind of usage. Do you have any plans for this?
,
May 9 2017
#44: You might be able to use print CSS or table headers/footers to create custom repeating headers/footers. #45: Can you explain why you need to have support in command line switches / can't use the DevTools command? Switches such as --print-to-pdf or --screenshot are currently intended as example usages of the related DevTools commands, not to provide full support of all their options via the command line.
,
May 9 2017
#46 my usage is prepared to be as simple as possible, either directly through php's "system" method or .sh scripts. Using full DevTools require at least using node with chrome-remote-interface which adds unnecessary dependencies to the project.
,
May 9 2017
Re #46 Sorry we're not going to add more command line flags that duplicate DevTools functionality. You could write a small wrapper script (in any language with a WebSockets library) to wrangle the DevTools commands. They're just json blobs and are not complicated to work with.
,
May 9 2017
I agree with #47. Full support for command line switches enables PDF generation applications to decouple themselves from chrome-remote-interface and javascript. We would like to be able to invoke chrome's PDF generation as a process call with appropriate command line arguments. For example Java's ProcessBuilder[1] [1] https://docs.oracle.com/javase/7/docs/api/java/lang/ProcessBuilder.html
,
May 9 2017
#48 would it really be such trouble to add switch like: -print-options=landscape,displayHeaderFooter,printBackground,scale,paperWidth,paperHeight,marginTop,marginBottom,marginLeft,marginRight,pageRanges It's really not just "small wrapper script (in any language with a WebSockets library)" because you have to handle a lot of events during process instead of just invoking a command and wait for it's exit status.
,
May 9 2017
#50: Please consider the more general problem - We don't intend to provide all the flexibility that DevTools provides through command line options: There are various technical reasons why command line options cannot provide the same flexibility (e.g. the event-based nature of DevTools). Adding more options won't solve this general misfit. I think that we should be aiming for a more library-based approach for headless user environments (e.g. nodejs, python, java, ..). Such a library can implement a default, but more customizable, page load/life cycle that includes common functions such as rendering a pdf/screenshot. I think we could provide an example/reference library and application (say, for nodejs) as part of headless chromium. Filed https://crbug.com/719921 to track this discussion. It is likely that this will lead to deprecation (and eventual removal) of --headless mode command line flags such as --print-to-pdf or --screenshot.
,
May 9 2017
Will be implemented support to other metrics like 'px', 'mm', 'cm' or only 'inches' on page width/height?
,
May 9 2017
#52: We'll stick to inches as this is what the printing system uses internally. You should be able to convert from other units to inches (using a DPI of 72 where necessary).
,
May 9 2017
Should we consider so that DPI will be 72 as default correct?
,
May 9 2017
,
May 9 2017
Are there plans to support @page CSS at-rules, at least for page size / orientation and margins?
,
May 9 2017
re Comment 38, Commit 3d83dad2db679c3924ffe74599cfd48a03211778 deletes a bunch of #if BUILDFLAG(ENABLE_PRINT_PREVIEW) therefore compilation fails when enable_print_preview is false. Example: ccache ../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/llvm-build/Release+Asserts/bin/clang++ -MMD -MF obj/components/printing/renderer/renderer/print_web_view_helper.o.d -DV8_DEPRECATION_WARNINGS -DUSE_AURA=1 -DUSE_PANGO=1 -DUSE_CAIRO=1 -DUSE_GLIB=1 -DUSE_NSS_CERTS=1 -DUSE_X11=1 -DDISABLE_NACL -DFULL_SAFE_BROWSING -DSAFE_BROWSING_CSD -DSAFE_BROWSING_DB_LOCAL -DCHROMIUM_BUILD -DFIELDTRIAL_TESTING_ENABLED -DCR_CLANG_REVISION=\"300839-1\" -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32 -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_26 -DGL_GLEXT_PROTOTYPES -DUSE_GLX -DUSE_EGL -DV8_USE_EXTERNAL_STARTUP_DATA -DU_USING_ICU_NAMESPACE=0 -DU_ENABLE_DYLOAD=0 -DU_STATIC_IMPLEMENTATION -DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -DENABLE_IPC_FUZZER -DSK_IGNORE_LINEONLY_AA_CONVEX_PATH_OPTS -DSK_SUPPORT_GPU=1 -DGOOGLE_PROTOBUF_NO_RTTI -DGOOGLE_PROTOBUF_NO_STATIC_INITIALIZER -DHAVE_PTHREAD -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src -Igen -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/khronos -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/gpu -Igen/shim_headers/ffmpeg_shim -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/ced/src -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/icu/source/common -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/icu/source/i18n -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/libwebm/source -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/skia/config -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/skia/ext -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/include/c -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/include/config -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/include/core -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/include/effects -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/include/images -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/include/lazy -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/include/pathops -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/include/pdf -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/include/pipe -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/include/ports -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/include/utils -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/third_party/vulkan -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/include/gpu -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/src/gpu -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/skia/src/sksl -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/protobuf/src -Igen/protoc_out -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/protobuf/src -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/boringssl/src/include -I/usr/include/nss -I/usr/include/nspr -Igen -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/third_party/WebKit -Igen/third_party/WebKit -I../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/v8/include -Igen/v8/include -fno-strict-aliasing -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -funwind-tables -fPIC -pipe -D_FORTIFY_SOURCE=2 -fomit-frame-pointer -fno-omit-frame-pointer -fcolor-diagnostics -m64 -march=x86-64 -pthread -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-covered-switch-default -Wno-unneeded-internal-declaration -Wno-inconsistent-missing-override -Wno-undefined-var-template -Wno-nonportable-include-path -Wno-address-of-packed-member -Wno-unused-lambda-capture -Wno-user-defined-warnings -Ofast -fno-fast-math -fno-ident -fdata-sections -ffunction-sections -fomit-frame-pointer -g1 -fvisibility=hidden -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Wno-header-guard -fvisibility-inlines-hidden -std=gnu++11 -fno-rtti -fno-exceptions -c ../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/components/printing/renderer/print_web_view_helper.cc -o obj/components/printing/renderer/renderer/print_web_view_helper.o ../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/components/printing/renderer/print_web_view_helper.cc:592:11: error: use of undeclared identifier 'IDR_PRINT_PREVIEW_PAGE' IDR_PRINT_PREVIEW_PAGE))); ^ 1 error generated.
,
May 9 2017
Is it too late the change the units of `paperWidth` and `paperHeight` on `Page.printToPDF`? I feel like these should probably be in centimetres rather than inches. (I’d also like to see A4 be the default page size but that’s less of an issue.)
,
May 10 2017
#58: As mentioned above, user code can convert to inches. The units and defaults were chosen to reflect those used in the printing system.
,
May 10 2017
We are running a nodejs host using headless chrome documentation, and we also require custom header and footer html to apply to page.printToPDF DevTools Protocol as #44. It does not seem like it's possible ATM. Do you think it will be done in the near future?
,
May 12 2017
#56 #60: CSS / markup should be the way to go for custom headers/footers. I'm not sure how well @page at-rules are supported in chrome at the moment or what the plans are. Looks like https://crbug.com/320370 is related, maybe express your interest there (e.g. by starring it).
,
May 12 2017
I vote for this, it's the last feature missing from phantomjs. I could then use chromium as a reliable substitute to it. Thank you for increasing priority
,
May 15 2017
,
May 16 2017
#61: Desktop Chrome does support @page at-rules for size and margins, and will set the sheet dimensions according to the size property.
It appears that Headless Chrome does parse @page as well to some extent, but behaves differently than the desktop version: If you specify @page {size}, headless seems to change the dimensions of the page box (essentially, the print area), and not the sheet, which always remains US Letter sized. However, it does rotate the sheet if you specify {size: landscape}.
Is this different behaviour by design? I don't see any reason why it would be.
Being able to specify the sheet size in at-rules would help our workflow a great deal as it would allow us to inline the size info into the HTML document, and not need to pass it separately to the rendering process.
Looking forward, what would be awesome is support for named pages [1], so we could have different size pages in the same document.
[1] CSS Paged Media Module Level 3, 9.1. : https://www.w3.org/TR/css3-page/#page
,
May 16 2017
#64: @page should behave the same in both versions so I think what you're describing sounds like a bug.
,
May 18 2017
,
May 19 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/f2df047e7dae8daf0f04abf9681fee1f4fcee3d9 commit f2df047e7dae8daf0f04abf9681fee1f4fcee3d9 Author: jzfeng <jzfeng@chromium.org> Date: Fri May 19 03:20:39 2017 make chrome build without any printing support User complain that chrome doesn't build using their customized args.gn. See https://bugs.chromium.org/p/chromium/issues/detail?id=603559#c57. Their args.gn set enable_basic_printing, enable_print_preview and enable_service_discovery to false. This patch makes sure this flag setting can build successfully. BUG= 603559 Review-Url: https://codereview.chromium.org/2884123003 Cr-Commit-Position: refs/heads/master@{#473057} [modify] https://crrev.com/f2df047e7dae8daf0f04abf9681fee1f4fcee3d9/chrome/renderer/BUILD.gn [modify] https://crrev.com/f2df047e7dae8daf0f04abf9681fee1f4fcee3d9/headless/lib/browser/headless_devtools_manager_delegate.cc [modify] https://crrev.com/f2df047e7dae8daf0f04abf9681fee1f4fcee3d9/pdf/BUILD.gn
,
May 25 2017
,
May 26 2017
There has been a bit of talk regarding generating PDFs with PhantomJS. One popular way to do that is with https://www.npmjs.com/package/html-pdf. I'm working on a replacement for that, using headless Chrome: https://www.npmjs.com/package/html-pdf-chrome.
,
May 31 2017
Hello, I tried to use some of the new parameters for the --print-to-pdf option with Chromium 61.0.3117.0 but I cannot figure out how to make it work. Are they not yet included? And if they are, what I am doing wrong? This is the command I am trying (on version 61.0.3117.0): ./chrome --no-sandbox --headless --disable-gpu --print-to-pdf=test.pdf --displayHeaderFooter=false http://chromium.org Any help is appreciated! Thanks, Stefano.
,
May 31 2017
The print options are exposed via the DevTools API only (and not via command line flags), see comments #51 and prior.
,
May 31 2017
Ok, now it's much more clear - I read comment #51 before posting but I was not able to follow without a bit of context - thank you! Is there any example of how to use these new options for the headless mode via the DevTools API somewhere? Thanks, Stefano.
,
Jun 1 2017
There is a browser test that uses the C++ bindings [1], which reflect the DevTools API. See headless documentation [2] and blog post [3] for more info on using the DevTools API. [1] https://cs.chromium.org/chromium/src/headless/lib/headless_web_contents_browsertest.cc?l=195 [2] https://cs.chromium.org/chromium/src/headless/README.md [3] https://developers.google.com/web/updates/2017/04/headless-chrome
,
Jun 16 2017
Is it possible to adjust PDF metadata? (Title, author, application etc.)
,
Jun 16 2017
> Is it possible to adjust PDF metadata? (Title, author, application etc.) From the Skia point of view, this is implemented. It would need to be done here in Chrome: https://cs.chromium.org/chromium/src/printing/common/pdf_metafile_utils.cc?l=33
,
Jun 16 2017
pingping on the DPI issue. Is there a downstream issue for the print API to configure the DPI?
,
Jul 1 2017
I'm a bit confused. I see Page.printToPDF method, but is there a way to create a pdf from a specific iframe inside my page?
,
Jul 3 2017
re #77 could you not just navigate to the iframe and print that?
,
Jul 3 2017
#78: This iframe does not have a "src" attribute, because it is constructed at runtime by a WYSIWYG html editor I use, so I can't navigate to it. Nevetheless, I found a way to remove it just for the printing procedure :-)
,
Jul 12 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/e4a7e916ad983c8758dffc7dd6565c22eb13d62d commit e4a7e916ad983c8758dffc7dd6565c22eb13d62d Author: Eric Seckler <eseckler@chromium.org> Date: Wed Jul 12 10:21:45 2017 [headless] Allow print page ranges with range.to > page count. Bug: 603559 Change-Id: Ib9316295cee0226fe19c966e47b0c5a6a730db44 Reviewed-on: https://chromium-review.googlesource.com/567504 Commit-Queue: Eric Seckler <eseckler@chromium.org> Reviewed-by: Alex Clarke <alexclarke@chromium.org> Cr-Commit-Position: refs/heads/master@{#485914} [modify] https://crrev.com/e4a7e916ad983c8758dffc7dd6565c22eb13d62d/headless/lib/browser/headless_print_manager.cc [modify] https://crrev.com/e4a7e916ad983c8758dffc7dd6565c22eb13d62d/headless/lib/browser/headless_printing_unittest.cc
,
Jul 12 2017
FYI, for anyone looking for DPI support, I filed https://bugs.chromium.org/p/chromium/issues/detail?id=741049
,
Jul 19 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/782aaff5b06c8bc32730a11dc33a342b0b6463d5 commit 782aaff5b06c8bc32730a11dc33a342b0b6463d5 Author: Eric Seckler <eseckler@chromium.org> Date: Wed Jul 19 10:58:08 2017 [headless/devtools] Add option to ignore invalid pdf page ranges. Bug: 603559 Change-Id: Ibabd53ccd478a767fcad05273b4ab11ee378b831 Reviewed-on: https://chromium-review.googlesource.com/571809 Reviewed-by: Pavel Feldman <pfeldman@chromium.org> Reviewed-by: Alex Clarke <alexclarke@chromium.org> Commit-Queue: Eric Seckler <eseckler@chromium.org> Cr-Commit-Position: refs/heads/master@{#487821} [modify] https://crrev.com/782aaff5b06c8bc32730a11dc33a342b0b6463d5/content/browser/devtools/protocol/page_handler.cc [modify] https://crrev.com/782aaff5b06c8bc32730a11dc33a342b0b6463d5/content/browser/devtools/protocol/page_handler.h [modify] https://crrev.com/782aaff5b06c8bc32730a11dc33a342b0b6463d5/headless/lib/browser/headless_devtools_manager_delegate.cc [modify] https://crrev.com/782aaff5b06c8bc32730a11dc33a342b0b6463d5/headless/lib/browser/headless_devtools_manager_delegate.h [modify] https://crrev.com/782aaff5b06c8bc32730a11dc33a342b0b6463d5/headless/lib/browser/headless_print_manager.cc [modify] https://crrev.com/782aaff5b06c8bc32730a11dc33a342b0b6463d5/headless/lib/browser/headless_print_manager.h [modify] https://crrev.com/782aaff5b06c8bc32730a11dc33a342b0b6463d5/headless/lib/browser/headless_printing_unittest.cc [modify] https://crrev.com/782aaff5b06c8bc32730a11dc33a342b0b6463d5/headless/lib/browser/headless_web_contents_impl.cc [modify] https://crrev.com/782aaff5b06c8bc32730a11dc33a342b0b6463d5/third_party/WebKit/Source/core/inspector/browser_protocol.json
,
Aug 8 2017
I read the comments above and was wondering how I can disable the header/footer when using print-to-pdf. You guys are referring to the DevTools, but I really dont know how I should use them to disable the Header/Footer. Can you help me out there? thank you!
,
Aug 12 2017
is there any way of adding a custom header/footer? i.e. point it to an HTML file to use as a header on each page. similar to how wkhtmltopdf does it.
,
Aug 30 2017
An option to support printing a set of web-pages to a single PDF would be most useful (printing in the order of links provided). I presently do this with https://wkhtmltopdf.org but it does not receive frequent updates. A headless Chromium implementation would be a far better and more universal solution.
,
Feb 1 2018
Is there any plan to add in support for printing hyperlinks (which can be clicked in the PDFs)? I don't see that as an option here: https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-printToPDF I would very much like to see this option added.
,
Feb 2 2018
The the hyperlinks in the PDF should be always click-able.
,
Feb 2 2018
verified by running chrome --headless --print-to-pdf="some_path" https://github.com
,
Feb 2 2018
#89: I see. The page I was rendering was the problem. Good work!
,
Feb 6 2018
For people looking for command line switches, since there doesn't seem to be any good other solutions out there (https://stackoverflow.com/questions/48602393/how-to-convert-modern-html-to-pdf-from-command-line/48652806#48652806) I built a nodejs package that creates such a command line tool: https://www.npmjs.com/package/chromehtml2pdf Hopefully, it's helpful. |
|||||||||||
►
Sign in to add a comment |
|||||||||||
Comment 1 by skyos...@chromium.org
, Apr 14 2016