mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-12-22 13:00:08 +00:00
..
This commit is contained in:
parent
dfb258c7a0
commit
5c2fa8ead1
@ -5,7 +5,7 @@ find_package(PkgConfig)
|
||||
pkg_check_modules(POPPLER REQUIRED poppler)
|
||||
include_directories(${POPPLER_INCLUDE_DIRS})
|
||||
link_directories ( ${POPPLER_LIBRARY_DIRS} )
|
||||
find_package(Boost REQUIRED COMPONENTS program_options filesystem)
|
||||
find_package(Boost REQUIRED COMPONENTS program_options filesystem system)
|
||||
include_directories(${Boost_INCLUDE_DIRS})
|
||||
link_directories ( ${Boost_LIBRARY_DIRS} )
|
||||
include_directories(src)
|
||||
@ -17,7 +17,6 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
|
||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb")
|
||||
|
||||
configure_file (bin/pdf2htmlEX.in bin/pdf2htmlEX)
|
||||
configure_file (src/config.h.in src/config.h)
|
||||
|
||||
add_executable(pdf2htmlEX
|
||||
@ -37,11 +36,8 @@ add_executable(pdf2htmlEX
|
||||
src/util.h
|
||||
src/config.h)
|
||||
|
||||
#link boost::system temporarily... maybe a bug of boost
|
||||
#target_link_libraries(pdf2htmlEX poppler boost_program_options boost_filesystem)
|
||||
target_link_libraries(pdf2htmlEX poppler boost_program_options boost_filesystem boost_system)
|
||||
|
||||
install (TARGETS pdf2htmlEX DESTINATION lib/pdf2htmlEX)
|
||||
install (PROGRAMS "bin/pdf2htmlEX" DESTINATION bin)
|
||||
install (TARGETS pdf2htmlEX DESTINATION bin)
|
||||
file (GLOB libfiles lib/*)
|
||||
install (FILES ${libfiles} DESTINATION lib/pdf2htmlEX)
|
||||
|
@ -31,7 +31,7 @@ Not supported yet
|
||||
Dependency
|
||||
----------------------------
|
||||
* libpoppler with xpdf header >= 0.20.2
|
||||
* boost c++ library (format, program options, gil, filesystem, serialization)
|
||||
* boost c++ library (format, program options, gil, filesystem, serialization, system(which is actually required by filesystem))
|
||||
* fontforge **Please use [the lastest version](https://github.com/fontforge/fontforge)**
|
||||
|
||||
HOW TO COMPILE
|
||||
|
@ -1,22 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
LIBDIR=@CMAKE_INSTALL_PREFIX@/lib/pdf2htmlEX
|
||||
TMPDIR=/tmp/pdf2htmlEX
|
||||
|
||||
# prepare the temporary directory
|
||||
test -d $TMPDIR || mkdir -p $TMPDIR
|
||||
rm -f $TMPDIR/* 2>/dev/null
|
||||
|
||||
$LIBDIR/pdf2htmlEX $*
|
||||
|
||||
if [ -f $TMPDIR/pdf2htmlEX.pe ]; then
|
||||
echo -n "Converting fonts: "
|
||||
fontforge -script $TMPDIR/pdf2htmlEX.pe 2>/dev/null
|
||||
echo "."
|
||||
fi
|
||||
|
||||
#clean
|
||||
#rm -f $TMPDIR/* 2>/dev/null
|
||||
|
||||
echo "Done."
|
@ -22,7 +22,7 @@ void HTMLRenderer::export_remote_font(long long fn_id, const string & suffix, co
|
||||
const std::string fn = (format("f%|1$x|%2%") % fn_id % suffix).str();
|
||||
if(param->single_html)
|
||||
{
|
||||
allcss_fout << "'data:font/" << fontfileformat << ";base64," << base64_filter(ifstream(tmp_dir / fn, ifstream::binary)) << "'";
|
||||
allcss_fout << "'data:font/" << fontfileformat << ";base64," << base64stream(ifstream(tmp_dir / fn, ifstream::binary)) << "'";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -131,7 +131,7 @@ void HTMLRenderer::startPage(int pageNum, GfxState *state)
|
||||
if(param->single_html)
|
||||
{
|
||||
auto path = tmp_dir / fn;
|
||||
html_fout << "'data:image/png;base64," << base64_filter(ifstream(path, ifstream::binary)) << "'";
|
||||
html_fout << "'data:image/png;base64," << base64stream(ifstream(path, ifstream::binary)) << "'";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
42
src/util.h
42
src/util.h
@ -13,7 +13,6 @@
|
||||
#include <algorithm>
|
||||
#include <istream>
|
||||
#include <ostream>
|
||||
#include <iterator>
|
||||
#include <iomanip>
|
||||
|
||||
#include <GfxState.h>
|
||||
@ -24,7 +23,6 @@
|
||||
|
||||
using std::istream;
|
||||
using std::ostream;
|
||||
using std::istream_iterator;
|
||||
using std::endl;
|
||||
using std::noskipws;
|
||||
|
||||
@ -120,41 +118,37 @@ public:
|
||||
double _[6];
|
||||
};
|
||||
|
||||
class base64_filter
|
||||
class base64stream
|
||||
{
|
||||
public:
|
||||
|
||||
base64_filter(istream & in)
|
||||
: in_iter(istream_iterator<char>(in >> noskipws))
|
||||
base64stream(istream & in)
|
||||
: in(&in)
|
||||
{ }
|
||||
|
||||
base64_filter(istream && in)
|
||||
: in_iter(istream_iterator<char>(in >> noskipws))
|
||||
base64stream(istream && in)
|
||||
: in(&in)
|
||||
{ }
|
||||
|
||||
ostream & dumpto(ostream & out)
|
||||
{
|
||||
unsigned char buf[3];
|
||||
istream_iterator<char> end_iter;
|
||||
int cnt = 0;
|
||||
while(in_iter != end_iter)
|
||||
while(in->read((char*)buf, 3))
|
||||
{
|
||||
buf[cnt++] = *(in_iter++);
|
||||
if(cnt == 3)
|
||||
{
|
||||
out << base64_encoding[(buf[0] & 0xfc)>>2];
|
||||
out << base64_encoding[((buf[0] & 0x03)<<4) | ((buf[1] & 0xf0)>>4)];
|
||||
out << base64_encoding[((buf[1] & 0x0f)<<2) | ((buf[2] & 0xc0)>>6)];
|
||||
out << base64_encoding[(buf[2] & 0x3f)];
|
||||
cnt = 0;
|
||||
}
|
||||
out << base64_encoding[(buf[0] & 0xfc)>>2]
|
||||
<< base64_encoding[((buf[0] & 0x03)<<4) | ((buf[1] & 0xf0)>>4)]
|
||||
<< base64_encoding[((buf[1] & 0x0f)<<2) | ((buf[2] & 0xc0)>>6)]
|
||||
<< base64_encoding[(buf[2] & 0x3f)];
|
||||
}
|
||||
auto cnt = in->gcount();
|
||||
if(cnt > 0)
|
||||
{
|
||||
for(int i = cnt; i < 3; ++i)
|
||||
buf[i] = 0;
|
||||
out << base64_encoding[(buf[0] & 0xfc)>>2];
|
||||
out << base64_encoding[((buf[0] & 0x03)<<4) | ((buf[1] & 0xf0)>>4)];
|
||||
|
||||
out << base64_encoding[(buf[0] & 0xfc)>>2]
|
||||
<< base64_encoding[((buf[0] & 0x03)<<4) | ((buf[1] & 0xf0)>>4)];
|
||||
|
||||
if(cnt > 1)
|
||||
{
|
||||
out << base64_encoding[(buf[1] & 0x0f)<<2];
|
||||
@ -171,10 +165,10 @@ public:
|
||||
|
||||
private:
|
||||
static constexpr const char * base64_encoding = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
istream_iterator<char> in_iter;
|
||||
istream * in;
|
||||
};
|
||||
|
||||
static inline ostream & operator << (ostream & out, base64_filter & bf) { return bf.dumpto(out); }
|
||||
static inline ostream & operator << (ostream & out, base64_filter && bf) { return bf.dumpto(out); }
|
||||
static inline ostream & operator << (ostream & out, base64stream & bf) { return bf.dumpto(out); }
|
||||
static inline ostream & operator << (ostream & out, base64stream && bf) { return bf.dumpto(out); }
|
||||
|
||||
#endif //UTIL_H__
|
||||
|
Loading…
Reference in New Issue
Block a user