Closed tskarman closed 8 years ago
Why would you want to disable V8? From what I understand, PDF documents may contain JavaScript. Are you proposing to maybe create an alternative version of the DLL that does not have V8?
I am not suggesting that you disable it by default. This issue is mostly about build documentation and (maybe) simplifying the process, as well as keeping the build instructions close to those of the native project.
Regarding your question: I use your library mostly for PDF rendering. I have not encountered any PDFs yet whose basic output (incl. annotations) depends on JavaScript being executed. Disabling the V8 module doesn't necessarily preclude JavaScript from running. From what I remember, disabling V8 doesn't disable JavaScript support altogether.
Anyway, since I do not require the V8 JavaScript parts, I prefer to not include them as it increases the attack surface for PDF-JavaScript-based exploits. V8 is an obvious target. I am running PdfiumViewer in server environments.
Sorry for the slow response and thank you for the build instructions.
I've updated the build instructions on https://github.com/pvginkel/PdfiumViewer/wiki/Building-PDFium to use your build instructions.
I've included two versions of the Pdfium DLL's. The standard ones still include V8. However, I did another attempt at getting Windows XP compatible DLL's and it turns out that, if you use a recent dbghelp.dll
version, the only thing preventing Pdfium from running on Windows XP is V8. So, now, in Libraries\Pdfium\Without V8
there are builds of the Pdfium DLL without V8 support. See https://github.com/pvginkel/PdfiumViewer/tree/master/Libraries/Pdfium for more information.
I've created a new project at PdfiumBuild to automate building the PDFium library. This project runs on a build server to create new versions daily. Have a look at that project for where to find the output.
I wanted to update the native PDFium libraries for myself and ended up with a few suggestions that I'd like to share. They are closer to the current build instructions and reduce the amount of customization work and don't require any actual VS IDE work (you'll still need the installation for the compilers).
While poking around the native build instructions I also found a few interesting flags (
pdf_enable_xfa
andpdf_enable_v8
) that I might want to employ to reduce binary size/compilation time/attack surface.To better illustrate the amount of work required, I'll use screenshots for now. But I'd be happy to create a pull request for this if and when we've hammered out the details.
Adjustments to the
BUILD.gn
(output DLL, include yourpdfiumviewer.cpp
):Adjustments to the
pdfiumviewer.cpp
(conditional clean-up of V8):Example build configuration for
gn
(create this in the stepgn args <buildname>
):~~I haven't set up
x64
building yet. This might provide some hints: https://groups.google.com/forum/#!topic/pdfium/aBjlQCtldyA UPDATE 2: See notes below.~~ UPDATE 3: See notes below.The build instructions of the PDFium project again for reference: https://pdfium.googlesource.com/pdfium/
UPDATE 1:
To avoid some error output (the test projects won't build because we change the library output type to
shared_library
), conditionally disable those projects inBUILD.gn
like so:It would be cleaner to just remove those projects from the
BUILD.gn
file (as they won't build even whenpdf_is_standalone
istrue
at the moment). But for illustrative purposes, I chose to keep the diff small here.UPDATE 2:
By default, the tools will build
x64
onx64
machines, it appears.UPDATE 3:
For
x86
builds onx64
machines, add a line toargs.gn
(see above) that says:target_cpu = "x86"
You can also set it to
x64
but that is the default onx64
machines anyway and presum. won't work onx86
machines.To generate VS projects files (useful for checking the configuration), run:
gn gen <directory> --ide=vs
As I said above, VS IDE work is not required. Usually you'd want to just run this to produce the DLL:
ninja -C <directory>