~mdw
/
sgt
/
halibut
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove the error message `no text found in paragraph'. Aaron Brown
[sgt/halibut]
/
bk_pdf.c
diff --git
a/bk_pdf.c
b/bk_pdf.c
index
fa5262a
..
75d1f83
100644
(file)
--- a/
bk_pdf.c
+++ b/
bk_pdf.c
@@
-64,7
+64,7
@@
void pdf_backend(paragraph *sourceform, keywordlist *keywords,
filename = dupstr("output.pdf");
for (p = sourceform; p; p = p->next) {
filename = dupstr("output.pdf");
for (p = sourceform; p; p = p->next) {
- if (p->type == para_Config
&& p->parent
) {
+ if (p->type == para_Config) {
if (!ustricmp(p->keyword, L"pdf-filename")) {
sfree(filename);
filename = dupstr(adv(p->origkeyword));
if (!ustricmp(p->keyword, L"pdf-filename")) {
sfree(filename);
filename = dupstr(adv(p->origkeyword));
@@
-76,7
+76,10
@@
void pdf_backend(paragraph *sourceform, keywordlist *keywords,
olist.number = 1;
cat = new_object(&olist);
olist.number = 1;
cat = new_object(&olist);
- outlines = new_object(&olist);
+ if (doc->n_outline_elements > 0)
+ outlines = new_object(&olist);
+ else
+ outlines = NULL;
pages = new_object(&olist);
resources = new_object(&olist);
pages = new_object(&olist);
resources = new_object(&olist);
@@
-84,11
+87,16
@@
void pdf_backend(paragraph *sourceform, keywordlist *keywords,
* The catalogue just contains references to the outlines and
* pages objects.
*/
* The catalogue just contains references to the outlines and
* pages objects.
*/
- objtext(cat, "<<\n/Type /Catalog\n/Outlines ");
- objref(cat, outlines);
+ objtext(cat, "<<\n/Type /Catalog");
+ if (outlines) {
+ objtext(cat, "\n/Outlines ");
+ objref(cat, outlines);
+ }
objtext(cat, "\n/Pages ");
objref(cat, pages);
objtext(cat, "\n/Pages ");
objref(cat, pages);
- objtext(cat, "\n/PageMode /UseOutlines\n>>\n");
+ if (outlines)
+ objtext(cat, "\n/PageMode /UseOutlines");
+ objtext(cat, "\n>>\n");
/*
* Set up the resources dictionary, which mostly means
/*
* Set up the resources dictionary, which mostly means
@@
-142,7
+150,7
@@
void pdf_backend(paragraph *sourceform, keywordlist *keywords,
width = 0.0;
else
width = fe->font->widths[fe->indices[i]];
width = 0.0;
else
width = fe->font->widths[fe->indices[i]];
- sprintf(buf, "%g\n", 1000.0 * width /
4096.0
);
+ sprintf(buf, "%g\n", 1000.0 * width /
FUNITS_PER_PT
);
objtext(widths, buf);
}
objtext(widths, "]\n");
objtext(widths, buf);
}
objtext(widths, "]\n");
@@
-195,7
+203,8
@@
void pdf_backend(paragraph *sourceform, keywordlist *keywords,
* So we don't need a /Resources entry here.
*/
sprintf(buf, "/MediaBox [0 0 %g %g]\n",
* So we don't need a /Resources entry here.
*/
sprintf(buf, "/MediaBox [0 0 %g %g]\n",
- doc->paper_width / 4096.0, doc->paper_height / 4096.0);
+ doc->paper_width / FUNITS_PER_PT,
+ doc->paper_height / FUNITS_PER_PT);
objtext(opage, buf);
/*
objtext(opage, buf);
/*
@@
-212,8
+221,9
@@
void pdf_backend(paragraph *sourceform, keywordlist *keywords,
*/
for (r = page->first_rect; r; r = r->next) {
char buf[512];
*/
for (r = page->first_rect; r; r = r->next) {
char buf[512];
- sprintf(buf, "%g %g %g %g re f\n", r->x / 4096.0,
- r->y / 4096.0, r->w / 4096.0, r->h / 4096.0);
+ sprintf(buf, "%g %g %g %g re f\n",
+ r->x / FUNITS_PER_PT, r->y / FUNITS_PER_PT,
+ r->w / FUNITS_PER_PT, r->h / FUNITS_PER_PT);
objstream(cstr, buf);
}
objstream(cstr, buf);
}
@@
-257,10
+267,11
@@
void pdf_backend(paragraph *sourceform, keywordlist *keywords,
*/
if (lx < 0) {
sprintf(buf, "1 0 0 1 %g %g Tm ",
*/
if (lx < 0) {
sprintf(buf, "1 0 0 1 %g %g Tm ",
- frag->x/
4096.0, frag->y/4096.0
);
+ frag->x/
FUNITS_PER_PT, frag->y/FUNITS_PER_PT
);
} else {
sprintf(buf, "%g %g Td ",
} else {
sprintf(buf, "%g %g Td ",
- (frag->x - lx)/4096.0, (frag->y - ly)/4096.0);
+ (frag->x - lx)/FUNITS_PER_PT,
+ (frag->y - ly)/FUNITS_PER_PT);
}
objstream(cstr, buf);
lx = x = frag->x;
}
objstream(cstr, buf);
lx = x = frag->x;
@@
-283,7
+294,7
@@
void pdf_backend(paragraph *sourceform, keywordlist *keywords,
if (frag->x != x) {
sprintf(buf, "%g",
(x - frag->x) * 1000.0 /
if (frag->x != x) {
sprintf(buf, "%g",
(x - frag->x) * 1000.0 /
- (
4096.0
* frag->fontsize));
+ (
FUNITS_PER_PT
* frag->fontsize));
objstream(cstr, buf);
}
pdf_string(objstream, cstr, frag->text);
objstream(cstr, buf);
}
pdf_string(objstream, cstr, frag->text);
@@
-322,8
+333,8
@@
void pdf_backend(paragraph *sourceform, keywordlist *keywords,
objtext(annot, "<<\n/Type /Annot\n/Subtype /Link\n/Rect [");
sprintf(buf, "%g %g %g %g",
objtext(annot, "<<\n/Type /Annot\n/Subtype /Link\n/Rect [");
sprintf(buf, "%g %g %g %g",
- xr->lx /
4096.0, xr->by / 4096.0
,
- xr->rx /
4096.0, xr->ty / 4096.0
);
+ xr->lx /
FUNITS_PER_PT, xr->by / FUNITS_PER_PT
,
+ xr->rx /
FUNITS_PER_PT, xr->ty / FUNITS_PER_PT
);
objtext(annot, buf);
objtext(annot, "]\n/Border [0 0 0]\n");
objtext(annot, buf);
objtext(annot, "]\n/Border [0 0 0]\n");
@@
-349,7
+360,7
@@
void pdf_backend(paragraph *sourceform, keywordlist *keywords,
/*
* Set up the outlines dictionary.
*/
/*
* Set up the outlines dictionary.
*/
- {
+
if (outlines)
{
int topcount;
char buf[80];
int topcount;
char buf[80];
@@
-456,7
+467,7
@@
void pdf_backend(paragraph *sourceform, keywordlist *keywords,
static object *new_object(objlist *list)
{
static object *new_object(objlist *list)
{
- object *obj =
mk
new(object);
+ object *obj =
s
new(object);
obj->list = list;
obj->list = list;