44 lines
1.2 KiB
C++
44 lines
1.2 KiB
C++
#include <emscripten/emscripten.h>
|
|
#include <cstdint>
|
|
#include <string>
|
|
#include "pdf_engine_facade.hpp"
|
|
|
|
// Global facade instance
|
|
static PdfEngineFacade g_facade;
|
|
|
|
extern "C" {
|
|
|
|
EMSCRIPTEN_KEEPALIVE int loadDocument(const uint8_t* buffer, int size) {
|
|
return g_facade.loadDocument(buffer, size);
|
|
}
|
|
|
|
EMSCRIPTEN_KEEPALIVE int renderPage(int docHandle, int pageIndex, float scale, uint8_t* outputBuffer, int width, int height) {
|
|
return g_facade.renderPage(docHandle, pageIndex, scale, outputBuffer, width, height) ? 1 : 0;
|
|
}
|
|
|
|
EMSCRIPTEN_KEEPALIVE void freeDocument(int docHandle) {
|
|
g_facade.freeDocument(docHandle);
|
|
}
|
|
|
|
EMSCRIPTEN_KEEPALIVE const char* engineBuildInfo() {
|
|
return PdfEngineFacade::buildInfo();
|
|
}
|
|
|
|
EMSCRIPTEN_KEEPALIVE int engineHasSkia() {
|
|
return PdfEngineFacade::hasSkia() ? 1 : 0;
|
|
}
|
|
|
|
EMSCRIPTEN_KEEPALIVE const char* getDocumentFonts(int docHandle, int startPage, int endPage) {
|
|
static std::string s_buf;
|
|
s_buf = g_facade.getDocumentFonts(docHandle, startPage, endPage);
|
|
return s_buf.c_str();
|
|
}
|
|
|
|
EMSCRIPTEN_KEEPALIVE const char* getPageFonts(int docHandle, int pageIndex) {
|
|
static std::string s_buf;
|
|
s_buf = g_facade.getPageFonts(docHandle, pageIndex);
|
|
return s_buf.c_str();
|
|
}
|
|
|
|
}
|