summaryrefslogtreecommitdiff
path: root/gs/base/gdevpdfu.c
diff options
context:
space:
mode:
authorKen Sharp <ken.sharp@artifex.com>2012-07-16 13:00:46 +0100
committerKen Sharp <ken.sharp@artifex.com>2012-07-16 13:01:39 +0100
commitb49d3c75a70cbdcdb2214f22ad1a1f62f1bb90fc (patch)
treee1f40229776982e51c9236c34205c419682e276f /gs/base/gdevpdfu.c
parent479b462ffa4663a71a88d185aaf7cc5c4f5d1903 (diff)
downloadghostpdl-b49d3c75a70cbdcdb2214f22ad1a1f62f1bb90fc.tar.gz
ps2write - create document %%BoundingBox from teh individual page Bounding boxes
Bug #693181 The document level BoundingBox is supposed to be the intersection of the boundingbox of all the pages, whereas in fact it is the device media size. Now we create the document BoundingBox by taking largest dimensions from all the pages in the output. NB the BoundingBox for each page is given from the media request, so this is not a true BoundingBox anyway, but at least it is better then before.
Diffstat (limited to 'gs/base/gdevpdfu.c')
-rw-r--r--gs/base/gdevpdfu.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/gs/base/gdevpdfu.c b/gs/base/gdevpdfu.c
index 8518349ad..d4e9432ab 100644
--- a/gs/base/gdevpdfu.c
+++ b/gs/base/gdevpdfu.c
@@ -402,11 +402,31 @@ int ps2write_dsc_header(gx_device_pdf * pdev, int pages)
char cre_date_time[41];
int code, status, cre_date_time_len;
char BBox[256];
- int width = (int)(pdev->width * 72.0 / pdev->HWResolution[0] + 0.5);
- int height = (int)(pdev->height * 72.0 / pdev->HWResolution[1] + 0.5);
stream_write(s, (byte *)"%!PS-Adobe-3.0\n", 15);
- sprintf(BBox, "%%%%BoundingBox: 0 0 %d %d\n", width, height);
+ /* We need to calculate the document BoundingBox which is a 'high water'
+ * mark derived from the BoundingBox of all the individual pages.
+ */
+ {
+ int pagecount = 1;
+ int urx=0, ury=0, j;
+
+ for (j = 0; j < NUM_RESOURCE_CHAINS; ++j) {
+ pdf_resource_t *pres = pdev->resources[resourcePage].chains[j];
+
+ for (; pres != 0; pres = pres->next)
+ if ((!pres->named || pdev->ForOPDFRead)
+ && !pres->object->written) {
+ pdf_page_t *page = &pdev->pages[pagecount - 1];
+ if ((int)ceil(page->MediaBox.x) > urx)
+ urx = page->MediaBox.x;
+ if ((int)ceil(page->MediaBox.y) > urx)
+ ury = page->MediaBox.y;
+ pagecount++;
+ }
+ }
+ sprintf(BBox, "%%%%BoundingBox: 0 0 %d %d\n", urx, ury);
+ }
stream_write(s, (byte *)BBox, strlen(BBox));
cre_date_time_len = pdf_get_docinfo_item(pdev, "/CreationDate", cre_date_time, sizeof(cre_date_time) - 1);
cre_date_time[cre_date_time_len] = 0;