Skip to content

Commit

Permalink
💩 Should I parse dictionaries?
Browse files Browse the repository at this point in the history
  • Loading branch information
vbuch committed Nov 29, 2023
1 parent 7ff6a32 commit 0d45df1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/placeholder-plain/src/getValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@
* @param {Buffer} trailer
* @param {string} key
* @returns {string}
*
* FIXME:
* 0 00 000 Null (NUL)
* 9 09 011 Tab (HT)
* 10 0A 012 Line feed (LF)
* 12 0C 014 Form feed (FF)
* 13 0D 015 Carriage return (CR)
* 32 20 040 Space (SP)
*
* The delimiter characters (, ), <, >, [, ], {, }, /, and %
*
* ^ All are terminators
*/
export const getValue = (trailer, key) => {
let index = trailer.indexOf(key);
Expand Down
12 changes: 12 additions & 0 deletions packages/placeholder-plain/src/readRefTable.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {SignPdfError} from '@signpdf/utils';
import xrefToRefMap from './xrefToRefMap';
import {findObjectAt} from './findObject';
// import {getValue} from './getValue';

/**
* @param {Buffer} pdf
Expand Down Expand Up @@ -93,6 +94,17 @@ const readXrefTableAt = (pdfSlice, position) => {
const readXrefStreamAt = (pdfSlice, position) => {
const {dictionary: _d, stream: _s} = findObjectAt(pdfSlice, position);

// const parsed = {
// size: getValue(_d, '/Size'),
// root: getValue(_d, '/Root'),
// info: getValue(_d, '/Info'),
// filter: getValue(_d, '/Filter'),
// length: getValue(_d, '/Length'),
// };

// console.log(_d.toString(), parsed);
// console.log(zlib.deflateSync(stream));

throw new SignPdfError(
'Cross-Reference Streams not yet implemented.',
SignPdfError.TYPE_PARSE,
Expand Down

0 comments on commit 0d45df1

Please sign in to comment.