Mantis Issue Tracking for Scribus
· Hosting provided by Anduin.net / Øverby Consulting ·

Viewing Issue Advanced Details Jump to Notes ] View Simple ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0008380 [Scribus] PDF minor always 09-Aug-24 17:05 09-Oct-23 22:27
Reporter pspencer View Status public  
Assigned To jghali
Priority normal Resolution fixed Platform linux
Status closed   OS Fedora
Projection none   OS Version 10
ETA none Fixed in Version 1.3.6svn Product Version 1.3.5
  Target Version Product Build 1.3.5.1 Release
Summary 0008380: Embed EPS/PDF Files produces slightly wrong scale/position when file dimensions are not an integral number of points
Description When exporting to PDF and selecting the experimental "Embed PDF/EPS Files" option, any pdf or eps image that is not an integral number of Postscript points wide or high, or any render frame that produces such a pdf file, will render slightly smaller than it should be and with its bottom edge slightly higher.

The attached file talign.sla (with included files lt.pdf and lt.eps, also attached) illustrates the problem, and the attached file scribus-1.3.5.1-embedpdfscale.patch.

The talign.sla file contains a black rectangle whose top edge is exactly 1 inch above the bottom of the paper. It also contains a variety of image and render frames all based on the same source image, which is a hollow square exactly 2cm wide and 2cm high. Key here is that 2cm is not an integral number of points. The image frames all have their bottom edge exactly 1 inch above the bottom of the paper, so the bottoms of the images should all coincide exactly with the top of the rectangle.

The image on the left is in a 4cm x 8cm frame and scaled 200% x 400%, using the pdf source. The next one uses the eps source. The remaining images are in 2cm by 2cm frames and are all unscaled: first from a pdf source, then an eps source, then two render frames at differing DPI settings. The images are all identical (the pdf was created by running pdflatex on the render frame code; the eps was created by running pdftops on the pdf).

Scribus's gs resolution setting must be set to 300dpi prior to opening this document (to avoid running into bug 0008378).

When you open the document, you see that on screen all images line up properly with the rectangle. This is also true if you export to PDF without the
"embed PDF/EPS files" option checked. However, when exporting with the option checked, the top-left corners of the images are all in the right places but their bottoms are distinctly above the alignment rectangle.

The cause is in the PDF_EmbeddedPDF function in pdflib_core.cpp. It performs an assignment imgInfo.Width = pagesize.getWidth(), but the LHS is an integer while the RHS is a double, so if the page size is not an integral number of points wide, the image gets shrunk into a smaller width than it should have. This results in only a 1-point deviation on an unscaled image, but on an image scaled larger the deviation is correspondingly larger, as the images on the left in talign.sla indicate.

The attached patch fixes this by adjusting the scale factor slightly to account for the error in width. It also makes sure the width is at least 1 to avoid divide-by-zero errors.

One other aspect of the patch is that I was not sure why imgInfo.xa and ya
were being set to sx/sy: it looks to me from reading elsewhere in the code that xa/ya are supposed to be offsets not scale factors. Thinking this setting might be in error, I set them to zero in my patch, but if they are correct as stands then the patch can be adjusted to leave them as they were.
Steps To Reproduce See above
Additional Information
Tags No tags attached.
Attached Files ? file icon talign.sla [^] (21,528 bytes) 09-Aug-24 17:05
pdf file icon lt.pdf [^] (3,185 bytes) 09-Aug-24 17:06
? file icon lt.eps [^] (16,212 bytes) 09-Aug-24 17:06
? file icon scribus-1.3.5.1-embedpdfscale.patch [^] (1,825 bytes) 09-Aug-24 17:06

- Relationships

-  Notes
(0022414)
jghali (administrator)
09-Aug-25 00:30

Thanks for the patch. Regarding imgInfo.xa and ya, pdflib_core code shows that imgInfo.xa and imgInfo.ya are used mostly as scale factors. However my testings have not shown any difference whether they are set to sx/sy or 0.0. I consequently applied to xa/ya the same factor as sxa/sya

- Issue History
Date Modified Username Field Change
09-Aug-24 17:05 pspencer New Issue
09-Aug-24 17:05 pspencer File Added: talign.sla
09-Aug-24 17:06 pspencer File Added: lt.pdf
09-Aug-24 17:06 pspencer File Added: lt.eps
09-Aug-24 17:06 pspencer File Added: scribus-1.3.5.1-embedpdfscale.patch
09-Aug-25 00:30 jghali Note Added: 0022414
09-Aug-25 00:30 jghali Status new => resolved
09-Aug-25 00:30 jghali Fixed in Version => 1.3.6svn
09-Aug-25 00:30 jghali Resolution open => fixed
09-Aug-25 00:30 jghali Assigned To => jghali
09-Oct-23 22:27 christoph_s Status resolved => closed



Mantis 1.1.7[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker