Update docs and demo

This commit is contained in:
Devon Govett 2016-08-26 13:30:51 -04:00
parent cc221b7107
commit 6ff6651ca3
24 changed files with 33548 additions and 12145 deletions

File diff suppressed because one or more lines are too long

View File

@ -77,9 +77,9 @@ links, underlines, and strikes. Here&#39;s an example showing two of them:</p>
<p>That&#39;s all there is to creating PDF documents in PDFKit. It&#39;s really quite
simple to create beautiful multi-page printable documents using Node.js!</p>
<p>This guide was actually generated from Markdown/Literate CoffeeScript files using a
<p>This guide was generated from Markdown/Literate CoffeeScript files using a
PDFKit generation script. The examples are actually run to generate the output shown
inline. The script generates both the website and the PDF guide, and
inline. The script generates both the website and the PDF guide, and
can be found <a href="http://github.com/devongovett/pdfkit/tree/master/docs/generate.coffee">on Github</a>.
Check it out if you want to see an example of a slightly more complicated renderer using
a parser for Markdown and a syntax highlighter.</p>

View File

@ -80,11 +80,16 @@ If you forget to install it, Browserify will print an error message.</p>
<h2 id="adding_pages">Adding pages</h2>
<p>The first page of a PDFKit document is added for you automatically when you
create the document. Subsequent pages must be added by you. Luckily, it is
create the document unless you provide <code>autoFirstPage: false</code>. Subsequent pages must be added by you. Luckily, it is
quite simple!</p>
<pre><code>doc.addPage()</code></pre>
<p>To add some content every time a page is created, either by calling <code>addPage()</code> or automatically, you can use the <code>pageAdded</code> event.</p>
<pre><code>doc.on &#39;pageAdded&#39;, -&gt;
doc.text &quot;Page Title&quot;</code></pre>
<p>You can also set some options for the page, such as it&#39;s size and orientation.</p>
<p>The <code>layout</code> property can be either <code>portrait</code> (the default) or <code>landscape</code>.

View File

@ -1250,7 +1250,7 @@ endobj
<<
/Producer (PDFKit)
/Creator (PDFKit)
/CreationDate (D:20160826171314Z)
/CreationDate (D:20160826173016Z)
>>
endobj
97 0 obj
@ -1264,7 +1264,7 @@ endobj
150 0 obj
<<
/Type /FontDescriptor
/FontName /GEMBQK+AlegreyaSans-Light
/FontName /EYXLNS+AlegreyaSans-Light
/Flags 4
/FontBBox [-240 -264 1137 967]
/ItalicAngle 0
@ -1280,7 +1280,7 @@ endobj
<<
/Type /Font
/Subtype /CIDFontType2
/BaseFont /GEMBQK+AlegreyaSans-Light
/BaseFont /EYXLNS+AlegreyaSans-Light
/CIDSystemInfo <<
/Registry (Adobe)
/Ordering (Identity)
@ -1294,7 +1294,7 @@ endobj
<<
/Type /Font
/Subtype /Type0
/BaseFont /GEMBQK+AlegreyaSans-Light
/BaseFont /EYXLNS+AlegreyaSans-Light
/Encoding /Identity-H
/DescendantFonts [151 0 R]
/ToUnicode 152 0 R
@ -1303,7 +1303,7 @@ endobj
154 0 obj
<<
/Type /FontDescriptor
/FontName /KWGMXL+Merriweather
/FontName /ONSEEO+Merriweather
/Flags 6
/FontBBox [-41.9921875 -312.5 1199.70703125 937.5]
/ItalicAngle 0
@ -1319,7 +1319,7 @@ endobj
<<
/Type /Font
/Subtype /CIDFontType2
/BaseFont /KWGMXL+Merriweather
/BaseFont /ONSEEO+Merriweather
/CIDSystemInfo <<
/Registry (Adobe)
/Ordering (Identity)
@ -1333,7 +1333,7 @@ endobj
<<
/Type /Font
/Subtype /Type0
/BaseFont /KWGMXL+Merriweather
/BaseFont /ONSEEO+Merriweather
/Encoding /Identity-H
/DescendantFonts [155 0 R]
/ToUnicode 156 0 R
@ -1342,7 +1342,7 @@ endobj
158 0 obj
<<
/Type /FontDescriptor
/FontName /GKCFBS+Alegreya-Bold
/FontName /OEYKZZ+Alegreya-Bold
/Flags 6
/FontBBox [-205 -318 1042 977]
/ItalicAngle 0
@ -1358,7 +1358,7 @@ endobj
<<
/Type /Font
/Subtype /CIDFontType2
/BaseFont /GKCFBS+Alegreya-Bold
/BaseFont /OEYKZZ+Alegreya-Bold
/CIDSystemInfo <<
/Registry (Adobe)
/Ordering (Identity)
@ -1372,7 +1372,7 @@ endobj
<<
/Type /Font
/Subtype /Type0
/BaseFont /GKCFBS+Alegreya-Bold
/BaseFont /OEYKZZ+Alegreya-Bold
/Encoding /Identity-H
/DescendantFonts [159 0 R]
/ToUnicode 160 0 R
@ -1381,7 +1381,7 @@ endobj
162 0 obj
<<
/Type /FontDescriptor
/FontName /ONVRIN+SourceCodePro-Regular
/FontName /JTHSHL+SourceCodePro-Regular
/Flags 5
/FontBBox [-39 -400 706 1000]
/ItalicAngle 0
@ -1397,7 +1397,7 @@ endobj
<<
/Type /Font
/Subtype /CIDFontType2
/BaseFont /ONVRIN+SourceCodePro-Regular
/BaseFont /JTHSHL+SourceCodePro-Regular
/CIDSystemInfo <<
/Registry (Adobe)
/Ordering (Identity)
@ -1411,7 +1411,7 @@ endobj
<<
/Type /Font
/Subtype /Type0
/BaseFont /ONVRIN+SourceCodePro-Regular
/BaseFont /JTHSHL+SourceCodePro-Regular
/Encoding /Identity-H
/DescendantFonts [163 0 R]
/ToUnicode 164 0 R
@ -1420,7 +1420,7 @@ endobj
166 0 obj
<<
/Type /FontDescriptor
/FontName /ANUMUM+SourceCodePro-Bold
/FontName /ESYNPY+SourceCodePro-Bold
/Flags 5
/FontBBox [-69 -400 705 1000]
/ItalicAngle 0
@ -1436,7 +1436,7 @@ endobj
<<
/Type /Font
/Subtype /CIDFontType2
/BaseFont /ANUMUM+SourceCodePro-Bold
/BaseFont /ESYNPY+SourceCodePro-Bold
/CIDSystemInfo <<
/Registry (Adobe)
/Ordering (Identity)
@ -1450,7 +1450,7 @@ endobj
<<
/Type /Font
/Subtype /Type0
/BaseFont /ANUMUM+SourceCodePro-Bold
/BaseFont /ESYNPY+SourceCodePro-Bold
/Encoding /Identity-H
/DescendantFonts [167 0 R]
/ToUnicode 168 0 R
@ -1467,7 +1467,7 @@ endobj
170 0 obj
<<
/Type /FontDescriptor
/FontName /VQTLWU+GoodDog
/FontName /EYQSQS+GoodDog
/Flags 4
/FontBBox [-107.421875 -174.8046875 1034.66796875 641.6015625]
/ItalicAngle 0
@ -1483,7 +1483,7 @@ endobj
<<
/Type /Font
/Subtype /CIDFontType2
/BaseFont /VQTLWU+GoodDog
/BaseFont /EYQSQS+GoodDog
/CIDSystemInfo <<
/Registry (Adobe)
/Ordering (Identity)
@ -1497,7 +1497,7 @@ endobj
<<
/Type /Font
/Subtype /Type0
/BaseFont /VQTLWU+GoodDog
/BaseFont /EYQSQS+GoodDog
/Encoding /Identity-H
/DescendantFonts [171 0 R]
/ToUnicode 172 0 R
@ -1506,7 +1506,7 @@ endobj
174 0 obj
<<
/Type /FontDescriptor
/FontName /EDDCKX+Chalkboard-Bold
/FontName /PIXZWK+Chalkboard-Bold
/Flags 4
/FontBBox [-163.53591160220995 -615.4696132596686 2017.67955801105 1358.011049723757]
/ItalicAngle 0
@ -1522,7 +1522,7 @@ endobj
<<
/Type /Font
/Subtype /CIDFontType2
/BaseFont /EDDCKX+Chalkboard-Bold
/BaseFont /PIXZWK+Chalkboard-Bold
/CIDSystemInfo <<
/Registry (Adobe)
/Ordering (Identity)
@ -1536,7 +1536,7 @@ endobj
<<
/Type /Font
/Subtype /Type0
/BaseFont /EDDCKX+Chalkboard-Bold
/BaseFont /PIXZWK+Chalkboard-Bold
/Encoding /Identity-H
/DescendantFonts [175 0 R]
/ToUnicode 176 0 R

View File

@ -1,6 +1,6 @@
<!DOCTYPE html><html><head><meta charset="utf-8"><title>Images in PDFKit</title><link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Source+Code+Pro:400,700|Alegreya:700|Merriweather"><link rel="stylesheet" href="/docs/css/index.css"><link rel="stylesheet" href="/docs/css/github.css"></head><body><nav class="sidebar"><ul><li><a href="/">Home</a></li><li><a href="/docs/../index.html">Documentation</a><ul><li><a href="/docs/getting_started.html">Getting Started </a></li><li><a href="/docs/vector.html">Vector Graphics </a></li><li><a href="/docs/text.html">Text </a></li><li><a href="/docs/images.html" class="selected">Images </a></li><li><a href="/docs/annotations.html">Annotations </a></li></ul></li><li><a href="/docs/guide.pdf">PDF Guide</a></li><li><a href="/demo/out.pdf">Example PDF</a></li><li><a href="/demo/browser.html">Interactive Browser Demo</a></li><li><a href="http://github.com/devongovett/pdfkit">Source Code</a></li></ul></nav><div class="main"><h1 id="images_in_pdfkit">Images in PDFKit</h1>
<p>Adding images to PDFKit documents is an easy task. Just pass an image path to
<p>Adding images to PDFKit documents is an easy task. Just pass an image path, buffer, or data uri with base64 encoded data to
the <code>image</code> method along with some optional arguments. PDFKit supports the
JPEG and PNG formats. If an X and Y position are not provided, the image is
rendered at the current point in the text flow (below the last line of text).
@ -13,7 +13,7 @@ be scaled according to the following options.</p>
<pre><code># Scale proprotionally to the specified width
doc.image(&#39;images/test.jpeg&#39;, 0, 15, width: 300)
.text(&#39;Proprotional to width&#39;, 0, 0)
.text(&#39;Proportional to width&#39;, 0, 0)
# Fit the image within the dimensions
doc.image(&#39;images/test.jpeg&#39;, 320, 15, fit: [100, 100])

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.3 KiB

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.3 KiB

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 77 KiB

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 944 KiB

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 48 KiB

View File

@ -73,7 +73,7 @@ doc.rect(doc.x, 0, 410, doc.y).stroke()</code></pre>
documents, which can be passed to the <code>text</code> method. They are enumerated
below.</p>
<ul><li><code>lineBreak</code> - set to <code>false</code> to disable line wrapping all together</li><li><code>width</code> - the width that text should be wrapped to (by default, the page width minus the left and right margin)</li><li><code>height</code> - the maximum height that text should be clipped to</li><li><code>ellipsis</code> - the character to display at the end of the text when it is too long. Set to <code>true</code> to use the default character.</li><li><code>columns</code> - the number of columns to flow the text into</li><li><code>columnGap</code> - the amount of space between each column (1/4 inch by default)</li><li><code>indent</code> - the amount in PDF points (72 per inch) to indent each paragraph of text</li><li><code>paragraphGap</code> - the amount of space between each paragraph of text</li><li><code>lineGap</code> - the amount of space between each line of text</li><li><code>wordSpacing</code> - the amount of space between each word in the text</li><li><code>characterSpacing</code> - the amount of space between each character in the text</li><li><code>fill</code> - whether to fill the text (<code>true</code> by default)</li><li><code>stroke</code> - whether to stroke the text</li><li><code>link</code> - a URL to link this text to (shortcut to create an annotation)</li><li><code>underline</code> - whether to underline the text</li><li><code>strike</code> - whether to strike out the text</li><li><code>continued</code> - whether the text segment will be followed immediately by another segment. Useful for changing styling in the middle of a paragraph.</li></ul>
<ul><li><code>lineBreak</code> - set to <code>false</code> to disable line wrapping all together</li><li><code>width</code> - the width that text should be wrapped to (by default, the page width minus the left and right margin)</li><li><code>height</code> - the maximum height that text should be clipped to</li><li><code>ellipsis</code> - the character to display at the end of the text when it is too long. Set to <code>true</code> to use the default character.</li><li><code>columns</code> - the number of columns to flow the text into</li><li><code>columnGap</code> - the amount of space between each column (1/4 inch by default)</li><li><code>indent</code> - the amount in PDF points (72 per inch) to indent each paragraph of text</li><li><code>paragraphGap</code> - the amount of space between each paragraph of text</li><li><code>lineGap</code> - the amount of space between each line of text</li><li><code>wordSpacing</code> - the amount of space between each word in the text</li><li><code>characterSpacing</code> - the amount of space between each character in the text</li><li><code>fill</code> - whether to fill the text (<code>true</code> by default)</li><li><code>stroke</code> - whether to stroke the text</li><li><code>link</code> - a URL to link this text to (shortcut to create an annotation)</li><li><code>underline</code> - whether to underline the text</li><li><code>strike</code> - whether to strike out the text</li><li><code>continued</code> - whether the text segment will be followed immediately by another segment. Useful for changing styling in the middle of a paragraph.</li><li><code>features</code> - an array of <a href="https://www.microsoft.com/typography/otspec/featuretags.htm">OpenType feature tags</a> to apply. If not provided, a set of defaults is used.</li></ul>
<p>Additionally, the fill and stroke color and opacity methods described in the
<a href="vector.html">vector graphics section</a> are applied to text content as well.</p>
@ -122,14 +122,14 @@ option from the first <code>text</code> call is retained by the second call.</p>
<p>The PDF format defines 14 standard fonts that can be used in PDF documents (4
styles of Helvetica, Courier, and Times, as well as Symbol and Zapf Dingbats),
but also allows fonts to be embedded right in the document. PDFKit supports
embedding font files in the TrueType (<code>.ttf</code>), TrueType Collection (<code>.ttc</code>),
and Datafork TrueType (<code>.dfont</code>) formats.</p>
embedding TrueType (<code>.ttf</code>), OpenType (<code>.otf</code>), WOFF, WOFF2, TrueType Collection (<code>.ttc</code>),
and Datafork TrueType (<code>.dfont</code>) fonts.</p>
<p>To change the font used to render text, just call the <code>font</code> method. If you
are using a standard PDF font, just pass the name to the <code>font</code> method.
Otherwise, pass the path to the font file, or a <code>Buffer</code> containing the font data.
If the font is a collection font (<code>.ttc</code> and <code>.dfont</code> files), meaning that it
contains multiple styles in the same file, you should pass the name of the style
If the font is a collection font (<code>.ttc</code> and <code>.dfont</code> files), meaning that it
contains multiple styles in the same file, you should pass the name of the style
to be extracted from the collection.</p>
<p>Here is an example showing how to set the font in each case.</p>

View File

@ -2,6 +2,8 @@
<p>A JavaScript PDF generation library for Node and the browser.</p>
<p><a href="https://gratipay.com/devongovett"><img alt="" src="https://img.shields.io/gratipay/devongovett.svg"/></a></p>
<h2 id="description">Description</h2>
<p>PDFKit is a PDF document generation library for Node and the browser that makes creating complex, multi-page, printable documents easy.
@ -37,7 +39,7 @@ folder.</p>
# Create a document
doc = new PDFDocument
# Pipe it&#39;s output somewhere, like to a file or HTTP response
# Pipe its output somewhere, like to a file or HTTP response
# See below for browser usage
doc.pipe fs.createWriteStream(&#39;output.pdf&#39;)