summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2022-05-29 15:33:09 -0600
committerGitHub <noreply@github.com>2022-05-29 15:33:09 -0600
commit87ed094d9bde86861fb82b6146db95dba0c99d15 (patch)
tree7d0b86d9f374c4e7fc9e3785c57b8f8c1c0a1820 /spec
parent283afa601050893ca02d41742f1308ab2ecc6632 (diff)
resolves #2215 interpret width of SVG correctly when width is defined in file using px units (PR #2218)
Diffstat (limited to 'spec')
-rw-r--r--spec/image_spec.rb24
-rw-r--r--spec/reference/image-svg-px-data.pdf186
-rw-r--r--spec/reference/image-svg-px-width.pdf167
3 files changed, 377 insertions, 0 deletions
diff --git a/spec/image_spec.rb b/spec/image_spec.rb
index 060bd53b..90113db4 100644
--- a/spec/image_spec.rb
+++ b/spec/image_spec.rb
@@ -422,6 +422,30 @@ describe 'Asciidoctor::PDF::Converter - Image' do
(expect text[0][:y]).to eql 276.036
end
+ it 'should compute width correctly when SVG defines width in px units', visual: true do
+ [true, false].each do |from_theme|
+ to_file = with_content_spacer 200, 200, 'px' do |spacer_path|
+ pdf_theme = {}
+ pdf_theme[:image_width] = '200px' if from_theme
+ to_pdf_file <<~EOS, %(image-svg-px-width-from-#{from_theme ? 'theme' : 'file'}.svg), pdf_theme: pdf_theme
+
+ image::#{spacer_path}[]
+
+ image::#{spacer_path}[pdfwidth=200px]
+ EOS
+ end
+
+ (expect to_file).to visually_match 'image-svg-px-width.pdf'
+ end
+ end
+
+ it 'should treat value with px units at pt in SVG data', visual: true do
+ to_file = to_pdf_file <<~'EOS', 'image-svg-px-data.pdf'
+ image::red-blue-squares.svg[pdfwidth=25%]
+ EOS
+ (expect to_file).to visually_match 'image-svg-px-data.pdf'
+ end
+
it 'should not allow inline image to affect the cursor position of the following paragraph' do
pdf = to_pdf <<~'EOS', analyze: true
before
diff --git a/spec/reference/image-svg-px-data.pdf b/spec/reference/image-svg-px-data.pdf
new file mode 100644
index 00000000..20551c16
--- /dev/null
+++ b/spec/reference/image-svg-px-data.pdf
@@ -0,0 +1,186 @@
+%PDF-1.4
+%ÿÿÿÿ
+1 0 obj
+<< /Title (Untitled)
+/Creator (Asciidoctor PDF 2.0.5, based on Prawn 2.4.0)
+/Producer (Asciidoctor PDF 2.0.5, based on Prawn 2.4.0)
+/ModDate (D:20220529141223-06'00')
+/CreationDate (D:20220529141223-06'00')
+>>
+endobj
+2 0 obj
+<< /Type /Catalog
+/Pages 3 0 R
+/Outlines 9 0 R
+/PageLabels 11 0 R
+/PageMode /UseOutlines
+/OpenAction [7 0 R /FitH 841.89]
+/ViewerPreferences << /DisplayDocTitle true
+>>
+/Names 13 0 R
+>>
+endobj
+3 0 obj
+<< /Type /Pages
+/Count 1
+/Kids [7 0 R]
+>>
+endobj
+4 0 obj
+<< /Length 2
+>>
+stream
+q
+
+endstream
+endobj
+5 0 obj
+<< /Type /Page
+/Parent 3 0 R
+/MediaBox [0 0 595.28 841.89]
+/CropBox [0 0 595.28 841.89]
+/BleedBox [0 0 595.28 841.89]
+/TrimBox [0 0 595.28 841.89]
+/ArtBox [0 0 595.28 841.89]
+/Contents 4 0 R
+/Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
+>>
+>>
+endobj
+6 0 obj
+<< /Length 881
+>>
+stream
+q
+/DeviceRGB cs
+0.0 0.0 0.0 scn
+/DeviceRGB CS
+0.0 0.0 0.0 SCN
+q
+48.24 681.19 m
+172.94 681.19 l
+172.94 805.89 l
+48.24 805.89 l
+h
+W n
+0.0 0.0 0.0 scn
+0.40226 0.0 0.0 0.40226 28.83507 481.71425 cm
+1.0 0.0 0.0 1.0 0.0 -0.0 cm
+q
+1.0 0.0 0.0 scn
+0.0 0.0 0.0 SCN
+2.0 w
+68.24 805.89 m
+278.24 805.89 l
+289.28569 805.89 298.24 796.93569 298.24 785.89 c
+298.24 575.89 l
+298.24 564.84431 289.28569 555.89 278.24 555.89 c
+68.24 555.89 l
+57.19431 555.89 48.24 564.84431 48.24 575.89 c
+48.24 785.89 l
+48.24 796.93569 57.19431 805.89 68.24 805.89 c
+h
+B
+Q
+q
+q
+/Tr1 gs
+0.0 0.0 1.0 scn
+0.0 0.0 0.0 SCN
+2.0 w
+148.24 745.89 m
+318.24 745.89 l
+340.33139 745.89 358.24 727.98139 358.24 705.89 c
+358.24 535.89 l
+358.24 513.79861 340.33139 495.89 318.24 495.89 c
+148.24 495.89 l
+126.14861 495.89 108.24 513.79861 108.24 535.89 c
+108.24 705.89 l
+108.24 727.98139 126.14861 745.89 148.24 745.89 c
+h
+B
+Q
+Q
+Q
+Q
+
+endstream
+endobj
+7 0 obj
+<< /Type /Page
+/Parent 3 0 R
+/MediaBox [0 0 595.28 841.89]
+/CropBox [0 0 595.28 841.89]
+/BleedBox [0 0 595.28 841.89]
+/TrimBox [0 0 595.28 841.89]
+/ArtBox [0 0 595.28 841.89]
+/Contents 6 0 R
+/Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
+/Font << >>
+/ExtGState << /Tr1 8 0 R
+>>
+>>
+>>
+endobj
+8 0 obj
+<< /Type /ExtGState
+/CA 1
+/ca 0.7
+>>
+endobj
+9 0 obj
+<< /Type /Outlines
+/Count 1
+/First 10 0 R
+/Last 10 0 R
+>>
+endobj
+10 0 obj
+<< /Title <feff0055006e007400690074006c00650064>
+/Parent 9 0 R
+/Count 0
+/Dest [7 0 R /XYZ 0 841.89 null]
+>>
+endobj
+11 0 obj
+<< /Nums [0 << /P (1)
+>>]
+>>
+endobj
+12 0 obj
+[7 0 R /XYZ 0 841.89 null]
+endobj
+13 0 obj
+<< /Type /Names
+/Dests 14 0 R
+>>
+endobj
+14 0 obj
+<< /Names [(__anchor-top) 12 0 R]
+>>
+endobj
+xref
+0 15
+0000000000 65535 f
+0000000015 00000 n
+0000000240 00000 n
+0000000441 00000 n
+0000000498 00000 n
+0000000549 00000 n
+0000000821 00000 n
+0000001753 00000 n
+0000002065 00000 n
+0000002117 00000 n
+0000002190 00000 n
+0000002314 00000 n
+0000002359 00000 n
+0000002402 00000 n
+0000002451 00000 n
+trailer
+<< /Size 15
+/Root 2 0 R
+/Info 1 0 R
+>>
+startxref
+2504
+%%EOF
diff --git a/spec/reference/image-svg-px-width.pdf b/spec/reference/image-svg-px-width.pdf
new file mode 100644
index 00000000..c656f566
--- /dev/null
+++ b/spec/reference/image-svg-px-width.pdf
@@ -0,0 +1,167 @@
+%PDF-1.4
+%ÿÿÿÿ
+1 0 obj
+<< /Title (Untitled)
+/Creator (Asciidoctor PDF 2.0.5, based on Prawn 2.4.0)
+/Producer (Asciidoctor PDF 2.0.5, based on Prawn 2.4.0)
+/ModDate (D:20220528032919-06'00')
+/CreationDate (D:20220528032919-06'00')
+>>
+endobj
+2 0 obj
+<< /Type /Catalog
+/Pages 3 0 R
+/Outlines 8 0 R
+/PageLabels 10 0 R
+/PageMode /UseOutlines
+/OpenAction [7 0 R /FitH 841.89]
+/ViewerPreferences << /DisplayDocTitle true
+>>
+/Names 12 0 R
+>>
+endobj
+3 0 obj
+<< /Type /Pages
+/Count 1
+/Kids [7 0 R]
+>>
+endobj
+4 0 obj
+<< /Length 2
+>>
+stream
+q
+
+endstream
+endobj
+5 0 obj
+<< /Type /Page
+/Parent 3 0 R
+/MediaBox [0 0 595.28 841.89]
+/CropBox [0 0 595.28 841.89]
+/BleedBox [0 0 595.28 841.89]
+/TrimBox [0 0 595.28 841.89]
+/ArtBox [0 0 595.28 841.89]
+/Contents 4 0 R
+/Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
+>>
+>>
+endobj
+6 0 obj
+<< /Length 474
+>>
+stream
+q
+/DeviceRGB cs
+0.0 0.0 0.0 scn
+/DeviceRGB CS
+0.0 0.0 0.0 SCN
+q
+48.24 655.89 m
+198.24 655.89 l
+198.24 805.89 l
+48.24 805.89 l
+h
+W n
+0.0 0.0 0.0 scn
+0.75 0.0 0.0 0.75 12.06 201.4725 cm
+1.0 0.0 0.0 1.0 0.0 0.0 cm
+q
+q
+0.6 0.6 0.6 scn
+48.24 605.89 200.0 200.0 re
+f
+Q
+Q
+Q
+q
+48.24 493.89 m
+198.24 493.89 l
+198.24 643.89 l
+48.24 643.89 l
+h
+W n
+0.0 0.0 0.0 scn
+0.75 0.0 0.0 0.75 12.06 160.9725 cm
+1.0 0.0 0.0 1.0 0.0 0.0 cm
+q
+q
+0.6 0.6 0.6 scn
+48.24 443.89 200.0 200.0 re
+f
+Q
+Q
+Q
+Q
+
+endstream
+endobj
+7 0 obj
+<< /Type /Page
+/Parent 3 0 R
+/MediaBox [0 0 595.28 841.89]
+/CropBox [0 0 595.28 841.89]
+/BleedBox [0 0 595.28 841.89]
+/TrimBox [0 0 595.28 841.89]
+/ArtBox [0 0 595.28 841.89]
+/Contents 6 0 R
+/Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
+/Font << >>
+>>
+>>
+endobj
+8 0 obj
+<< /Type /Outlines
+/Count 1
+/First 9 0 R
+/Last 9 0 R
+>>
+endobj
+9 0 obj
+<< /Title <feff0055006e007400690074006c00650064>
+/Parent 8 0 R
+/Count 0
+/Dest [7 0 R /XYZ 0 841.89 null]
+>>
+endobj
+10 0 obj
+<< /Nums [0 << /P (1)
+>>]
+>>
+endobj
+11 0 obj
+[7 0 R /XYZ 0 841.89 null]
+endobj
+12 0 obj
+<< /Type /Names
+/Dests 13 0 R
+>>
+endobj
+13 0 obj
+<< /Names [(__anchor-top) 11 0 R]
+>>
+endobj
+xref
+0 14
+0000000000 65535 f
+0000000015 00000 n
+0000000240 00000 n
+0000000441 00000 n
+0000000498 00000 n
+0000000549 00000 n
+0000000821 00000 n
+0000001346 00000 n
+0000001630 00000 n
+0000001701 00000 n
+0000001824 00000 n
+0000001869 00000 n
+0000001912 00000 n
+0000001961 00000 n
+trailer
+<< /Size 14
+/Root 2 0 R
+/Info 1 0 R
+>>
+startxref
+2014
+%%EOF