Skip to content

v2.7-2.8 incorrectly render dashed line in FPDF/FPDI-created files. #13211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kanuay opened this issue Apr 9, 2021 · 4 comments · Fixed by #14536
Closed

v2.7-2.8 incorrectly render dashed line in FPDF/FPDI-created files. #13211

kanuay opened this issue Apr 9, 2021 · 4 comments · Fixed by #14536
Assignees

Comments

@kanuay
Copy link

kanuay commented Apr 9, 2021

Attach (recommended) or Link to PDF file here:
https://kanuay.com/pdf/report/test.pdf

Configuration:

  • Web browser and its version: Firefox Dev 88.0 & Safari iOS 14
  • Operating system and its version: Windows 10 Latest & iOS 14
  • PDF.js version: 2.7-2.8 (Both self-hosted and Firefox built-in)

Steps to reproduce the problem:
Lot of my file created by FPDF/FPDI
Open these files with PDF.js v2.7 or v2.8
All the fraction lines, radical signs, especially dashed lines are rendered incorrectly.

PDF js Problem Report 210409

@timvandermeij
Copy link
Contributor

If I recall correctly we did make some changes to the minimum line width code, although I'm not sure it's related to this.

@Snuffleupagus
Copy link
Collaborator

Snuffleupagus commented Apr 9, 2021

It seems that this regressed in two steps unfortunately, according to git bisect:

  1. The rendering of the figure first broke in
    b3dccd66ab6f895aa4a721082fdac05277c6818b is the first bad commit
    commit b3dccd66ab6f895aa4a721082fdac05277c6818b
    Author: Calixte Denizet <[email protected]>
    Date:   Mon Jan 4 14:25:30 2021 +0100
    
        Enforce line width to be at least 1px after applied transform
         * add a comment to explain how minimal linewidth is computed.
         * when context.linewidth < 1 after transform, firefox and chrome
           don't render in the same way (issue #12810).
         * set lineWidth to 1 after transform and before stroking
           - aims fix issue #12295
           - a pixel can be transformed into a rectangle with both heights < 1.
             A single rescale leads to a rectangle with dim equals to 1 and
             the other to something greater than 1.
         * change the way to render rectangle with null dimensions:
           - right now we rely on the lineWidth set before "re" but
             it can be set after "re" and before "S" and in this case the rendering
             will be wrong.
           - render such rectangles as a single line.
    
    
  2. The math symbols then became too bold in
    9754216c600a571f3cd10f819a88269b98ab2616 is the first bad commit
    commit 9754216c600a571f3cd10f819a88269b98ab2616
    Author: Calixte Denizet <[email protected]>
    Date:   Sat Jan 16 14:05:37 2021 +0100
    
        Fix zoom issue with too thin lines
         - aims to fix issue #12868: apply zoom factor to linewidth after setting it
           to 1.
         - only apply 1px-width when required
         - the sign of getSinglePixelWidth is used to know if 1px-width is required
    
    
    

/cc @calixteman

@calixteman
Copy link
Contributor

I wonder if the correct approach would be to play with the transform to get a final correct rectangle (pixel after transform) instead of playing with the linewidth itself.

@calixteman
Copy link
Contributor

I tried to fix the transformMatrix instead of fixing the line width and it seems to be the correct way to deal with this issue.
I'll submit a PR asap.

calixteman added a commit to calixteman/pdf.js that referenced this issue Feb 5, 2022
 - it aims to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1753075 and issue mozilla#13211;
 - previously we were trying to adjust lineWidth to have something correct after the current transform is applied but this approach was not correct because finally the pixel is rescaled with the same factors in both directions.
  And sometimes those factors must be different (see bug 1753075).
 - So the idea of this patch is to apply a scale matrix to the current transform just before setting lineWidth and stroking. This scale matrix is computed in order to ensure that after transform, a pixel will have its two thickness greater than 1.
calixteman added a commit to calixteman/pdf.js that referenced this issue Feb 5, 2022
 - it aims to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1753075 and issue mozilla#13211;
 - previously we were trying to adjust lineWidth to have something correct after the current transform is applied but this approach was not correct because finally the pixel is rescaled with the same factors in both directions.
  And sometimes those factors must be different (see bug 1753075).
 - So the idea of this patch is to apply a scale matrix to the current transform just before setting lineWidth and stroking. This scale matrix is computed in order to ensure that after transform, a pixel will have its two thickness greater than 1.
calixteman added a commit to calixteman/pdf.js that referenced this issue Feb 7, 2022
 - it aims to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1753075 and issue mozilla#13211;
 - previously we were trying to adjust lineWidth to have something correct after the current transform is applied but this approach was not correct because finally the pixel is rescaled with the same factors in both directions.
  And sometimes those factors must be different (see bug 1753075).
 - So the idea of this patch is to apply a scale matrix to the current transform just before setting lineWidth and stroking. This scale matrix is computed in order to ensure that after transform, a pixel will have its two thickness greater than 1.
calixteman added a commit to calixteman/pdf.js that referenced this issue Feb 7, 2022
 - it aims to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1753075 and issue mozilla#13211;
 - previously we were trying to adjust lineWidth to have something correct after the current transform is applied but this approach was not correct because finally the pixel is rescaled with the same factors in both directions.
  And sometimes those factors must be different (see bug 1753075).
 - So the idea of this patch is to apply a scale matrix to the current transform just before setting lineWidth and stroking. This scale matrix is computed in order to ensure that after transform, a pixel will have its two thickness greater than 1.
calixteman added a commit to calixteman/pdf.js that referenced this issue Feb 13, 2022
 - it aims to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1753075 and issue mozilla#13211;
 - previously we were trying to adjust lineWidth to have something correct after the current transform is applied but this approach was not correct because finally the pixel is rescaled with the same factors in both directions.
  And sometimes those factors must be different (see bug 1753075).
 - So the idea of this patch is to apply a scale matrix to the current transform just before setting lineWidth and stroking. This scale matrix is computed in order to ensure that after transform, a pixel will have its two thickness greater than 1.
calixteman added a commit to calixteman/pdf.js that referenced this issue Feb 14, 2022
 - it aims to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1753075 and issue mozilla#13211;
 - previously we were trying to adjust lineWidth to have something correct after the current transform is applied but this approach was not correct because finally the pixel is rescaled with the same factors in both directions.
  And sometimes those factors must be different (see bug 1753075).
 - So the idea of this patch is to apply a scale matrix to the current transform just before setting lineWidth and stroking. This scale matrix is computed in order to ensure that after transform, a pixel will have its two thickness greater than 1.
calixteman added a commit to calixteman/pdf.js that referenced this issue Feb 14, 2022
 - it aims to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1753075 and issue mozilla#13211;
 - previously we were trying to adjust lineWidth to have something correct after the current transform is applied but this approach was not correct because finally the pixel is rescaled with the same factors in both directions.
  And sometimes those factors must be different (see bug 1753075).
 - So the idea of this patch is to apply a scale matrix to the current transform just before setting lineWidth and stroking. This scale matrix is computed in order to ensure that after transform, a pixel will have its two thickness greater than 1.
calixteman added a commit to calixteman/pdf.js that referenced this issue Feb 19, 2022
…743245)

 - it aims to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1753075, https://bugzilla.mozilla.org/show_bug.cgi?id=1743245, issue mozilla#13211 and issue mozilla#14521;
 - previously we were trying to adjust lineWidth to have something correct after the current transform is applied but this approach was not correct because finally the pixel is rescaled with the same factors in both directions.
  And sometimes those factors must be different (see bug 1753075).
 - So the idea of this patch is to apply a scale matrix to the current transform just before setting lineWidth and stroking. This scale matrix is computed in order to ensure that after transform, a pixel will have its two thickness greater than 1.
calixteman added a commit to calixteman/pdf.js that referenced this issue Feb 24, 2022
…743245, bug 1710019)

 - it aims to fix:
   - https://bugzilla.mozilla.org/show_bug.cgi?id=1753075;
   - https://bugzilla.mozilla.org/show_bug.cgi?id=1743245;
   - https://bugzilla.mozilla.org/show_bug.cgi?id=1710019;
   - issue mozilla#13211;
   - issue mozilla#14521.
 - previously we were trying to adjust lineWidth to have something correct after the current transform is applied but this approach was not correct because finally the pixel is rescaled with the same factors in both directions.
  And sometimes those factors must be different (see bug 1753075).
 - So the idea of this patch is to apply a scale matrix to the current transform just before setting lineWidth and stroking. This scale matrix is computed in order to ensure that after transform, a pixel will have its two thickness greater than 1.
calixteman added a commit to calixteman/pdf.js that referenced this issue Feb 25, 2022
…743245, bug 1710019)

 - it aims to fix:
   - https://bugzilla.mozilla.org/show_bug.cgi?id=1753075;
   - https://bugzilla.mozilla.org/show_bug.cgi?id=1743245;
   - https://bugzilla.mozilla.org/show_bug.cgi?id=1710019;
   - issue mozilla#13211;
   - issue mozilla#14521.
 - previously we were trying to adjust lineWidth to have something correct after the current transform is applied but this approach was not correct because finally the pixel is rescaled with the same factors in both directions.
  And sometimes those factors must be different (see bug 1753075).
 - So the idea of this patch is to apply a scale matrix to the current transform just before setting lineWidth and stroking. This scale matrix is computed in order to ensure that after transform, a pixel will have its two thickness greater than 1.
bh213 pushed a commit to bh213/pdf.js that referenced this issue Jun 3, 2022
…743245, bug 1710019)

 - it aims to fix:
   - https://bugzilla.mozilla.org/show_bug.cgi?id=1753075;
   - https://bugzilla.mozilla.org/show_bug.cgi?id=1743245;
   - https://bugzilla.mozilla.org/show_bug.cgi?id=1710019;
   - issue mozilla#13211;
   - issue mozilla#14521.
 - previously we were trying to adjust lineWidth to have something correct after the current transform is applied but this approach was not correct because finally the pixel is rescaled with the same factors in both directions.
  And sometimes those factors must be different (see bug 1753075).
 - So the idea of this patch is to apply a scale matrix to the current transform just before setting lineWidth and stroking. This scale matrix is computed in order to ensure that after transform, a pixel will have its two thickness greater than 1.
rousek pushed a commit to signosoft/pdf.js that referenced this issue Aug 10, 2022
…743245, bug 1710019)

 - it aims to fix:
   - https://bugzilla.mozilla.org/show_bug.cgi?id=1753075;
   - https://bugzilla.mozilla.org/show_bug.cgi?id=1743245;
   - https://bugzilla.mozilla.org/show_bug.cgi?id=1710019;
   - issue mozilla#13211;
   - issue mozilla#14521.
 - previously we were trying to adjust lineWidth to have something correct after the current transform is applied but this approach was not correct because finally the pixel is rescaled with the same factors in both directions.
  And sometimes those factors must be different (see bug 1753075).
 - So the idea of this patch is to apply a scale matrix to the current transform just before setting lineWidth and stroking. This scale matrix is computed in order to ensure that after transform, a pixel will have its two thickness greater than 1.
@marco-c marco-c moved this to Closed in PDF.js quality Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Closed
4 participants