Commit dc20cdcd authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_corporate_identity: possible to add margin to pdf

parent 3eed4e6b
......@@ -18,6 +18,7 @@ Creates the Book content.
book_source_person_title python: options.get('book_source_person_title');
book_content python: options.get('book_content');
book_format python: options.get('book_format');
margin_15mm python: options.get('margin_15mm');
book_rendering_fix python: options.get('book_rendering_fix');">
<!DOCTYPE html>
<html tal:attributes="class python: ''.join(['ci-', book_theme, ' ci-', book_language])">
......@@ -37,18 +38,34 @@ Creates the Book content.
</tal:block>
</tal:block>
</head>
<body class="ci-book ci-book-content">
<tal:block metal:use-macro="context/WebPage_createBookContent/macros/book_content" />
<script type="text/javascript" src="template_js/highlight.js"></script>
<tal:block tal:condition="python: len(book_report_js_list) > 0">
<tal:block tal:repeat="js_src book_report_js_list">
<script type="text/javascript" tal:attributes="src js_src"></script>
<tal:block tal:condition="python: margin_15mm">
<body class="ci-book ci-book-content margin-15mm">
<tal:block metal:use-macro="context/WebPage_createBookContent/macros/book_content" />
<script type="text/javascript" src="template_js/highlight.js"></script>
<tal:block tal:condition="python: len(book_report_js_list) > 0">
<tal:block tal:repeat="js_src book_report_js_list">
<script type="text/javascript" tal:attributes="src js_src"></script>
</tal:block>
</tal:block>
</tal:block>
<tal:block tal:condition="python: book_format == 'pdf'">
<tal:block tal:content="structure python: book_rendering_fix"></tal:block>
</tal:block>
</body>
<tal:block tal:condition="python: book_format == 'pdf'">
<tal:block tal:content="structure python: book_rendering_fix"></tal:block>
</tal:block>
</body>
</tal:block>
<tal:block tal:condition="python: not margin_15mm">
<body class="ci-book ci-book-content">
<tal:block metal:use-macro="context/WebPage_createBookContent/macros/book_content" />
<script type="text/javascript" src="template_js/highlight.js"></script>
<tal:block tal:condition="python: len(book_report_js_list) > 0">
<tal:block tal:repeat="js_src book_report_js_list">
<script type="text/javascript" tal:attributes="src js_src"></script>
</tal:block>
</tal:block>
<tal:block tal:condition="python: book_format == 'pdf'">
<tal:block tal:content="structure python: book_rendering_fix"></tal:block>
</tal:block>
</body>
</tal:block>
</html>
</tal:block>
......
......@@ -13,6 +13,7 @@ Creates the Book cover.
book_template_css_url python: options.get('book_template_css_url');
book_short_title python: options.get('book_short_title');
book_description python: options.get('book_description');
margin_15mm python: options.get('margin_15mm');
book_source_person_title python: options.get('book_source_person_title');">
<!DOCTYPE html>
<html tal:attributes="class python: ''.join(['ci-', book_theme, ' ci-', book_language])">
......@@ -26,9 +27,16 @@ Creates the Book cover.
<link rel="stylesheet" tal:attributes="href book_theme_css_url" />
<link rel="stylesheet" tal:attributes="href book_template_css_url" />
</head>
<body class="ci-book">
<tal:block metal:use-macro="context/WebPage_createBookCover/macros/book_cover" />
</body>
<tal:block tal:condition="python: margin_15mm">
<body class="ci-book margin-15mm">
<tal:block metal:use-macro="context/WebPage_createBookCover/macros/book_cover" />
</body>
</tal:block>
<tal:block tal:condition="python: not margin_15mm">
<body class="ci-book">
<tal:block metal:use-macro="context/WebPage_createBookCover/macros/book_cover" />
</body>
</tal:block>
</html>
</tal:block>
......
......@@ -12,6 +12,7 @@ Creates the Book footer.
book_theme_css_url python: options.get('book_theme_css_url');
book_template_css_url python: options.get('book_template_css_url');
book_full_reference python: options.get('book_full_reference');
margin_15mm python: options.get('margin_15mm');
book_source_organisation_title python: options.get('book_source_organisation_title');">
<!DOCTYPE html>
<html tal:attributes="class python: ''.join(['ci-', book_theme, ' ci-', book_language])">
......@@ -25,9 +26,16 @@ Creates the Book footer.
<link rel="stylesheet" tal:attributes="href book_theme_css_url" />
<link rel="stylesheet" tal:attributes="href book_template_css_url" />
</head>
<body class="ci-book" onload="setPlaceholdersWithUrlParameters()">
<tal:block metal:use-macro="context/WebPage_createBookFooter/macros/book_footer" />
</body>
<tal:block tal:condition="python: margin_15mm">
<body class="ci-book margin-15mm" onload="setPlaceholdersWithUrlParameters()">
<tal:block metal:use-macro="context/WebPage_createBookFooter/macros/book_footer" />
</body>
</tal:block>
<tal:block tal:condition="python: not margin_15mm">
<body class="ci-book" onload="setPlaceholdersWithUrlParameters()">
<tal:block metal:use-macro="context/WebPage_createBookFooter/macros/book_footer" />
</body>
</tal:block>
</html>
</tal:block>
......
......@@ -17,6 +17,7 @@ Creates the Book header.
book_reference python: options.get('book_reference');
book_revision python: options.get('book_revision');
book_version python: options.get('book_version');
margin_15mm python: options.get('margin_15mm');
book_short_date python: options.get('book_short_date');">
<!DOCTYPE html>
<html tal:attributes="class python: ''.join(['ci-', book_theme, ' ci-', book_language])">
......@@ -50,9 +51,16 @@ Creates the Book header.
}
</script>
</head>
<body class="ci-book" onload="setPlaceholdersWithUrlParameters()">
<tal:block metal:use-macro="context/WebPage_createBookHeader/macros/book_header" />
</body>
<tal:block tal:condition="python: margin_15mm">
<body class="ci-book margin-15mm" onload="setPlaceholdersWithUrlParameters()">
<tal:block metal:use-macro="context/WebPage_createBookHeader/macros/book_header" />
</body>
</tal:block>
<tal:block tal:condition="python: not margin_15mm">
<body class="ci-book" onload="setPlaceholdersWithUrlParameters()">
<tal:block metal:use-macro="context/WebPage_createBookHeader/macros/book_header" />
</body>
</tal:block>
</html>
</tal:block>
......
......@@ -14,6 +14,7 @@ Creates the Book sections (version, authors, etc).
book_include_history python: options.get('book_include_history');
book_signature_list python: options.get('book_signature_list');
book_distribution_list python: options.get('book_distribution_list');
margin_15mm python: options.get('margin_15mm');
book_version_list python: options.get('book_version_list');">
<!DOCTYPE html>
<html tal:attributes="class python: ''.join(['ci-', book_theme, ' ci-', book_language])">
......@@ -27,9 +28,16 @@ Creates the Book sections (version, authors, etc).
<link rel="stylesheet" tal:attributes="href book_theme_css_url" />
<link rel="stylesheet" tal:attributes="href book_template_css_url" />
</head>
<body class="ci-book" tal:condition="python: book_include_history != 0">
<tal:block metal:use-macro="context/WebPage_createBookTableOfHistory/macros/book_history" />
</body>
<tal:block tal:condition="python: margin_15mm">
<body class="ci-book margin-15mm" tal:condition="python: book_include_history != 0">
<tal:block metal:use-macro="context/WebPage_createBookTableOfHistory/macros/book_history" />
</body>
</tal:block>
<tal:block tal:condition="python: not margin_15mm">
<body class="ci-book" tal:condition="python: book_include_history != 0">
<tal:block metal:use-macro="context/WebPage_createBookTableOfHistory/macros/book_history" />
</body>
</tal:block>
</html>
</tal:block>
......
......@@ -51,6 +51,7 @@ return context.WebPage_viewAsBook(
include_reference_table=include_reference_table,
include_linked_content=include_linked_content,
include_report_content=include_report_content,
margin15mm = margin15mm,
format=format,
**kw
)
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>format=None, include_content_table=None,include_history_table= None,include_reference_table=None,include_linked_content=None,include_report_content=None,document_download=None,batch_mode=False,display_svg=None,document_save=None,transformation=None,override_document_description=None,override_document_short_title=None,override_document_title=None,override_document_version=None,override_logo_reference=None,override_source_organisation_title=None,override_source_person_title=None,override_document_reference=None, **kw</string> </value>
<value> <string>format=None, include_content_table=None,include_history_table= None,include_reference_table=None,include_linked_content=None,include_report_content=None,margin15mm=None,document_download=None,batch_mode=False,display_svg=None,document_save=None,transformation=None,override_document_description=None,override_document_short_title=None,override_document_title=None,override_document_version=None,override_logo_reference=None,override_source_organisation_title=None,override_source_person_title=None,override_document_reference=None, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -56,6 +56,7 @@ book_include_history_table = int(kw.get('include_history_table') or 0)
book_include_reference_table = int(kw.get('include_reference_table') or 0)
book_include_linked_content = int(kw.get('include_linked_content') or 0)
book_include_report_content = int(kw.get('include_report_content') or 0)
margin_15mm = int(kw.get('margin15mm') or 0)
override_source_person_title = kw.get('override_source_person_title')
override_source_organisation_title = kw.get("override_source_organisation_title")
......@@ -90,7 +91,7 @@ if isinstance(book_content, unicode):
book_content = book_content.encode("UTF-8")
# backcompat
#book_history_section_list = re.findall('<section*?>.+?</section>', book_content, re.S)
book_history_section_list = re.findall('<section*?>.+?</section>', book_content, re.S)
# override for tests
if override_batch_mode:
......@@ -194,7 +195,7 @@ if book_include_reference_table:
#if len(book_history_section_list) > 0:
# book_content = book_content.replace(book_history_section_list[-1], (book_history_section_list[-1] + book_references.encode('UTF-8').strip()))
#else:
book_references = book.Base_unescape(book_references)
# book_content = book_content.replace("${WebPage_insertTableOfReferences}", book_references.encode('UTF-8').strip())
book_content = book_content.replace("${WebPage_insertTableOfReferences}", book_references.encode('UTF-8').strip())
else:
book_content = book_content.replace("${WebPage_insertTableOfReferences}", blank)
......@@ -205,7 +206,8 @@ if book_include_content_table:
book_translated_toc_title = translateText("Table of Contents")
if book_format == "pdf":
book_table_of_content = book.WebPage_createBookXslTableOfContent(
book_toc_title=book_translated_toc_title
book_toc_title=book_translated_toc_title,
margin_15mm = margin_15mm
).encode('UTF-8').strip()
elif book_format == "html":
book_content, book_table_of_content = book.WebPage_createTableOfContent(
......@@ -284,6 +286,7 @@ if book_format == "pdf":
book_template_css_url=book_theme.get("template_css_url"),
book_short_title=book_short_title,
book_description=book_description,
margin_15mm = margin_15mm,
book_source_person_title=book_source.get("contributor_title_string").split(",")
)
......@@ -299,6 +302,7 @@ if book_format == "pdf":
book_include_history=book_include_history_table,
book_signature_list=book_signature_list,
book_version_list=book_version_list,
margin_15mm = margin_15mm,
book_distribution_list=book_distribution_list,
)
......@@ -312,10 +316,12 @@ if book_format == "pdf":
book_theme_css_font_list=book_theme.get("theme_css_font_list"),
book_theme_css_url=book_theme.get("theme_css_url"),
book_template_css_url=book_theme.get("template_css_url"),
margin_15mm = margin_15mm,
book_report_css_list=book_report_css_list,
book_report_js_list=book_report_js_list,
book_content=book_content,
)
book_head = book.WebPage_createBookHeader(
book_theme=book_theme.get("theme"),
book_title=book_title,
......@@ -329,6 +335,7 @@ if book_format == "pdf":
book_reference=book_reference,
book_revision=book_revision,
book_version=book_version,
margin_15mm = margin_15mm,
book_short_date=book_short_date
)
......@@ -342,6 +349,7 @@ if book_format == "pdf":
book_theme_logo_alt=book_theme.get("theme_logo_description"),
book_template_css_url=book_theme.get("template_css_url"),
book_full_reference=book_full_reference,
margin_15mm = margin_15mm,
book_source_organisation_title=book_source.get("organisation_title") or blank,
)
......@@ -362,11 +370,16 @@ if book_format == "pdf":
xsl_style_sheet_data = book_table_of_content
embedded_html_data = book.Base_convertHtmlToSingleFile(book_content, allow_script=True)
footer_embedded_html_data = book.Base_convertHtmlToSingleFile(book_foot, allow_script=True)
if margin_15mm:
margin_top = 50
margin_bottom = 25
else:
margin_top = 40
margin_bottom = 20
pdf_file = book.Base_cloudoooDocumentConvert(embedded_html_data, "html", "pdf", conversion_kw=dict(
encoding="utf8",
margin_top=40,
margin_bottom=20,
margin_top=margin_top,
margin_bottom=margin_bottom,
toc=True if book_include_content_table else False,
before_toc_data_list=before_toc_data_list,
xsl_style_sheet_data=b64encode(xsl_style_sheet_data),
......
......@@ -85,6 +85,7 @@
<string>display_svg</string>
<string>document_save</string>
<string>portal_skin</string>
<string>margin15mm</string>
</list>
</value>
</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="CheckBoxField" module="Products.Formulator.StandardFields"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>margin15mm</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
<item>
<key> <string>required_not_found</string> </key>
<value> <string>This field is mandatory.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Margin 15mm</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
.margin-15mm{
margin-left:15mm;
margin-right:15mm;
}
/* === font-size === */
.ci-book h1 + p::first-letter {
font-size: 21.1667mm; /* 60pt; */ /* 80px; */
......@@ -93,6 +98,16 @@
font-size: 6.35mm; /* 18pt; */ /* 24px; */
}
.ci-book p em,
.ci-book li em,
.ci-book p i,
.ci-book li i {
font-style: italic;
}
.ci-book table tbody td strong {
font-weight: bold;
}
/* === color === */
/* .ci-book a:not([href*="#"]), */
.ci-book a:not([id]),
......@@ -541,7 +556,8 @@ NOTE: logos will disappear in wkhtmltopdf if they go beyond the available space
list-style: none;
list-style-position: inside;
}
.ci-book ul li {
.ci-book ul li,
.ci-book ol li {
padding-left: 16px;
text-indent: -24px;
}
......@@ -705,6 +721,7 @@ NOTE: logos will disappear in wkhtmltopdf if they go beyond the available space
.ci-book .ci-book-table-of-content li ol li {
margin: 0;
}
.ci-book .ci-book-table-of-content a {
text-decoration:none;
color: black;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment