Skip to content

Commit a3d56cd

Browse files
committed
Add conversion of dia source images for ebooks and pdfs
The conversion is done on the fly to generated best matched formats of images for each transformation. The conversion requires obviously `dia` to be installed. For PDF, additionally, `epstopdf` must be available.
1 parent 18578c6 commit a3d56cd

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

latex/makepdf

+6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ def figures(lang,&block)
1515
Dir["#$root/figures/18333*.png"].each do |file|
1616
cp(file, file.sub(/18333fig0(\d)0?(\d+)\-tn/, '\1.\2'))
1717
end
18+
Dir["#$root/#{lang}/figures-dia/*.dia"].each do |file|
19+
eps_dest= file.sub(/.*fig0(\d)0?(\d+).dia/, '\1.\2.eps')
20+
system("dia -t eps-pango -e #$root/figures/#{eps_dest} #{file}")
21+
system("epstopdf #$root/figures/#{eps_dest}")
22+
end
1823
cp(Dir["#$root/#{lang}/figures/*.png"],"#$root/figures")
1924
cp(Dir["#$root/#{lang}/figures/*.pdf"],"#$root/figures")
2025
block.call
@@ -23,6 +28,7 @@ def figures(lang,&block)
2328
rm(file.gsub(/18333fig0(\d)0?(\d+)\-tn/, '\1.\2'))
2429
end
2530
rm(Dir["#$root/figures/*.pdf"])
31+
rm(Dir["#$root/figures/*.eps"])
2632
end
2733
end
2834

makeebooks

+4-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ def figures(lang,&block)
2626
Dir["#{lang}/figures/*.png"].each do |file|
2727
cp(file,"figures")
2828
end
29-
29+
Dir["#{lang}/figures-dia/*.dia"].each do |file|
30+
png_dest= file.sub(/.*fig0(\d)0?(\d+).dia/, 'figures/\1.\2.png')
31+
system("dia -e #{png_dest} #{file}")
32+
end
3033
block.call
3134
ensure
3235
Dir["figures/18333*.png"].each do |file|

0 commit comments

Comments
 (0)