Skip to content

Commit

Permalink
PDFBOX-3330: add new template for documentation; auto generate toc fo…
Browse files Browse the repository at this point in the history
…r documentation
  • Loading branch information
msahyoun committed Mar 29, 2018
1 parent 386f163 commit 37123aa
Show file tree
Hide file tree
Showing 10 changed files with 235 additions and 55 deletions.
16 changes: 1 addition & 15 deletions content/2.0/commandline.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ license: Licensed to the Apache Software Foundation (ASF) under one
specific language governing permissions and limitations
under the License.

layout: default
layout: documentation
title: Command-Line Tools
---

Expand All @@ -27,20 +27,6 @@ PDFBox comes with a series of command-line utilities. They are available as stan
See the [Dependencies](/2.0/dependencies.html) page for instructions on how to set your classpath in order to run
PDFBox tools as Java applications.

**Table of Contents**
- [Decrypt](#decrypt)
- [Encrypt](#encrypt)
- [ExtractImages](#extractimages)
- [ExtractText](#extracttext)
- [OverlayPDF](#overlaypdf)
- [PDFDebugger](#pdfdebugger)
- [PDFMerger](#pdfmerger)
- [PDFSplit](#pdfsplit)
- [PDFToImage](#pdftoimage)
- [PrintPDF](#printpdf)
- [TextToPDF](#texttopdf)
- [WriteDecodedDoc](#writedecodeddoc)

## Decrypt ##

This application will decrypt a PDF document.
Expand Down
2 changes: 1 addition & 1 deletion content/2.0/cookbook/encryption.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ license: Licensed to the Apache Software Foundation (ASF) under one
specific language governing permissions and limitations
under the License.

layout: default
layout: documentation
title: Cookbook - Encrypting a File
---

Expand Down
2 changes: 1 addition & 1 deletion content/2.0/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ license: Licensed to the Apache Software Foundation (ASF) under one
specific language governing permissions and limitations
under the License.

layout: default
layout: documentation
title: Dependencies
---

Expand Down
2 changes: 1 addition & 1 deletion content/2.0/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ license: Licensed to the Apache Software Foundation (ASF) under one
specific language governing permissions and limitations
under the License.

layout: default
layout: documentation
title: Examples
---

Expand Down
31 changes: 1 addition & 30 deletions content/2.0/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,41 +16,12 @@ license: Licensed to the Apache Software Foundation (ASF) under one
specific language governing permissions and limitations
under the License.

layout: default
layout: documentation
title: Frequently Asked Questions (FAQ)
---

# Frequently Asked Questions

### General Questions

- [I am getting the below Log4J warning message, how do I remove it?](#log4j)
- [Is PDFBox thread safe?](#threadsafe)
- [Why do I get a "Warning: You did not close the PDF Document"?](#notclosed)

### Font Handling

- [I'm getting java.lang.IllegalArgumentException: ... is not available in this font's encoding: WinAnsiEncoding](#fontencoding)

### PDF Creation

- [I'm creating a PDF but my page is empty. Why?](#emptypage)

### Text Extraction

- [Why does the extracted text appear in the wrong sequence?](#textorder)
- [How come I am not getting any text from the PDF document?](#notext)
- [How come I am getting gibberish(G38G43G36G51G5) when extracting text?](#gibberish)
- [What does "java.io.IOException: Can't handle font width" mean?](#fontwidth)
- [Why do I get "You do not have permission to extract text" on some documents?](#permission)
- [Can't we just extract the text without parsing the whole document or extract text as it is parsed?](#partially)

### PDF Rendering

- [I'm getting an OutOfMemoryError. What can I do?](#outofmemoryerror)
- [A drop shadow is missing or at the wrong position when rendering a page](#dropshadow)
- [Why are some texts in poor quality and not antialiased?](#textantialias)

## General Questions

<a name="log4j"></a>
Expand Down
6 changes: 4 additions & 2 deletions content/2.0/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ license: Licensed to the Apache Software Foundation (ASF) under one
specific language governing permissions and limitations
under the License.

layout: default
layout: documentation
title: Getting Started
---

Expand Down Expand Up @@ -53,6 +53,8 @@ https://bugs.openjdk.java.net/browse/JDK-8041125

PDFBox 2.0.4 introduced a new command line setting

``-Dorg.apache.pdfbox.rendering.UsePureJavaCMYKConversion=true``
```
-Dorg.apache.pdfbox.rendering.UsePureJavaCMYKConversion=true
```

which may improve the performance of rendering PDFs on some systems especially if there are a lot of images on a page.
2 changes: 1 addition & 1 deletion content/2.0/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ license: Licensed to the Apache Software Foundation (ASF) under one
specific language governing permissions and limitations
under the License.

layout: default
layout: documentation
title: PDFBox 2.0.0 Migration Guide
---

Expand Down
85 changes: 85 additions & 0 deletions content/_includes/toc.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{% capture tocWorkspace %}
{% comment %}
Version 1.0.4
https://github.com/allejo/jekyll-toc

"...like all things liquid - where there's a will, and ~36 hours to spare, there's usually a/some way" ~jaybe

Usage:
{% include toc.html html=content sanitize=true class="inline_toc" id="my_toc" h_min=2 h_max=3 %}

Parameters:
* html (string) - the HTML of compiled markdown generated by kramdown in Jekyll

Optional Parameters:
* sanitize (bool) : false - when set to true, the headers will be stripped of any HTML in the TOC
* class (string) : '' - a CSS class assigned to the TOC
* id (string) : '' - an ID to assigned to the TOC
* h_min (int) : 1 - the minimum TOC header level to use; any header lower than this value will be ignored
* h_max (int) : 6 - the maximum TOC header level to use; any header greater than this value will be ignored
* ordered (bool) : false - when set to true, an ordered list will be outputted instead of an unordered list
* item_class (string) : '' - add custom class for each list item; has support for '%level%' placeholder, which is the current heading level

Output:
An ordered or unordered list representing the table of contents of a markdown block. This snippet will only generate the table of contents and will NOT output the markdown given to it
{% endcomment %}

{% capture my_toc %}{% endcapture %}
{% assign orderedList = include.ordered | default: false %}
{% assign minHeader = include.h_min | default: 1 %}
{% assign maxHeader = include.h_max | default: 6 %}
{% assign nodes = include.html | split: '<h' %}
{% assign firstHeader = true %}

{% capture listModifier %}{% if orderedList %}1.{% else %}-{% endif %}{% endcapture %}

{% for node in nodes %}
{% if node == "" %}
{% continue %}
{% endif %}

{% assign headerLevel = node | replace: '"', '' | slice: 0, 1 | times: 1 %}

{% if headerLevel < minHeader or headerLevel > maxHeader %}
{% continue %}
{% endif %}

{% if firstHeader %}
{% assign firstHeader = false %}
{% assign minHeader = headerLevel %}
{% endif %}

{% assign indentAmount = headerLevel | minus: minHeader | add: 1 %}
{% assign _workspace = node | split: '</h' %}

{% assign _idWorkspace = _workspace[0] | split: 'id="' %}
{% assign _idWorkspace = _idWorkspace[1] | split: '"' %}
{% assign html_id = _idWorkspace[0] %}

{% capture _hAttrToStrip %}{{ _workspace[0] | split: '>' | first }}>{% endcapture %}
{% assign header = _workspace[0] | replace: _hAttrToStrip, '' %}

{% assign space = '' %}
{% for i in (1..indentAmount) %}
{% assign space = space | prepend: ' ' %}
{% endfor %}

{% unless include.item_class == blank %}
{% capture listItemClass %}{:.{{ include.item_class | replace: '%level%', headerLevel }}}{% endcapture %}
{% endunless %}

{% capture my_toc %}{{ my_toc }}
{{ space }}{{ listModifier }} {{ listItemClass }} [{% if include.sanitize %}{{ header | strip_html }}{% else %}{{ header }}{% endif %}](#{{ html_id }}){% endcapture %}

{% endfor %}

{% if include.class %}
{% capture my_toc %}{:.{{ include.class }}}
{{ my_toc | lstrip }}{% endcapture %}
{% endif %}

{% if include.id %}
{% capture my_toc %}{: #{{ include.id }}}
{{ my_toc | lstrip }}{% endcapture %}
{% endif %}
{% endcapture %}{% assign tocWorkspace = '' %}{{ my_toc | markdownify | strip }}
60 changes: 60 additions & 0 deletions content/_layouts/documentation.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<!DOCTYPE html>
<html lang="en">

<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE- 2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

{% include head.html %}

<body>

{% include header.html %}

<div class="container documentation">
<nav>
<h1>Documentation</h1>
<ul>
<li><a href="/2.0/migration.html">Migration Guide</a></li>
<li><a href="/2.0/getting-started.html">Getting Started</a></li>
<li><a href="/2.0/examples.html">Examples</a></li>
<li><a href="/2.0/dependencies.html">Dependencies</a></li>
<li class="sidebar-node" id="v2-0-cookbook">
<a href="#">Cookbook</a>
<ul>
<li><a href="/2.0/cookbook/encryption.html">Document Encryption</a></li>
</ul>
</li>
<li><a href="/2.0/commandline.html">Command-Line Tools</a></li>
<li><a href="/2.0/faq.html">FAQ</a></li>
<li><a href="/docs/2.0.8/javadocs/">API Docs</a></li>
</nav>
<section>
{{ content }}
</section>
<aside>
<h1>Table of Contents</h1>
{% include toc.html html=content h_min=2 h_max=3 %}
</aside>
</div>

{% include footer.html %}
{% include footer_scripts.html %}

</body>

</html>
84 changes: 80 additions & 4 deletions content/css/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ body {
}

body > .container {
padding-top: 20px;
padding-top: 5rem;
}

.main-header {
Expand Down Expand Up @@ -168,9 +168,7 @@ code {
* Default styling for the tables copied over from bootstrap
* to get basic styling for tables created through markdown
*/
table {
width: 100%;
}


table th, table td {
padding: 8px;
Expand Down Expand Up @@ -249,6 +247,84 @@ table tr:nth-child(even) td, table tr.even td {
content: url("data:image/svg+xml, %3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3E%3Cpath fill='#0088cc' d='M1.5 0l-1.5 1.5 2.5 2.5-2.5 2.5 1.5 1.5 4-4-4-4z' transform='translate(1)' /%3E%3C/svg%3E");
}

.documentation {
display: flex;
}

.documentation section h1, .documentation section h2,
.documentation section h3, .documentation section h4,
.documentation section ul,
.documentation section p {
padding-left: 3rem;
padding-right: 1rem;
}

.documentation section table {
margin-left: 3rem;
margin-right: 1rem;
}

.documentation section ul {
padding-left: 5rem;
}

.documentation nav {
min-width: 25rem;
box-shadow: 1px 0 0 rgba(81,88,90,0.17);
}

.documentation nav h1 {
font-size: 1.2rem;
text-transform: uppercase;
}

.documentation nav ul {
list-style: none;
}

.documentation nav > ul {
list-style: none;
padding: 0;
}

.documentation nav li a {
padding: .20em 15px;
}

.documentation nav li a:hover, .documentation nav li a:focus {
background-color: #eee;
text-decoration: none;
}

.documentation aside {
min-width: 22rem;
max-width: 22rem;
padding-left: 2rem;
}

.documentation aside h1 {
font-size: 1.2rem;
text-transform: uppercase;
}

.documentation aside ul {
list-style: none;
padding: 0 1rem;
}

.documentation aside > ul {
list-style: none;
padding: 0;
}

.documentation aside a {
font-size: 13px;
text-decoration: none;
border-radius: 2px;
padding: 4px 5px 4px 23px;
display: block;
}


/*
* Off Canvas
Expand Down

0 comments on commit 37123aa

Please sign in to comment.