PDF

PDF

Ref

  1. Introduction to PDF
  2. Fillable PDF

Intro

  • Portable Format Document
  • A format meant to be displayed identicaly in all platforms and media

Simple Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
%PDF-1.7

1 0 obj % entry point
<<
/Type /Catalog
/Pages 2 0 R
>>
endobj

2 0 obj
<<
/Type /Pages
/MediaBox [ 0 0 200 200 ]
/Count 1
/Kids [ 3 0 R ]
>>
endobj

3 0 obj
<<
/Type /Page
/Parent 2 0 R
/Resources <<
/Font <<
/F1 4 0 R
>>
>>
/Contents 5 0 R
>>
endobj

4 0 obj
<<
/Type /Font
/Subtype /Type1
/BaseFont /Times-Roman
>>
endobj

5 0 obj % page content
<<
/Length 44
>>
stream
BT
70 50 TD
/F1 12 Tf
(Hello, world!) Tj
ET
endstream
endobj

xref
0 6
0000000000 65535 f
0000000010 00000 n
0000000079 00000 n
0000000173 00000 n
0000000301 00000 n
0000000380 00000 n
trailer
<<
/Size 6
/Root 1 0 R
>>
startxref
492
%%EOF

Structure

Typically, a PDF contains 4 parts:

  1. The header, with PDF version(and an option line to specify if the PDF contains binary data)
1
%PDF-1.7
  1. The body, containing a series of objects
1
2
3
4
5
6
7
1 0 obj
...
endobj
2 0 obj
...
endobj
...
  1. A cross-reference table that specifies the position of the bojects
1
2
3
4
5
6
7
8
xref
0 6
0000000000 65535 f
0000000010 00000 n
0000000079 00000 n
0000000173 00000 n
0000000301 00000 n
0000000380 00000 n
  1. A trailer, with information about where the document starts
1
2
3
4
5
6
7
8
trailer
<<
/Size 6
/Root 1 0 R
>>
startxref
492
%%EOF

Sign a PDF

  • Signing can ensure a PDF has not been modified and to verify that the author is who we expect.
  • For example, an important contract.

Fill a PDF form

Log4js

Log4js

Tips

  • By default, log4js level for default category is set to OFF, thus not outputting any logs. To turn on logging, level must be set other than OFF.
  • Levels: TRACE -> DEBUG -> INFO -> WARN -> ERROR -> FATAL
Read more
Using Oracle in node.js

Using Oracle in node.js

Basic

Install

yarn add oracledb

Example

Simple

Using MongoDB in node.js
Heroku

Heroku

Add proxy to heroku login

Read more
cookie, localStorage, sessionStorage

cookie, localStorage, sessionStorage

Comparison

Name Description Size Life
Cookie Small piece of text data filed by server and saved in browser and carried in every request. Mostly used for identifying user. 4KB User defined expiration. Default cleared on browser close.
localStorage Permanent storage for each domain. Not used in request. 5MB Permanent, unless cleared.
sessionStorage Transient storage for each domain. Not used in request. 5MB Available in current session. Cleared when tab or browser closed/refreshed.
Read more
CORS and withCredentials
Javascript this && Javascript Class VS Function