Commit Diff


commit - 684a3c707589742d0776267e54d2bde5015cb62c
commit + e0350ca3bb91fb9ff9a91e048ab68ce059cd7f66
blob - 07edfd51ed5a272b0951e621c72f98eb4a5fd7ff
blob + df1ba9ef34971e75abc9f44ab9410f97200c1ea8
--- pdf.c
+++ pdf.c
@@ -2174,9 +2174,6 @@ text_extract(struct Env *aux, const char *outfn, const
 
 	curr = aux->txthead;
 	for (int i = 0; i < aux->ntextobjs; i++) {
-		if (outfn2)
-			fwrite((const void *)curr->tstr->text, (int) curr->tstr->nchars, 1, stream2);
-
 		tt_text = curr->tstr->tobj;
 		for (int j = 0; j < tt_text->seq->used; j++) {
 			struct textstr *tstr = NULL;
@@ -2196,14 +2193,16 @@ text_extract(struct Env *aux, const char *outfn, const
 			}
 			assert(tstr != NULL);
 
-			if (outfn) {
+			if (outfn2) {
 				Fontinfo_T *ft = lookup_font(&txte->node->ts, aux);
 				if (ft)
-					pp_fontinfo(stream, &txte->node->ts, ft);
+					pp_fontinfo(stream2, &txte->node->ts, ft);
 				else
-					fputs("\nMissing Font Info!!\n", stream);
+					fputs("\nMissing Font Info!!\n", stream2);
+				fwrite(tstr->text, 1, (size_t)tstr->nchars, stream2);
+			}
+			if (outfn)
 				fwrite(tstr->text, 1, (size_t)tstr->nchars, stream);
-			}
 		}
 
 		curr = curr->next;