PDFium for Web Assembly is working and has a web demo

1,680 views
Skip to first unread message

Paulo Coutinho

unread,
Jan 31, 2021, 5:07:20 AM1/31/21
to pdfium
Hi,

It is working on my project here:

And you can test on web here:

Consider donation on Sponsor button.

Problems:

  1. Some images are blue and i don't know why. Anyone understand why and can help?
    download (1).png


Thanks.

Paulo Coutinho

unread,
Jan 31, 2021, 6:45:21 AM1/31/21
to pdfium
Hi,

I have fixed the color problem.

Daniel Hosseinian

unread,
Feb 1, 2021, 3:32:51 PM2/1/21
to Paulo Coutinho, pdfium
Hi Paulo,

Neat project!

Glad to see you figured out the color problem. Were the images coming out blue because of the byte order? FPDF_REVERSE_BYTE_ORDER is helpful for switching from BGRA to RGBA when rendering to bitmaps.

Best,
Daniel

--
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/5d3530b8-3e7b-40c9-9523-d4df610bf4fbn%40googlegroups.com.


--
Google Logo
Daniel Hosseinian
Software Engineer
dh...@google.com
+1 424-341-4575

Paulo Coutinho

unread,
Feb 1, 2021, 3:44:06 PM2/1/21
to Daniel Hosseinian, pdfium
Wow nice man! Much more fast than my loop to change the bytes.

I see these options but don't see this exact option to revert it.

Thanks man.

--
Atenciosamente, 
Paulo Coutinho.
PRS - Soluções Inteligentes
Blog: www.pcoutinho.com 
Skype: paulo.prsolucoes

Daniel Hosseinian

unread,
Feb 1, 2021, 3:50:55 PM2/1/21
to Paulo Coutinho, pdfium
I'm not sure if I understood your concern exactly :) 

You can use that flag in the `flag` parameter of methods like `FPDF_RenderPageBitmap()`. Here's an example where Chromium calls PDFium [1].

Paulo Coutinho

unread,
Feb 1, 2021, 4:15:58 PM2/1/21
to Daniel Hosseinian, pdfium
Yes, I understand and i'm using it now.

I sad that I see this options/flags in the past but i don't remember about this option to revert bytes.

Im making now a better PDF modal in javascript to show the images without stretch the images.

Thanks.



Paulo Coutinho

unread,
Feb 1, 2021, 8:06:14 PM2/1/21
to Daniel Hosseinian, pdfium
Hey man,

I have added a lot of functions now:


or direct with PDF:


Im making a public viewer for any PDF.

Can you test?

I have tested with big/small PDF, with and without complex images, but only one PDF don't render images in my test. I will attach here. Can you help me understand why these images not render, but only the test?

Thanks.

sample-pdf-with-images.pdf

Daniel Hosseinian

unread,
Feb 1, 2021, 8:28:38 PM2/1/21
to Paulo Coutinho, pdfium
Hi Paulo,

Again -- neat website! I'm glad to see developers put PDFium to great use!

Regarding your problem -- I'm not sure why the images are missing but I recommend that you try rendering the document with `pdfium_test` [1]. If it does render (which I think it should), then compare that code to yours. I took a quick look at your code [2] and I didn't see anything wrong with it. But then again, I didn't have time for a deep debug.

Please let me know if I can forward you to any other resources.

Cheers,
Danie;

Paulo Coutinho

unread,
Feb 1, 2021, 11:33:06 PM2/1/21
to Daniel Hosseinian, pdfium
Hi,

The source code is here:

I have compared to your file (pdfium_test) and changed to version 3 only, but make no difference.

I see the render function too and don't see differences, only that you can enable v8, but i don't know if it is the problem.

I will test pdfium_test after.

Thanks anyway.


Daniel Hosseinian

unread,
Feb 2, 2021, 12:18:05 PM2/2/21
to Paulo Coutinho, pdfium
Yup, give pdfium_test a try. By the way, pdfium_test has runtime flags for disabling V8, although I doubt that this PDF embeds any JavaScript.

Paulo Coutinho

unread,
Feb 5, 2021, 2:18:57 PM2/5/21
to pdfium
Hi,

After test with pdfium_test program, i have some conclusions:

- the page was exported with success (image is attached) with command:

./pdfium_test --png --pages=0 ~/Documents/PDF/sample-pdf-with-images.pdf

- there is no problem in render process of pdfium for desktop (ex: macos)

- something or is not compiled for wasm or some code are necessary to render it like in desktop program


I only need understand what is wrong now to finish it.


sample-pdf-with-images.pdf.0.png
sample-pdf-with-images.pdf

Paulo Coutinho

unread,
Mar 26, 2021, 1:57:44 AM3/26/21
to pdfium
Hi,

Can anyone help me on this?

Thanks.

Paulo Coutinho

unread,
May 14, 2021, 3:27:10 PM5/14/21
to pdfium
Hi,

We discovered some tips about the problem:

[attached]

It is related to "Jpeg Decoding".

Thanks for any help.

118282704-dda87700-b4ce-11eb-961a-df184c968787.png

Paulo Coutinho

unread,
May 15, 2021, 2:42:16 PM5/15/21
to pdfium
Hi,

Finally make it work.

The full issue history is here:

The repository updated is here:

And the web demo is here:

Thanks.
Reply all
Reply to author
Forward
0 new messages