summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
authorHan The Thanh <hanthethanh@gmail.com>2011-03-01 01:43:47 +0000
committerHan The Thanh <hanthethanh@gmail.com>2011-03-01 01:43:47 +0000
commit6dcd44939d4765af4a24a7969f1fef796b6c0b15 (patch)
treea888c1d2336a88543f76d126ba8966c4d76a71b4 /Build
parent81af3bd308254a1148792ac692106f2aa8d1a46d (diff)
fix for page group (bug report #4326)
git-svn-id: svn://tug.org/texlive/trunk@21555 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r--Build/source/texk/web2c/pdftexdir/pdftex-common.h2
-rw-r--r--Build/source/texk/web2c/pdftexdir/pdftex.web16
-rw-r--r--Build/source/texk/web2c/pdftexdir/pdftoepdf.cc45
-rw-r--r--Build/source/texk/web2c/pdftexdir/writeimg.c2
-rw-r--r--Build/source/texk/web2c/pdftexdir/writepng.c8
5 files changed, 57 insertions, 16 deletions
diff --git a/Build/source/texk/web2c/pdftexdir/pdftex-common.h b/Build/source/texk/web2c/pdftexdir/pdftex-common.h
index 58625d0b20e..4b942899f58 100644
--- a/Build/source/texk/web2c/pdftexdir/pdftex-common.h
+++ b/Build/source/texk/web2c/pdftexdir/pdftex-common.h
@@ -48,6 +48,7 @@ extern integer pdfbufsize;
extern boolean pdfosmode;
extern eightbits pdflastbyte;
extern integer fixedinclusioncopyfont;
+extern integer pdfpagegroupval;
/* pdftexcoerce.h - generated from pdftex.web */
extern integer pdfnewobjnum(void);
@@ -114,5 +115,6 @@ extern int epdf_selected_page;
extern int epdf_num_pages;
extern int epdf_page_box;
extern void *epdf_doc;
+extern int epdf_has_page_group;
#endif /* PDFTEX_COMMON_H */
diff --git a/Build/source/texk/web2c/pdftexdir/pdftex.web b/Build/source/texk/web2c/pdftexdir/pdftex.web
index d96a1ff0750..776aa446212 100644
--- a/Build/source/texk/web2c/pdftexdir/pdftex.web
+++ b/Build/source/texk/web2c/pdftexdir/pdftex.web
@@ -15224,7 +15224,6 @@ zip_write_state := no_zip;
pdf_minor_version_written := false;
fixed_pdfoutput_set := false;
fixed_pdf_draftmode_set := false;
-pdf_page_group_val := -1;
@ @p
@@ -18743,6 +18742,7 @@ fix_pdfoutput;
temp_ptr:=p;
prepare_mag;
pdf_last_resources := pdf_new_objnum;
+pdf_page_group_val := 0;
@<Reset resource lists@>;
if not shipping_page then begin
pdf_xform_width := width(p);
@@ -18969,7 +18969,6 @@ if pdf_page_group_val > 0 then begin
pdf_print("/Group ");
pdf_print_int(pdf_page_group_val);
pdf_print_ln(" 0 R");
- pdf_page_group_val := -1;
end;
@<Generate array of annotations or beads in page@>;
pdf_end_dict
@@ -36027,9 +36026,9 @@ begin
pdf_append_list(pdf_ximage_objnum(p))(pdf_ximage_list);
if not is_pdf_image(image) then begin
if is_png_image(image) then begin
- groupref := image_group_ref (image);
- if (groupref>0) and (pdf_page_group_val<1) then
- pdf_page_group_val := groupref;
+ groupref := image_group_ref(image);
+ if (groupref > 0) and (pdf_page_group_val = 0) then
+ pdf_page_group_val := groupref;
end;
pdf_print_real(ext_xn_over_d(pdf_width(p),
ten_pow[6], one_hundred_bp), 4);
@@ -36041,7 +36040,11 @@ begin
pdf_print_bp(pdf_y(cur_v));
end
else begin
- if pdf_page_group_val<1 then pdf_page_group_val := image_group_ref (image);
+ {for pdf images we generate the page group object number here}
+ groupref := image_group_ref(image); {this is only a flag whether page group is present}
+ if (groupref > 0) and (pdf_page_group_val = 0) then begin
+ pdf_page_group_val := pdf_new_objnum;
+ end;
pdf_print_real(ext_xn_over_d(pdf_width(p),
ten_pow[6], img_w), 6);
pdf_print(" 0 0 ");
@@ -36064,7 +36067,6 @@ begin
pdf_print_ln("Q");
end;
-
function gap_amount(p: pointer; cur_pos: scaled): scaled; {find the gap between
the position of the current snap node |p| and the nearest point on the grid}
var snap_unit, stretch_amount, shrink_amount: scaled;
diff --git a/Build/source/texk/web2c/pdftexdir/pdftoepdf.cc b/Build/source/texk/web2c/pdftexdir/pdftoepdf.cc
index 22f01978ab3..0f8261b878b 100644
--- a/Build/source/texk/web2c/pdftexdir/pdftoepdf.cc
+++ b/Build/source/texk/web2c/pdftexdir/pdftoepdf.cc
@@ -141,8 +141,6 @@ struct UsedEncoding {
static InObj *inObjList;
static UsedEncoding *encodingList;
static GBool isInit = gFalse;
-static bool groupIsIndirect;
-static PdfObject lastGroup;
// --------------------------------------------------------------------
// Maintain list of open embedded PDF files
@@ -809,6 +807,12 @@ read_pdf_info(char *image_name, char *page_name, int page_num,
if (epdf_rotate < 0)
epdf_rotate += 360;
+ // page group
+ if (page->getGroup() != NULL)
+ epdf_has_page_group = 1; // only flag that page group is present;
+ // the actual object number will be
+ // generated in pdftex.web
+
pdf_doc->xref = pdf_doc->doc->getXRef();
return page_num;
}
@@ -823,6 +827,8 @@ void write_epdf(void)
Ref *pageRef;
Dict *pageDict;
PdfObject contents, obj1, obj2, pageObj, dictObj;
+ PdfObject groupDict;
+ bool writeSepGroup = false;
Object info;
char *key;
char s[256];
@@ -830,12 +836,12 @@ void write_epdf(void)
int rotate;
double scale[6] = { 0, 0, 0, 0, 0, 0 };
bool writematrix = false;
- static char *pageDictKeys[] = {
- "Group",
+ static char *pageDictKeys[] = {
"LastModified",
"Metadata",
"PieceInfo",
"SeparationInfo",
+// "Group",
// "Resources",
NULL
};
@@ -920,7 +926,7 @@ void write_epdf(void)
if (!dictObj->isNull() && !dictObj->isRef())
pdftex_warn("PDF inclusion: /Metadata must be indirect object");
- // copy selected items in Page dictionary except Resources
+ // copy selected items in Page dictionary except Resources & Group
for (i = 0; pageDictKeys[i] != NULL; i++) {
pageDict->lookupNF(pageDictKeys[i], &dictObj);
if (!dictObj->isNull()) {
@@ -928,6 +934,23 @@ void write_epdf(void)
pdf_printf("/%s ", pageDictKeys[i]);
copyObject(&dictObj); // preserves indirection
}
+ }
+
+ // handle page group
+ pageDict->lookupNF("Group", &dictObj);
+ if (!dictObj->isNull()) {
+ if (pdfpagegroupval == 0) {
+ // another pdf with page group was included earlier on the same page;
+ // copy the Group entry as is
+ pdf_newline();
+ pdf_puts("/Group ");
+ copyObject(&dictObj);
+ } else {
+ // write Group dict as a separate object, since the Page dict also refers to it
+ writeSepGroup = true;
+ initDictFromDict(groupDict, page->getGroup());
+ pdf_printf("/Group %d 0 R\n", pdfpagegroupval);
+ }
}
// write the Resources dictionary
@@ -1008,10 +1031,22 @@ void write_epdf(void)
pdfbeginstream();
pdfendstream();
}
+
// write out all indirect objects
writeRefs();
+
// write out all used encodings (and delete list)
writeEncodings();
+
+ // write the Group dict if needed
+ if (writeSepGroup) {
+ pdfbeginobj(pdfpagegroupval, 2);
+ copyObject(&groupDict);
+ pdfendobj();
+ pdfpagegroupval = 0; // only the 1st included pdf on a page gets its
+ // Group included in the Page dict
+ }
+
// save object list, xref
pdf_doc->inObjList = inObjList;
pdf_doc->xref = xref;
diff --git a/Build/source/texk/web2c/pdftexdir/writeimg.c b/Build/source/texk/web2c/pdftexdir/writeimg.c
index 4a1e5d65ac1..3f5b4b1b32e 100644
--- a/Build/source/texk/web2c/pdftexdir/writeimg.c
+++ b/Build/source/texk/web2c/pdftexdir/writeimg.c
@@ -41,6 +41,7 @@ int epdf_selected_page;
int epdf_num_pages;
int epdf_page_box;
void *epdf_doc;
+int epdf_has_page_group;
static integer new_image_entry(void)
{
@@ -322,6 +323,7 @@ integer readimage(strnumber s, integer page_num, strnumber page_name,
pdf_ptr(img)->orig_y = bp2int(epdf_orig_y);
pdf_ptr(img)->selected_page = page_num;
pdf_ptr(img)->doc = epdf_doc;
+ img_group_ref(img) = epdf_has_page_group;
break;
case IMAGE_TYPE_PNG:
img_pages(img) = 1;
diff --git a/Build/source/texk/web2c/pdftexdir/writepng.c b/Build/source/texk/web2c/pdftexdir/writepng.c
index 481d4bb6461..523396f0160 100644
--- a/Build/source/texk/web2c/pdftexdir/writepng.c
+++ b/Build/source/texk/web2c/pdftexdir/writepng.c
@@ -34,7 +34,7 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#define png_rowbytes(N) png_get_rowbytes(png_ptr(N), png_info(N))
#define png_width(N) png_get_image_width(png_ptr(N), png_info(N))
-static int transparent_page_group = -1;
+static int transparent_page_group = 0;
void read_png_info(integer img)
{
@@ -106,10 +106,10 @@ void read_png_info(integer img)
/* png with alpha channel in device colours; we have to add a Page
* Group to make Adobe happy, so we have to create a dummy group object
*/
- if (transparent_page_group < 1) {
+ if (transparent_page_group == 0) {
transparent_page_group = pdfnewobjnum();
}
- if (pdfpagegroupval < 1) {
+ if (pdfpagegroupval == 0) {
pdfpagegroupval = transparent_page_group;
}
img_group_ref(img) = pdfpagegroupval;
@@ -510,7 +510,7 @@ static boolean transparent_page_group_was_written = false;
static void write_additional_png_objects(void)
{
if (last_png_needs_page_group) {
- if (!transparent_page_group_was_written && transparent_page_group > 1) {
+ if (!transparent_page_group_was_written && transparent_page_group > 0) {
// create new group object
transparent_page_group_was_written = true;
pdfbeginobj(transparent_page_group, 2);