How to config PDFium for PDF with complex vector drawings?

231 views
Skip to first unread message

Dmitry Goryachev

unread,
Mar 16, 2021, 6:01:08 PM3/16/21
to pdfium
Hi,

I have a PDF file with very complex vector drawings on a large page. Rendering one page with Pdfium takes 6-7 minutes. But Chrome browser renders this PDF in less than a minute.
Unfortunately, I have no permission to publish this PDF here, but I can send it by email.

Currently args.gn contains the following flags:
pdf_is_standalone = false
pdf_use_skia = false
pdf_use_skia_paths = false
pdf_enable_xfa = false
pdf_enable_v8 = false
is_component_build = false
clang_use_chrome_plugins = false
pdf_is_complete_lib = true
use_custom_libcxx = false
use_custom_libcxx_for_host = false
target_cpu = "x86"
is_debug = false
is_official_build = true

How to reduce the rendering time of complex PDFs via PDFium?

Thanks,
Dmitry

Olivia Yingst

unread,
Mar 16, 2021, 8:07:31 PM3/16/21
to Dmitry Goryachev, pdfium
Hi Dmitry,

Could it be the PDF viewer inside the browser was rendering the PDF file at a different scale level? That might affect the rendering time significantly.

Also, here are some of the args I use normally:
pdf_enable_xfa = true
pdf_enable_v8 = true 
pdf_is_standalone = true  # Set for a non-embedded build.

is_component_build = false 
clang_use_chrome_plugins = false

Since Chrome browser doesn't have skia enabled, the two skia flags are not the issue. But sometimes setting pdf_use_skia to true may lead to shorter rendering time. You can give it a try.

Thanks,
Olivia




--
You received this message because you are subscribed to the Google Groups "pdfium" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pdfium+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pdfium/72fb670e-316e-4b95-9558-ac77803bc433n%40googlegroups.com.


--

Olivia(Hui) Yingst | Software Engineer | huiy...@google.com | 213-399-8487

Dmitry Goryachev

unread,
Mar 22, 2021, 1:59:52 PM3/22/21
to pdfium
Hi Olivia,

Thank you for the suggestions. Unfortunately, skia flags didn't help and only made it worse. At least for the current file.
Rendering with 25% scaling takes about 5min. This is still a big discrepancy with the Chrome browser.
Any other ideas, flags, properties?

I can send a file by email directly if it helps and will be deleted after use.

Thanks,
Dmitry

среда, 17 марта 2021 г. в 03:07:31 UTC+3, Olivia Yingst:

Dmitry Goryachev

unread,
Apr 7, 2021, 7:46:20 AM4/7/21
to pdfium
Hi Olivia,

Any updates?
Perhaps anyone knows what methods chromium uses to render pages? Is it a regular FPDF_RenderPageBitmap or some kind of modification or alternative?

Thanks,
Dmitry

понедельник, 22 марта 2021 г. в 20:59:52 UTC+3, Dmitry Goryachev:

K. Moon

unread,
Apr 7, 2021, 12:12:23 PM4/7/21
to Dmitry Goryachev, pdfium
The source for Chromium is searchable:

Chromium doesn't use any secret APIs, just what PDFium provides. It does use progressive rendering, but that's only likely to make things slower, not faster.

You probably should try and profile your application to see where all the time is going. It may be something you don't expect (like memory allocation, for example).

Dmitry Goryachev

unread,
Apr 7, 2021, 1:59:22 PM4/7/21
to pdfium
Thank you for the answer.
I forgot to say that I made a test to reproduce this issue

  EXPECT_TRUE(EmbedderTest::OpenDocument("Confidential.pdf"));
  FPDF_PAGE page = EmbedderTest::LoadPage(1);
  ASSERT_TRUE(page);

  // 25% scale
  int width = static_cast<int>(FPDF_GetPageWidthF(page) / 4);
  int height = static_cast<int>(FPDF_GetPageHeightF(page) / 4);

  int alpha = FPDFPage_HasTransparency(page) ? 1 : 0;
  ScopedFPDFBitmap bitmap(FPDFBitmap_Create(width, height, alpha));
  FPDF_DWORD fill_color = alpha ? 0x00000000 : 0xFFFFFFFF;
  FPDFBitmap_FillRect(bitmap.get(), 0, 0, width, height, fill_color);
  FPDF_RenderPageBitmap(bitmap.get(), page, 0, 0, width, height, 0, 0);
  FPDF_FFLDraw(nullptr, bitmap.get(), page, 0, 0, width, height, 0, 0);

Thanks,
Dmitry
среда, 7 апреля 2021 г. в 19:12:23 UTC+3, km...@chromium.org:
Reply all
Reply to author
Forward
0 new messages