Closed ajrcarey closed 2 years ago
Added bindings for FPDF_VIEWERREF_*()
functions. Added example of image object creation in examples/image.rs
. Updated documentation. Need to complete WASM bindings before publishing crate version 0.7.8.
Completed WASM bindings. Added tests to confirm setting an image object's image and then retrieving that image object's image returns the same image :) Published crate version 0.7.8.
Fleshed out image object functions in PdfPageImageObject.
The
FPDFBitmap_GetBuffer()
function is problematic. It returns a pointer to a mutable buffer of pixel data. Mutating that buffer changes the image linked to an image object. When compiling to WASM, the buffer lives in a separate WASM module, so the buffer returned by theWasmPdfiumBindings::FPDFBitmap_GetBuffer()
is necessarily a copy (since it must reside in pdfium-render's WASM module, not Pdfium's). Mutating this buffer does nothing since Pdfium never sees it, and there is no way for pdfium-render to know when the caller has finished mutating data, so there is no reliable way for pdfium-render to copy any changes made to the buffer back across to Pdfium's WASM module.Adjusted definition of
FPDFBitmap_GetBuffer()
so that it returns*const c_void
rather than*mut c_void
when compiling to WASM, in order to make the problem more obvious to the caller. (Obviously the caller can recast the pointer to*mut
if they really want to, but this forces them to do so.) Added doc comments to the binding to explain the problem. Added newFPDFBitmap_SetBuffer()
function that makes it easy for a caller to provide an updated pixel data buffer for a bitmap in a way that works for all target platforms including WASM.