Skip to content

Commit 8e76a85

Browse files
committed
fix funky string access
1 parent dc61272 commit 8e76a85

2 files changed

Lines changed: 11 additions & 12 deletions

File tree

pdf2htmlEX/src/BackgroundRenderer/CairoBackgroundRenderer.cc

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,10 @@ bool CairoBackgroundRenderer::render_page(PDFDoc * doc, int pageno)
130130
if (doc->getPageRotate(pageno) == 90 || doc->getPageRotate(pageno) == 270)
131131
std::swap(page_height, page_width);
132132

133-
134-
std::string tmp_fn = html_renderer->str_fmt("%s/tmp_bg%x.%s", (param.embed_image ? param.tmp_dir : param.dest_dir).c_str(), pageno, format.c_str());
135-
std::string fn = html_renderer->str_fmt("%s/bg%x.%s", (param.embed_image ? param.tmp_dir : param.dest_dir).c_str(), pageno, format.c_str());
133+
auto tmp_fn = html_renderer->str_fmt("%s/tmp_bg%x.%s", (param.embed_image ? param.tmp_dir : param.dest_dir).c_str(), pageno, format.c_str());
134+
auto fn = html_renderer->str_fmt("%s/bg%x.%s", (param.embed_image ? param.tmp_dir : param.dest_dir).c_str(), pageno, format.c_str());
136135

137-
surface = cairo_svg_surface_create(tmp_fn.c_str(), page_width * param.actual_dpi / DEFAULT_DPI, page_height * param.actual_dpi / DEFAULT_DPI);
136+
surface = cairo_svg_surface_create((const char *)tmp_fn, page_width * param.actual_dpi / DEFAULT_DPI, page_height * param.actual_dpi / DEFAULT_DPI);
138137
cairo_svg_surface_restrict_to_version(surface, CAIRO_SVG_VERSION_1_2);
139138
cairo_surface_set_fallback_resolution(surface, param.actual_dpi, param.actual_dpi);
140139

@@ -174,7 +173,7 @@ bool CairoBackgroundRenderer::render_page(PDFDoc * doc, int pageno)
174173
{
175174
int n = 0;
176175
char c;
177-
ifstream svgfile(tmp_fn);
176+
ifstream svgfile((const char *)tmp_fn);
178177
//count of '<' in the file should be an approximation of node count.
179178
while(svgfile >> c)
180179
{
@@ -191,10 +190,10 @@ bool CairoBackgroundRenderer::render_page(PDFDoc * doc, int pageno)
191190
for (auto id : bitmaps_in_current_page)
192191
++bitmaps_ref_count[id];
193192

194-
std::rename(tmp_fn.c_str(), fn.c_str());
193+
std::rename((const char *)tmp_fn, (const char *)fn);
195194

196195
if(param.embed_image)
197-
html_renderer->tmp_files.add(fn);
196+
html_renderer->tmp_files.add((const char *)fn);
198197

199198
return true;
200199
}

pdf2htmlEX/src/BackgroundRenderer/SplashBackgroundRenderer.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ bool SplashBackgroundRenderer::render_page(PDFDoc * doc, int pageno)
114114

115115
auto * bitmap = getBitmap();
116116

117-
std::string tmp_fn = html_renderer->str_fmt("%s/tmp_bg%x.%s", (param.embed_image ? param.tmp_dir : param.dest_dir).c_str(), pageno, format.c_str());
118-
std::string fn = html_renderer->str_fmt("%s/bg%x.%s", (param.embed_image ? param.tmp_dir : param.dest_dir).c_str(), pageno, format.c_str());
117+
auto tmp_fn = html_renderer->str_fmt("%s/tmp_bg%x.%s", (param.embed_image ? param.tmp_dir : param.dest_dir).c_str(), pageno, format.c_str());
118+
auto fn = html_renderer->str_fmt("%s/bg%x.%s", (param.embed_image ? param.tmp_dir : param.dest_dir).c_str(), pageno, format.c_str());
119119

120120
SplashImageFileFormat splashImageFileFormat;
121121
if(format == "png")
@@ -125,14 +125,14 @@ bool SplashBackgroundRenderer::render_page(PDFDoc * doc, int pageno)
125125
else
126126
throw string("Image format not supported: ") + format;
127127

128-
SplashError e = bitmap->writeImgFile(splashImageFileFormat, tmp_fn.c_str(), param.actual_dpi, param.actual_dpi);
128+
SplashError e = bitmap->writeImgFile(splashImageFileFormat, (const char *)tmp_fn, param.actual_dpi, param.actual_dpi);
129129
if (e != splashOk)
130130
throw string("Cannot write background image. SplashErrorCode: ") + std::to_string(e);
131131

132-
std::rename(tmp_fn.c_str(), fn.c_str());
132+
std::rename((const char *)tmp_fn, (const char *)fn);
133133

134134
if(param.embed_image)
135-
html_renderer->tmp_files.add(fn);
135+
html_renderer->tmp_files.add((const char *)fn);
136136

137137
return true;
138138
}

0 commit comments

Comments
 (0)