Changing the size of an ePub book - epub

Does anyone know how I set the width and height for an epub book?
I've noticed that there are books with different sizes and I am trying to work out how they do this.
I've been reading the spec but as yet I can't work it out?
Is it just done in CSS or is there part of the spec I need to use?

Two ways:
Viewport attribute:
You should set it on the head of each html:
< head >
...
< meta content="width=566, height=623" name="viewport" / >
...
< / head >
This method is specially usedful for Fixed Layout eBooks.
Set margins on the CSS file for the main div
Regards,
AM

Found the answer here: http://wiki.mobileread.com/wiki/Fixed_layout_ePub
For iBooks you need to a a special xml document in the META-INF folder called com.apple.ibooks.display-options.xml with the following contents:
<?xml version="1.0" encoding="UTF-8"?>
<display_options>
<platform name="*">
<option name="fixed-layout">true</option>
</platform>
</display_options>
Then you can set <meta name="viewport" content="width=1000, height=1000"></meta> in each xhtml file or body {width: 709px; height: 652px; } in css.
For other eBook readers you are meant to be able to add:
<meta name="rendition:layout">pre-paginated</meta>
<meta name="rendition:orientation">landscape</meta>
in the package definition but I have not tested this. More about that can be found in the spec http://www.idpf.org/epub/fxl/
Edit: you also need to set the same in your body so they all match. If you want full screen images you also need to set the height and width to be the same on these too with absolute positioning (top: 0, left: 0 as well).

Related

WKWebView: scalesPageToFit behaviour without Java Script

How to get scalesPageToFit behaviour for HTML content displayed in a WKWebView without using JavaScript? (disabling JS is a requirement for in our case).
Sorry for not posting any code, but I have no idea how I could achieve this. All solutions I know and all I found are based on JS. Example.
I already add <meta name="viewport" content="width=device-width, initial-scale=1.0"/> to the HTML if it does not exist yet, but at least images are often displayed way too big.
All images are provided to WKWebView by a WKURLSchemeHandler.
Please put
<meta name="viewport" content="initial-scale=1.0" />
inside your <head> tag.
extension String {
mutating func fitContentToScreen() {
self.add(prefix: "<header><meta name='viewport' content='width=device-width, user-scalable=yes'></header>")
}
}
You add this header line to html content to fit screen.

Twitter card: summary vs summary_large_image

I read these 2 doc pages: summary and
summary-card-with-large-image, but I don't really see the difference.
Example:
<meta name="twitter:card" content="summary" /> <!-- or summary_large_image -->
<meta name="twitter:title" content="Small Island Developing States Photo Submission" />
<meta name="twitter:image" content="https://farm6.staticflickr.com/5510/14338202952_93595258ff_z.jpg" />
What is the actual difference betwen both at the end? The rendering looks identical:
You're quite right and I'll make a note to update these documentation pages. A summary card usually has a small image on the left of the text in the timeline - this variance in the docs may be the result of using embedded Tweets. Both examples in the documentation show what I'd expect a summary card with large image to render as.
As suggested by #AndyPiper, this is probably a documentation problem. Here is the result of a content="summary", screenshot from Twitter in Chrome browser (desktop):

Apply cache manifest only in production mode

I've added a "cache.manifest" in my application (this works perfectly) and since then, it's very hard to debug since I must always clear the cache or modify the cache.manifest version.
I tryied to load the manifest with "HttpContext.Current.IsDebuggingEnabled" condition:
<!DOCTYPE HTML>
#if (HttpContext.Current.IsDebuggingEnabled)
{
<html>
}
else
{
<html manifest="/cache.manifest">
}
This doesn't works and Visual Studio gives me 3 errors:
The block is missing a closing } character
html element is not closed
Can't have more than 1 html element.
Does anyone have an idea ?
Thanks !
Based on the answer from "sav931", I finally found the solution:
<html #(HttpContext.Current.IsDebuggingEnabled ? "" : "manifest=cache.manifest" )>
No need to add an app setting key in the web.config, since there's already a function for that. (HttpContext.Current.IsDebuggingEnabled)
Also, I removed the manfest attribut completely when developping.
Try to add key in the web.config like:
<add key="devMode" value="true"/>
and now add this in your View:
<head #(Convert.ToBoolean(System.Web.Configuration.WebConfigurationManager.AppSettings["devMode"]) ? "manifest=/cache.manifest" : "manifest=devMode.manifest")>
by adding a manifest file name that not exist it will disable the cache...

classic ASP with non-english languages special characters as boxes

I am currently working on Classic ASP for one of my project. For non English languages I am getting boxes instead of special characters. I am rendering using UTF-8 but sometimes the characters goes to boxes. It comes back normal when I click refresh sometimes.
I followed all the steps below but i still get this problem
XML:
<xml version="1.0" encoding="UTF-8">
HTML:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
content-type: text/html; charset=utf-8
Am I missing anything here? Thanks.
Add this to your page:
Response.CodePage = 65001
Response.CharSet = "utf-8"
It should display all correctly now.
Hope that helps
It's amazing BUT nobody gives a complete answer on what to do this PROPERLY... I hope this help somebody like me, because it was so hard to find the whole picture...
---------------- PREVIOUS CONSIDERATIONS --------------
FIRST, make sure IIS IS NOT replacing the Code Page... Go to IIS, click the Website, open ASP module, on Behavior it should be >> Code Page = 0
SECOND, The file itself should be checked, YES! the file... open your file explorer on windows (my computer), go to the folder where the files of your website are, take for example "default.asp", right click >> open with >> notepad THEN click on File >> Save As... IN THE DIALOG at the bottom says "Encoding", make sure it has UTF-8, otherwise you will have to add the
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> in every page (including server side includes), which is not correct.
---------------- CORRECT STRUCTURE OF THE PAGE --------------
<%#LANGUAGE="VBSCRIPT" CODEPAGE="65001"%><%
Response.AddHeader "Content-Type", "text/html;charset=utf-8"
%><!-- #include virtual="/conexion.asp" -->
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="utf-8">
</head>
<body>
áéíóú
</body>
</html>
It should work fine now with QueryStrings, Database and regular HTML... uffff

$sf_response->addStyleSheet() dosen't work in SF 1.4?

Does anyone know how to add stylesheets in a template with Symfony 1.4 ?
I have tried everything I can think of, from modifying frontend/config/view.yml to modifying the template itself - bothing works.
I have seen from my searches, that other people have had the same problem. There seems to be a clash of sorts between using include_stylesheets and use_stylesheets - however this is not documented anywhere AFAIK.
Edit:
Ok I think I got it now. You should add include_stylesheets() into the head section of your layout file:
<html>
<head>
<title>This is the title</title>
<?php include_stylesheets() ?>
</head>
<body>
<!-- ... -->
Then in your template file, you use use_stylesheet() to add a particular stylesheet for this template:
<?php use_stylesheet('/path/to/stylesheet.css') ?>
From the API documentation:
include_stylesheets()
Prints <link> tags for all stylesheets configured in view.yml or added to the response object.
use_stylesheet()
Adds a stylesheet to the response object.
Same for Javascript.
According to the API documentation it should still work in 1.4, sfWebResponse still has this method:
addStylesheet ($file, $position, $options)
$file The stylesheet file
$position Position
$options Stylesheet options
Adds a stylesheet to the current web response.
At least the method exists.
What exactly is the problem? Do you get an error if you want to call that method or is the stylesheet just not added?
http://www.symfony-project.org/tutorial/1_4/en/upgrade#removal_of_the_common_filter
As of 1.4 your javascripts and stylesheets are no longer automatically injected into your head tag. Instead, you need to include the following in your layout where you'd like them to be placed:
<?php include_javascripts() ?>
<?php include_stylesheets() ?>
and just in case your post title wasn't a typo you'll want to use addStylesheet('...') off of the response:
$sf_response->addStylesheet('main');
$sf_context->getResponse()->addStylesheet('style.css')
$sf_context->getResponse()->addJavascript('script.js')

Resources