"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "htmldoc/ps-pdf.cxx" between
htmldoc-1.9.14-source.tar.gz and htmldoc-1.9.15-source.tar.gz

About: HTMLDOC converts HTML and Markdown source files into indexed HTML, EPUB, PostScript, or PDF files (but doesn’t support CSS).

ps-pdf.cxx  (htmldoc-1.9.14-source):ps-pdf.cxx  (htmldoc-1.9.15-source)
/* /*
* PostScript + PDF output routines for HTMLDOC, a HTML document processing * PostScript + PDF output routines for HTMLDOC, a HTML document processing
* program. * program.
* *
* Just in case you didn't notice it, this file is too big; it will be * Just in case you didn't notice it, this file is too big; it will be
* broken into more manageable pieces once we make all of the output * broken into more manageable pieces once we make all of the output
* "drivers" into classes... * "drivers" into classes...
* *
* Copyright © 2011-2021 by Michael R Sweet. * Copyright © 2011-2022 by Michael R Sweet.
* Copyright © 1997-2010 by Easy Software Products. All rights reserved. * Copyright © 1997-2010 by Easy Software Products. All rights reserved.
* *
* This program is free software. Distribution and use rights are outlined in * This program is free software. Distribution and use rights are outlined in
* the file "COPYING". * the file "COPYING".
*/ */
/* /*
* Include necessary headers. * Include necessary headers.
*/ */
skipping to change at line 70 skipping to change at line 70
#ifdef __hpux #ifdef __hpux
# undef page_t # undef page_t
#endif // __hpux #endif // __hpux
/* /*
* Output options... * Output options...
*/ */
#define HTMLDOC_ASCII85 #define HTMLDOC_ASCII85
//#define HTMLDOC_INTERPOLATION //#define HTMLDOC_INTERPOLATION
#define HTMLDOC_PRODUCER "htmldoc " SVERSION " Copyright 2011-2021 by Michael R Sweet" #define HTMLDOC_PRODUCER "htmldoc " SVERSION " Copyright 2011-2022 by Michael R Sweet"
/* /*
* Constants... * Constants...
*/ */
#define RENDER_TEXT 0 /* Text fragment */ #define RENDER_TEXT 0 /* Text fragment */
#define RENDER_IMAGE 1 /* Image */ #define RENDER_IMAGE 1 /* Image */
#define RENDER_BOX 2 /* Box */ #define RENDER_BOX 2 /* Box */
#define RENDER_LINK 3 /* Hyperlink */ #define RENDER_LINK 3 /* Hyperlink */
#define RENDER_BG 4 /* Background image */ #define RENDER_BG 4 /* Background image */
skipping to change at line 2800 skipping to change at line 2800
/* /*
* Make an object for this entry... * Make an object for this entry...
*/ */
if (toc == NULL) if (toc == NULL)
{ {
/* /*
* This is for the Table of Contents page... * This is for the Table of Contents page...
*/ */
if (chapter_starts[0] < 0 || chapter_starts[0] >= (int)num_pages)
return;
thisobj = pdf_start_object(out); thisobj = pdf_start_object(out);
fprintf(out, "/Parent %d 0 R", parent); fprintf(out, "/Parent %d 0 R", parent);
fputs("/Title", out); fputs("/Title", out);
write_utf16(out, (uchar *)TocTitle); write_utf16(out, (uchar *)TocTitle);
x = 0.0f; x = 0.0f;
y = PagePrintLength + PageBottom; y = PagePrintLength + PageBottom;
pspdf_transform_coords(pages + chapter_starts[0], x, y); pspdf_transform_coords(pages + chapter_starts[0], x, y);
skipping to change at line 2941 skipping to change at line 2944
if (parent > 0 && toc->child && toc->child->markup == MARKUP_A) if (parent > 0 && toc->child && toc->child->markup == MARKUP_A)
{ {
if ((text = htmlGetText(toc->child->child)) != NULL) if ((text = htmlGetText(toc->child->child)) != NULL)
{ {
fputs("/Title", out); fputs("/Title", out);
write_utf16(out, text); write_utf16(out, text);
free(text); free(text);
} }
i = heading_pages[*heading]; if (*heading < (int)num_headings)
x = 0.0f; {
y = heading_tops[*heading] + pages[i].bottom; i = heading_pages[*heading];
pspdf_transform_coords(pages + i, x, y); x = 0.0f;
y = heading_tops[*heading] + pages[i].bottom;
pspdf_transform_coords(pages + i, x, y);
fprintf(out, "/Dest[%d 0 R/XYZ %.0f %.0f 0]", fprintf(out, "/Dest[%d 0 R/XYZ %.0f %.0f 0]", pages_object + 2 * pages[i].
pages_object + 2 * pages[i].outpage + 1, x, y); outpage + 1, x, y);
(*heading) ++; (*heading) ++;
}
} }
if (prev > 0) if (prev > 0)
fprintf(out, "/Prev %d 0 R", prev); fprintf(out, "/Prev %d 0 R", prev);
if (next > 0) if (next > 0)
fprintf(out, "/Next %d 0 R", next); fprintf(out, "/Next %d 0 R", next);
pdf_end_object(out); pdf_end_object(out);
skipping to change at line 3852 skipping to change at line 3857
/* /*
* Update current headings for header/footer strings in TOC. * Update current headings for header/footer strings in TOC.
*/ */
check_pages(*page); check_pages(*page);
if (t->markup == MARKUP_B && pages[*page].chapter == pages[*page - 1] .chapter) if (t->markup == MARKUP_B && pages[*page].chapter == pages[*page - 1] .chapter)
{ {
pages[*page].chapter = htmlGetText(t->child->child); pages[*page].chapter = htmlGetText(t->child->child);
for (int i = *page + 1; i < num_pages; i ++) for (int i = *page + 1; i < (int)num_pages; i ++)
pages[i].chapter = pages[*page].chapter; pages[i].chapter = pages[*page].chapter;
} }
if (pages[*page].heading == pages[*page - 1].heading) if (pages[*page].heading == pages[*page - 1].heading)
{ {
pages[*page].heading = htmlGetText(t->child->child); pages[*page].heading = htmlGetText(t->child->child);
for (int i = *page + 1; i < num_pages; i ++) for (int i = *page + 1; i < (int)num_pages; i ++)
pages[i].heading = pages[*page].heading; pages[i].heading = pages[*page].heading;
} }
/* /*
* Next heading... * Next heading...
*/ */
(*heading) ++; (*heading) ++;
if (t->last_child->markup == MARKUP_UL) if (t->last_child->markup == MARKUP_UL)
skipping to change at line 4545 skipping to change at line 4550
if (Verbosity) if (Verbosity)
progress_show("Formatting page %d", *page); progress_show("Formatting page %d", *page);
} }
check_pages(*page); check_pages(*page);
if (t->markup == MARKUP_H1 && !title_page) if (t->markup == MARKUP_H1 && !title_page)
{ {
pages[*page].chapter = htmlGetText(current_heading); pages[*page].chapter = htmlGetText(current_heading);
for (int i = *page + 1; i < num_pages; i ++) for (int i = *page + 1; i < (int)num_pages; i ++)
pages[i].chapter = pages[*page].chapter; pages[i].chapter = pages[*page].chapter;
} }
if ((pages[*page].heading == NULL || t->markup == MARKUP_H1 || if ((pages[*page].heading == NULL || t->markup == MARKUP_H1 ||
(*page > 0 && pages[*page].heading == pages[*page - 1].heading)) && (*page > 0 && pages[*page].heading == pages[*page - 1].heading)) &&
!title_page) !title_page)
{ {
pages[*page].heading = htmlGetText(current_heading); pages[*page].heading = htmlGetText(current_heading);
pages[*page].headnode = current_heading; pages[*page].headnode = current_heading;
for (int i = *page + 1; i < num_pages; i ++) for (int i = *page + 1; i < (int)num_pages; i ++)
{ {
pages[i].heading = pages[*page].heading; pages[i].heading = pages[*page].heading;
pages[i].headnode = current_heading; pages[i].headnode = current_heading;
} }
} }
if ((t->markup - MARKUP_H1) < TocLevels && !title_page) if ((t->markup - MARKUP_H1) < TocLevels && !title_page)
{ {
DEBUG_printf(("H%d: heading_pages[%d] = %d\n", t->markup - MARKUP_H1 + 1, DEBUG_printf(("H%d: heading_pages[%d] = %d\n", t->markup - MARKUP_H1 + 1,
(int)num_headings, *page - 1)); (int)num_headings, *page - 1));
skipping to change at line 5439 skipping to change at line 5444
} }
} }
while (flat != NULL) while (flat != NULL)
{ {
for (height = 0.0f, start = flat; flat != NULL; flat = flat->next) for (height = 0.0f, start = flat; flat != NULL; flat = flat->next)
{ {
if (flat->height > height) if (flat->height > height)
height = flat->height; height = flat->height;
if (flat->markup == MARKUP_BR || if (flat->markup == MARKUP_BR || (flat->markup == MARKUP_NONE && flat->dat
(flat->markup == MARKUP_NONE && flat->data && a && flat->data[0] && flat->data[strlen((char *)flat->data) - 1] == '\n'))
flat->data[strlen((char *)flat->data) - 1] == '\n'))
break; break;
} }
if (flat) if (flat)
flat = flat->next; flat = flat->next;
if (*y < (height + bottom)) if (*y < (height + bottom))
{ {
(*page) ++; (*page) ++;
*y = top; *y = top;
skipping to change at line 5881 skipping to change at line 5884
if (cells[row][0] != NULL) if (cells[row][0] != NULL)
{ {
if ((height_var = htmlGetVariable(cells[row][0]->parent, (uchar *)"HEIGHT" )) == NULL) if ((height_var = htmlGetVariable(cells[row][0]->parent, (uchar *)"HEIGHT" )) == NULL)
for (col = 0; col < table.num_cols; col ++) for (col = 0; col < table.num_cols; col ++)
if (htmlGetVariable(cells[row][col], (uchar *)"ROWSPAN") == NULL) if (htmlGetVariable(cells[row][col], (uchar *)"ROWSPAN") == NULL)
if ((height_var = htmlGetVariable(cells[row][col], (uchar *)"HEIGHT") ) != NULL) if ((height_var = htmlGetVariable(cells[row][col], (uchar *)"HEIGHT") ) != NULL)
break; break;
} }
if (height_var != NULL) if (height_var != NULL && *height_var)
{ {
// Hardcode the row height... // Hardcode the row height...
if (height_var[strlen((char *)height_var) - 1] == '%') if (height_var[strlen((char *)height_var) - 1] == '%')
temp_height = (float)(atof((char *)height_var) * 0.01f * PagePrintLength ); temp_height = (float)(atof((char *)height_var) * 0.01f * PagePrintLength );
else else
temp_height = (float)(atof((char *)height_var) * PagePrintWidth / _htmlB rowserWidth); temp_height = (float)(atof((char *)height_var) * PagePrintWidth / _htmlB rowserWidth);
if (table.height > 0 && temp_height > table.height) if (table.height > 0 && temp_height > table.height)
temp_height = table.height; temp_height = table.height;
skipping to change at line 6320 skipping to change at line 6323
table.debug = 1; table.debug = 1;
else else
table.debug = 0; table.debug = 0;
/* /*
* Figure out the # of rows, columns, and the desired widths... * Figure out the # of rows, columns, and the desired widths...
*/ */
cells = NULL; cells = NULL;
if ((var = htmlGetVariable(t, (uchar *)"WIDTH")) != NULL) if ((var = htmlGetVariable(t, (uchar *)"WIDTH")) != NULL && *var)
{ {
if (var[strlen((char *)var) - 1] == '%') if (var[strlen((char *)var) - 1] == '%')
table_width = (float)(atof((char *)var) * (right - left) / 100.0f); table_width = (float)(atof((char *)var) * (right - left) / 100.0f);
else else
table_width = (float)(atoi((char *)var) * PagePrintWidth / _htmlBrowserWid th); table_width = (float)(atoi((char *)var) * PagePrintWidth / _htmlBrowserWid th);
if (table_width < 0.0f || table_width > PagePrintWidth) if (table_width < 0.0f || table_width > PagePrintWidth)
table_width = right - left; table_width = right - left;
} }
else else
table_width = right - left; table_width = right - left;
if ((var = htmlGetVariable(t, (uchar *)"HEIGHT")) != NULL) if ((var = htmlGetVariable(t, (uchar *)"HEIGHT")) != NULL && *var)
{ {
if (var[strlen((char *)var) - 1] == '%') if (var[strlen((char *)var) - 1] == '%')
table.height = (float)(atof((char *)var) * (top - bottom) / 100.0f); table.height = (float)(atof((char *)var) * (top - bottom) / 100.0f);
else else
table.height = (float)(atoi((char *)var) * PagePrintWidth / _htmlBrowserWi dth); table.height = (float)(atoi((char *)var) * PagePrintWidth / _htmlBrowserWi dth);
} }
else else
table.height = -1.0f; table.height = -1.0f;
DEBUG_printf(("table_width = %.1f\n", table_width)); DEBUG_printf(("table_width = %.1f\n", table_width));
skipping to change at line 6539 skipping to change at line 6542
if (table.row_spans[col] <= 1) if (table.row_spans[col] <= 1)
table.row_spans[col] = 0; table.row_spans[col] = 0;
for (tcol = 1; tcol < colspan; tcol ++) for (tcol = 1; tcol < colspan; tcol ++)
table.row_spans[col + tcol] = table.row_spans[col]; table.row_spans[col + tcol] = table.row_spans[col];
} }
// Compute the cell size... // Compute the cell size...
col_width = get_cell_size(tempcol, 0.0f, table_width, &col_min, &col_p ref, &col_height); col_width = get_cell_size(tempcol, 0.0f, table_width, &col_min, &col_p ref, &col_height);
if ((var = htmlGetVariable(tempcol, (uchar *)"WIDTH")) != NULL) if ((var = htmlGetVariable(tempcol, (uchar *)"WIDTH")) != NULL && *var )
{ {
if (var[strlen((char *)var) - 1] == '%') if (var[strlen((char *)var) - 1] == '%')
{ {
col_width -= 2.0 * table.cellpadding - cellspacing; col_width -= 2.0 * table.cellpadding - cellspacing;
if (colspan <= 1) if (colspan <= 1)
table.col_percent[col] = 1; table.col_percent[col] = 1;
} }
else else
{ {
skipping to change at line 6649 skipping to change at line 6652
if (table.num_cols == 0) if (table.num_cols == 0)
{ {
free(cells); free(cells);
return; return;
} }
/* /*
* Now figure out the width of the table... * Now figure out the width of the table...
*/ */
if ((var = htmlGetVariable(t, (uchar *)"WIDTH")) != NULL) if ((var = htmlGetVariable(t, (uchar *)"WIDTH")) != NULL && *var)
{ {
if (var[strlen((char *)var) - 1] == '%') if (var[strlen((char *)var) - 1] == '%')
width = (float)(atof((char *)var) * (right - left) / 100.0f); width = (float)(atof((char *)var) * (right - left) / 100.0f);
else else
width = (float)(atoi((char *)var) * PagePrintWidth / _htmlBrowserWidth); width = (float)(atoi((char *)var) * PagePrintWidth / _htmlBrowserWidth);
} }
else else
{ {
for (col = 0, width = 0.0; col < table.num_cols; col ++) for (col = 0, width = 0.0; col < table.num_cols; col ++)
width += table.col_prefs[col]; width += table.col_prefs[col];
skipping to change at line 6995 skipping to change at line 6998
if ((height_var = htmlGetVariable(cells[row][0]->parent, (uchar *)"HEIGHT" )) == NULL) if ((height_var = htmlGetVariable(cells[row][0]->parent, (uchar *)"HEIGHT" )) == NULL)
for (col = 0; col < table.num_cols; col ++) for (col = 0; col < table.num_cols; col ++)
if (htmlGetVariable(cells[row][col], (uchar *)"ROWSPAN") == NULL) if (htmlGetVariable(cells[row][col], (uchar *)"ROWSPAN") == NULL)
if ((height_var = htmlGetVariable(cells[row][col], (uchar *)"HEIGHT") ) != NULL) if ((height_var = htmlGetVariable(cells[row][col], (uchar *)"HEIGHT") ) != NULL)
break; break;
} }
if (height_var != NULL && row == header_row) if (height_var != NULL && row == header_row)
header_height_var = height_var; header_height_var = height_var;
if (cells[row][0] != NULL && height_var != NULL) if (cells[row][0] != NULL && height_var != NULL && *height_var)
{ {
// Row height specified; make sure it'll fit... // Row height specified; make sure it'll fit...
if (height_var[strlen((char *)height_var) - 1] == '%') if (height_var[strlen((char *)height_var) - 1] == '%')
temp_height = (float)(atof((char *)height_var) * 0.01f * (PagePrintLength - 2 * table.cellpadding)); temp_height = (float)(atof((char *)height_var) * 0.01f * (PagePrintLength - 2 * table.cellpadding));
else else
temp_height = (float)(atof((char *)height_var) * PagePrintWidth / _htmlB rowserWidth); temp_height = (float)(atof((char *)height_var) * PagePrintWidth / _htmlB rowserWidth);
if (table.height > 0.0f && temp_height > table.height) if (table.height > 0.0f && temp_height > table.height)
temp_height = table.height; temp_height = table.height;
skipping to change at line 8958 skipping to change at line 8961
frag_min, // Fragment minimum width frag_min, // Fragment minimum width
minh, // Local minimum height minh, // Local minimum height
minw, // Local minimum width minw, // Local minimum width
prefw, // Local preferred width prefw, // Local preferred width
format_width; // Working format width for images format_width; // Working format width for images
DEBUG_printf(("get_cell_size(%p, %.1f, %.1f, %p, %p, %p)\n", DEBUG_printf(("get_cell_size(%p, %.1f, %.1f, %p, %p, %p)\n",
(void *)t, left, right, (void *)minwidth, (void *)prefwidth, (vo id *)minheight)); (void *)t, left, right, (void *)minwidth, (void *)prefwidth, (vo id *)minheight));
// First see if the width has been specified for this cell... // First see if the width has been specified for this cell...
if ((var = htmlGetVariable(t, (uchar *)"WIDTH")) != NULL && if ((var = htmlGetVariable(t, (uchar *)"WIDTH")) != NULL && *var && (var[strle
(var[strlen((char *)var) - 1] != '%' || (right - left) > 0.0f)) n((char *)var) - 1] != '%' || (right - left) > 0.0f))
{ {
// Yes, use it! // Yes, use it!
if (var[strlen((char *)var) - 1] == '%') if (var[strlen((char *)var) - 1] == '%')
width = (right - left) * atoi((char *)var) * 0.01f; width = (right - left) * atoi((char *)var) * 0.01f;
else else
width = (float)(atoi((char *)var) * PagePrintWidth / _htmlBrowserWidth); width = (float)(atoi((char *)var) * PagePrintWidth / _htmlBrowserWidth);
} }
else else
width = 0.0f; width = 0.0f;
if ((format_width = right - left) <= 0.0f) if ((format_width = right - left) <= 0.0f)
format_width = PagePrintWidth; format_width = PagePrintWidth;
minw = 0.0f; minw = 0.0f;
prefw = 0.0f; prefw = 0.0f;
// Then the height... // Then the height...
if ((var = htmlGetVariable(t, (uchar *)"HEIGHT")) != NULL) if ((var = htmlGetVariable(t, (uchar *)"HEIGHT")) != NULL && *var)
{ {
// Yes, use it! // Yes, use it!
if (var[strlen((char *)var) - 1] == '%') if (var[strlen((char *)var) - 1] == '%')
minh = PagePrintLength * atoi((char *)var) * 0.01f; minh = PagePrintLength * atoi((char *)var) * 0.01f;
else else
minh = (float)(atoi((char *)var) * PagePrintWidth / _htmlBrowserWidth); minh = (float)(atoi((char *)var) * PagePrintWidth / _htmlBrowserWidth);
} }
else else
minh = 0.0f; minh = 0.0f;
skipping to change at line 9066 skipping to change at line 9068
#endif // TABLE_DEBUG2 #endif // TABLE_DEBUG2
// Handle min/preferred widths separately... // Handle min/preferred widths separately...
if (temp->width > minw) if (temp->width > minw)
{ {
DEBUG_printf(("Setting minw to %.1f (was %.1f) for fragment...\n", DEBUG_printf(("Setting minw to %.1f (was %.1f) for fragment...\n",
temp->width, minw)); temp->width, minw));
minw = temp->width; minw = temp->width;
} }
if (temp->preformatted && temp->data != NULL && if (temp->preformatted && temp->data != NULL && temp->data[0] && temp-
temp->data[strlen((char *)temp->data) - 1] == '\n') >data[strlen((char *)temp->data) - 1] == '\n')
{ {
// End of a line - check preferred width... // End of a line - check preferred width...
frag_pref += temp->width + 1; frag_pref += temp->width + 1;
if (frag_pref > prefw) if (frag_pref > prefw)
prefw = frag_pref; prefw = frag_pref;
if (temp->preformatted && frag_pref > minw) if (temp->preformatted && frag_pref > minw)
{ {
DEBUG_printf(("Setting minw to %.1f (was %.1f) for preformatted...\ n", DEBUG_printf(("Setting minw to %.1f (was %.1f) for preformatted...\ n",
skipping to change at line 9097 skipping to change at line 9098
{ {
// parse_paragraph() will force a break // parse_paragraph() will force a break
if (frag_pref > prefw) if (frag_pref > prefw)
prefw = frag_pref; prefw = frag_pref;
frag_pref = temp->width; frag_pref = temp->width;
} }
else else
frag_pref += temp->width; frag_pref += temp->width;
if (temp->preformatted && temp->data != NULL && if (temp->preformatted && temp->data != NULL && temp->data[0] && temp
temp->data[strlen((char *)temp->data) - 1] == '\n') ->data[strlen((char *)temp->data) - 1] == '\n')
{ {
// Check required width... // Check required width...
frag_width += temp->width + 1; frag_width += temp->width + 1;
if (frag_width > minw) if (frag_width > minw)
{ {
DEBUG_printf(("Setting minw to %.1f (was %.1f) for block...\n", DEBUG_printf(("Setting minw to %.1f (was %.1f) for block...\n",
frag_width, minw)); frag_width, minw));
minw = frag_width; minw = frag_width;
} }
frag_width = 0.0f; frag_width = 0.0f;
} }
else if (!temp->preformatted && temp->data != NULL && else if (!temp->preformatted && temp->data != NULL && temp->data[0] &&
(isspace(temp->data[0]) || (isspace(temp->data[0]) || (temp->data[0] && isspace(temp->data[strlen((char *)
(temp->data[0] && isspace(temp->data[strlen((char *)temp->dat temp->data) - 1]))))
a) - 1]))))
{ {
// Check required width... // Check required width...
if (isspace(temp->data[0])) if (isspace(temp->data[0]))
frag_width = temp->width + 1; frag_width = temp->width + 1;
else else
frag_width += temp->width + 1; frag_width += temp->width + 1;
if (frag_width > minw) if (frag_width > minw)
{ {
DEBUG_printf(("Setting minw to %.1f (was %.1f) for block...\n", DEBUG_printf(("Setting minw to %.1f (was %.1f) for block...\n",
skipping to change at line 9287 skipping to change at line 9285
cellpadding, // Padding inside cells cellpadding, // Padding inside cells
cellspacing; // Spacing around cells cellspacing; // Spacing around cells
int columns, // Current number of columns int columns, // Current number of columns
max_columns, // Maximum columns max_columns, // Maximum columns
rows; // Number of rows rows; // Number of rows
DEBUG_printf(("get_table_size(%p, %.1f, %.1f, %p, %p, %p)\n", DEBUG_printf(("get_table_size(%p, %.1f, %.1f, %p, %p, %p)\n",
(void *)t, left, right, (void *)minwidth, (void *)prefwidth, (vo id *)minheight)); (void *)t, left, right, (void *)minwidth, (void *)prefwidth, (vo id *)minheight));
// First see if the width has been specified for this table... // First see if the width has been specified for this table...
if ((var = htmlGetVariable(t, (uchar *)"WIDTH")) != NULL && if ((var = htmlGetVariable(t, (uchar *)"WIDTH")) != NULL && *var && (var[strle
(var[strlen((char *)var) - 1] != '%' || (right - left) > 0.0f)) n((char *)var) - 1] != '%' || (right - left) > 0.0f))
{ {
// Yes, use it! // Yes, use it!
if (var[strlen((char *)var) - 1] == '%') if (var[strlen((char *)var) - 1] == '%')
width = (right - left) * atoi((char *)var) * 0.01f; width = (right - left) * atoi((char *)var) * 0.01f;
else else
width = (float)(atoi((char *)var) * PagePrintWidth / _htmlBrowserWidth); width = (float)(atoi((char *)var) * PagePrintWidth / _htmlBrowserWidth);
} }
else else
width = 0.0f; width = 0.0f;
minw = 0.0f; minw = 0.0f;
prefw = 0.0f; prefw = 0.0f;
// Then the height... // Then the height...
if ((var = htmlGetVariable(t, (uchar *)"HEIGHT")) != NULL) if ((var = htmlGetVariable(t, (uchar *)"HEIGHT")) != NULL && *var)
{ {
// Yes, use it! // Yes, use it!
if (var[strlen((char *)var) - 1] == '%') if (var[strlen((char *)var) - 1] == '%')
minh = PagePrintLength * atoi((char *)var) * 0.01f; minh = PagePrintLength * atoi((char *)var) * 0.01f;
else else
minh = (float)(atoi((char *)var) * PagePrintWidth / _htmlBrowserWidth); minh = (float)(atoi((char *)var) * PagePrintWidth / _htmlBrowserWidth);
} }
else else
minh = 0.0f; minh = 0.0f;
skipping to change at line 9585 skipping to change at line 9582
static void static void
update_image_size(tree_t *t) /* I - Tree entry */ update_image_size(tree_t *t) /* I - Tree entry */
{ {
image_t *img; /* Image file */ image_t *img; /* Image file */
uchar *width, /* Width string */ uchar *width, /* Width string */
*height; /* Height string */ *height; /* Height string */
width = htmlGetVariable(t, (uchar *)"WIDTH"); width = htmlGetVariable(t, (uchar *)"WIDTH");
height = htmlGetVariable(t, (uchar *)"HEIGHT"); height = htmlGetVariable(t, (uchar *)"HEIGHT");
if (width != NULL && height != NULL) if (width != NULL && *width && height != NULL && *height)
{ {
if (width[strlen((char *)width) - 1] == '%') if (width[strlen((char *)width) - 1] == '%')
t->width = (float)(atof((char *)width) * PagePrintWidth / 100.0f); t->width = (float)(atof((char *)width) * PagePrintWidth / 100.0f);
else else
t->width = (float)(atoi((char *)width) * PagePrintWidth / _htmlBrowserWidt h); t->width = (float)(atoi((char *)width) * PagePrintWidth / _htmlBrowserWidt h);
if (height[strlen((char *)height) - 1] == '%') if (height[strlen((char *)height) - 1] == '%')
t->height = (float)(atof((char *)height) * PagePrintWidth / 100.0f); t->height = (float)(atof((char *)height) * PagePrintWidth / 100.0f);
else else
t->height = (float)(atoi((char *)height) * PagePrintWidth / _htmlBrowserWi dth); t->height = (float)(atoi((char *)height) * PagePrintWidth / _htmlBrowserWi dth);
return; return;
} }
img = image_find((char *)htmlGetVariable(t, (uchar *)"REALSRC")); img = image_find((char *)htmlGetVariable(t, (uchar *)"REALSRC"));
if (img == NULL) if (img == NULL)
return; return;
if (width != NULL) if (width != NULL && *width)
{ {
if (width[strlen((char *)width) - 1] == '%') if (width[strlen((char *)width) - 1] == '%')
t->width = (float)(atof((char *)width) * PagePrintWidth / 100.0f); t->width = (float)(atof((char *)width) * PagePrintWidth / 100.0f);
else else
t->width = (float)(atoi((char *)width) * PagePrintWidth / _htmlBrowserWidt h); t->width = (float)(atoi((char *)width) * PagePrintWidth / _htmlBrowserWidt h);
t->height = t->width * img->height / img->width; t->height = t->width * img->height / img->width;
} }
else if (height != NULL) else if (height != NULL && *height)
{ {
if (height[strlen((char *)height) - 1] == '%') if (height[strlen((char *)height) - 1] == '%')
t->height = (float)(atof((char *)height) * PagePrintWidth / 100.0f); t->height = (float)(atof((char *)height) * PagePrintWidth / 100.0f);
else else
t->height = (float)(atoi((char *)height) * PagePrintWidth / _htmlBrowserWi dth); t->height = (float)(atoi((char *)height) * PagePrintWidth / _htmlBrowserWi dth);
t->width = t->height * img->width / img->height; t->width = t->height * img->width / img->height;
} }
else else
{ {
skipping to change at line 10172 skipping to change at line 10169
/* /*
* See if we can optimize the image as indexed without color loss... * See if we can optimize the image as indexed without color loss...
*/ */
img = r->data.image; img = r->data.image;
ncolors = 0; ncolors = 0;
indices = NULL; indices = NULL;
indwidth = 0; indwidth = 0;
if (!img->pixels && !img->obj) if (!img->pixels && !img->obj)
{
image_load(img->filename, !OutputColor, 1); image_load(img->filename, !OutputColor, 1);
if (!img->pixels)
return;
}
// Note: Acrobat 6 tries to decrypt the colormap of indexed in-line images twi ce, which // Note: Acrobat 6 tries to decrypt the colormap of indexed in-line images twi ce, which
// is 1) not consistent with prior Acrobat releases and 2) in violation of their // is 1) not consistent with prior Acrobat releases and 2) in violation of their
// PDF spec. The "img->use > 1 || !Encryption" test prevents the use of indexed // PDF spec. The "img->use > 1 || !Encryption" test prevents the use of indexed
// in-line images when encryption is enabled. // in-line images when encryption is enabled.
// //
// We are filing a bug on this with Adobe, but if history is any indicat or, we are // We are filing a bug on this with Adobe, but if history is any indicat or, we are
// stuck with this workaround forever... // stuck with this workaround forever...
if (PSLevel != 1 && PDFVersion >= 12 && img->obj == 0 && (img->use > 1 || !Enc ryption)) if (PSLevel != 1 && PDFVersion >= 12 && img->obj == 0 && (img->use > 1 || !Enc ryption))
{ {
if (img->depth == 1) if (img->depth == 1)
skipping to change at line 12338 skipping to change at line 12340
* Embed a Type1 font in the PostScript output... * Embed a Type1 font in the PostScript output...
*/ */
fprintf(out, "%%%%BeginResource: font %s\n", _htmlFonts[typeface][style]); fprintf(out, "%%%%BeginResource: font %s\n", _htmlFonts[typeface][style]);
line[0] = '\0'; line[0] = '\0';
while (fgets(line, sizeof(line), fp) != NULL) while (fgets(line, sizeof(line), fp) != NULL)
fputs(line, out); fputs(line, out);
if (line[strlen(line) - 1] != '\n') if (line[0] && line[strlen(line) - 1] != '\n')
fputs("\n", out); fputs("\n", out);
fputs("%%EndResource\n", out); fputs("%%EndResource\n", out);
fclose(fp); fclose(fp);
} }
else else
{ {
/* /*
* Embed a Type1 font object in the PDF output... * Embed a Type1 font object in the PDF output...
 End of changes. 30 change blocks. 
40 lines changed or deleted 49 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)