One of the problems of postscript files generated by "draw" is that
it is not proper "embedded postscript file", aka "eps".
When trying to include such image files in latex document, there are
huge padding around image.
The problem is caused by "BoundingBox". We have "BoundingBox" in
generated PS file, but almost all utilities such as "ps2pdf",
"epstopdf" only recognize "BoundingBox" in the header comment section.
FriCAS generates "BoundingBox" in the middle of the PS file.
Following patch is a proof of concept to fix this issue.
After this patch, I can use "epstopdf" to convert PS file to
properly cropped pdf file.
I think for a proper fix, a better way is to split "headerps"
into two and add a "boundingbox" patch in between?
- Qian
diff --git a/src/graph/Gdraws/Gfun.c b/src/graph/Gdraws/Gfun.c
index 808822aa..027e1dbe 100644
--- a/src/graph/Gdraws/Gfun.c
+++ b/src/graph/Gdraws/Gfun.c
@@ -98,6 +98,11 @@ PSCreateFile(
return (psError);
}
else {
+ fprintf(ofp, "%%!PS-Adobe-2.0\n");
+ XWindowAttributes vwInfo;
+ XGetWindowAttributes(dsply, vw, &vwInfo);
+ /* Write a Bounding Box for psfig etc. */
+ fprintf(fp, "%%%%BoundingBox: 0 0 %d %d\n", vwInfo.height,
vwInfo.width);
i = 1;
while (i < psDrawNo) { /* loops through each file/procedure */
if (psData[i].flag) { /* if set, procedure/file is used */
@@ -226,10 +231,6 @@ Gdraws_setDimension(
fprintf(fp, "\t%d\t%d\t%d\tsetDim\n", twInfo.height - vwInfo.height,
vwInfo.height, vwInfo.width);
- /* Write a Bounding Box for psfig etc. */
-
- fprintf(fp, "%%%%BoundingBox: 0 0 %d %d\n", vwInfo.height, vwInfo.width);
-
fprintf(fp, "\tmaxX maxY\t0 0\trectangle\tclip\t%% set clip path\n\n");
return (fclose(fp));
}
diff --git a/src/graph/Gdraws/ps_files/
header.ps
b/src/graph/Gdraws/ps_files/
header.ps
index e945bec4..037914ac 100644
--- a/src/graph/Gdraws/ps_files/
header.ps
+++ b/src/graph/Gdraws/ps_files/
header.ps
@@ -1,4 +1,3 @@
-%!PS-Adobe-2.0
%%DocumentFonts: Times-Roman
%%Creator: FriCAS
%%CreationDate: today