View Single Post
Old 09-24-2013, 01:32 AM   #2
Tex2002ans
Wizard
Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.
 
Posts: 2,306
Karma: 13057279
Join Date: Jul 2012
Device: Kobo Forma, Nook
Step 3: Inkscape

When you open Inkscape, you should be greeted with a blank screen. Press File - Open. Go to where you saved your LibreOffice Math PDF files, and open the first one:

Click image for larger version

Name:	Step3.OpenFile.png
Views:	711
Size:	13.6 KB
ID:	112008

You will be greeted with this screen. Just press Ok:

Click image for larger version

Name:	Step3.OpenDialog.png
Views:	711
Size:	8.1 KB
ID:	112007

You can now see the PDF that LibreOffice created open in Inkscape.

Click image for larger version

Name:	Step3.JustOpened.png
Views:	725
Size:	35.7 KB
ID:	112005

Now you have to click on the formula, and arrows should appear around it:

Click image for larger version

Name:	Step3.FormulaArrows.png
Views:	717
Size:	36.3 KB
ID:	112003

Side Note: IF you are greeted with the entire thing surrounded by arrows. Press Object - Ungroup. This should split it into clickable sections. It should now be possible to press on the formula.

Click image for larger version

Name:	Step3.FormulaEntire.png
Views:	705
Size:	36.4 KB
ID:	112004 Click image for larger version

Name:	Step3Note.Ungroup.png
Views:	701
Size:	43.9 KB
ID:	112009

Make sure just the formula is selected and has arrows around it, and press File - Export Bitmap...

Click image for larger version

Name:	Step3.ExportBitmap.png
Views:	653
Size:	38.2 KB
ID:	112001

The Export Bitmap dialog should pop up. This is where you Inkscape what resolution the final PNG will be, and where to save the PNG.

IMPORTANT: Make sure along the top, that the "Selection" button is chosen. Selection means it will create a PNG of everything that is inside the "surrounding arrows".

Click image for larger version

Name:	Step3.ExportBitmapDialog.png
Views:	737
Size:	9.8 KB
ID:	112002

Personally, I have settled on "320" as a good DPI for formulas. This determines how large the letters/numbers will be in the final PNG (and thus, the EPUB). Feel free to raise/lower this to suit your liking.

You can also manually tell Inkscape which X/Y resolution you want created by changing the "Width" and "Height".

Side Note: I recommend keeping the DPI the same throughout an entire book, so when formula PNGs are scaled to their max width, they will all have the same size font.

After setting the DPI (or Width/Height), press Export. This will now save the file to the location you selected.

Side Note: Inkscape auto-names the file g#####.png. This is quite annoying. Make sure you change to a better filename so you can keep the images organized.

Repeat Step 3 for all formulas until you have 320 DPI PNGs generated for all Formulas.

Step 4: GIMP

Open GIMP, and open the PNG formulas created from Inkscape.

Click image for larger version

Name:	Step4.Open.png
Views:	733
Size:	38.6 KB
ID:	112014

Press Layer - Transparency - Remove Alpha Channel:

Click image for larger version

Name:	Step4.RemoveAlpha.png
Views:	769
Size:	47.2 KB
ID:	112015

This should result in the transparent background turning white:

Click image for larger version

Name:	Step4.RemovedTransparency.png
Views:	823
Size:	39.0 KB
ID:	112016

Since there is no color in this image, you want to change the mode from RGB to Grayscale.

Note: Going from RGB (nearly every color under the sun) to Grayscale will cut down the filesize DRAMATICALLY. "Grayscale" means it will be 256 shades of gray.

Press Image - Mode - Grayscale.

Click image for larger version

Name:	Step4.Grayscale.png
Views:	726
Size:	44.1 KB
ID:	112013

Now we have to save the PNG again. Press File - Export...

Click image for larger version

Name:	Step4.ExportMenu.png
Views:	704
Size:	35.4 KB
ID:	112011

Choose where you save your file and what to name it.
IMPORTANT: Make sure that ".png" is at the end of the filename. This will tell GIMP to Export this as a PNG.

Click image for larger version

Name:	Step4.ExportDialog.png
Views:	690
Size:	14.6 KB
ID:	112010

Uncheck all the boxes in the dialog box, and make sure Compression is set to max. Press Export.

Click image for larger version

Name:	Step4.ExportPNGDialog.png
Views:	699
Size:	6.1 KB
ID:	112012

Repeat Step 4 for all Formulas.

Step 5: Insert into the EPUB

That is all! Now you can insert the PNG into the EPUB just like you would any other image.

I have attached a sample EPUB full of the real world text, with two XHTML files: "Old" and "New". The "Old" has PNG snapshots taken from the PDF, while "New" has the new PNGs generated by this tutorial.

Feel free to compare them both for yourself.

Side Note: I have left an Extra Credit image (the formula at the top of Page 182: See Step -1). See if you can generate a new and improved version using the Tutorial above!

If you need a hint with the Libre Math "code" for the Extra Credit:

Spoiler:
"Barter terms of trade" = {W_a over n_a} div {{W_b times R} over m_b} = W_a over {W_b times R} times {m_b over n_a}"."
Attached Files
File Type: epub FormulaPNGTutorial.epub (118.0 KB, 597 views)

Last edited by Tex2002ans; 09-24-2013 at 02:34 AM.
Tex2002ans is offline   Reply With Quote