From 708cf16d9259392dab17bdb1eeaefa21baa5a7fe Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Mon, 10 Apr 2017 13:26:28 +0200 Subject: Use addRawStream in pdf-create-lowlevel.js example script. The more explicit createObject, writeObject, writeRawStream idiom is shown in pdf-merge.js. --- docs/examples/pdf-create-lowlevel.js | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'docs') diff --git a/docs/examples/pdf-create-lowlevel.js b/docs/examples/pdf-create-lowlevel.js index 658adfb5..c7a299f7 100644 --- a/docs/examples/pdf-create-lowlevel.js +++ b/docs/examples/pdf-create-lowlevel.js @@ -15,22 +15,20 @@ var font = pdf.addObject({ }) // Create and add an image resource: -// Allocate a slot for a new object and get a reference to it. -var image = pdf.createObject() -// Write a dictionary object into the slot. -image.writeObject({ - Type: "XObject", - Subtype: "Image", - Width: 4, - Height: 2, - BitsPerComponent: 8, - ColorSpace: "DeviceGray", - // The compression filter to be used: - Filter: "ASCIIHexDecode", -}) -// Write raw stream data into the slot; hex encoded -// to match the Filter entry in the dictionary. -image.writeRawStream("004488CCEEBB7733>") +var image = pdf.addRawStream( + // The raw stream contents, hex encoded to match the Filter entry: + "004488CCEEBB7733>", + // The image object dictionary: + { + Type: "XObject", + Subtype: "Image", + Width: 4, + Height: 2, + BitsPerComponent: 8, + ColorSpace: "DeviceGray", + Filter: "ASCIIHexDecode", + } +); // Create resource dictionary. var resources = pdf.addObject({ -- cgit v1.2.3