Search results

PdfPen API in JavaScript (ES5) Pdf Export API control

PdfPen class defining settings for drawing operations, that determines the color, width, and style of the drawing elements.

// create a new PDF document
let document : PdfDocument = new PdfDocument();
// create a new page
let page1 : PdfPage = document.pages.add();
// set pen
let pen : PdfPen = new PdfPen(new PdfColor(0, 0, 0));
// draw rectangle
page1.graphics.drawRectangle(pen, new RectangleF({x : 0, y : 0}, {width : 100, height : 50}));
// save the document.
document.save('output.pdf');
// destroy the document
document.destroy();

Properties

dashStyle PdfDashStyle

Gets or sets the dash style of the pen.

// create a new PDF document
let document : PdfDocument = new PdfDocument();
// create a new page
let page1 : PdfPage = document.pages.add();
// set pen
let pen : PdfPen = new PdfPen(new PdfColor(0, 0, 0));
//
// set pen style
pen.dashStyle = PdfDashStyle.DashDot;
// get pen style
let style : PdfDashStyle = pen.dashStyle;
//
// draw rectangle
page1.graphics.drawRectangle(pen, new RectangleF({x : 0, y : 0}, {width : 100, height : 50}));
// save the document.
document.save('output.pdf');
// destroy the document
document.destroy();

width number

Gets or sets the width of the pen.

// create a new PDF document
let document : PdfDocument = new PdfDocument();
// create a new page
let page1 : PdfPage = document.pages.add();
// set pen
let pen : PdfPen = new PdfPen(new PdfColor(0, 0, 0));
//
// set pen width
pen.width = 2;
//
// draw rectangle
page1.graphics.drawRectangle(pen, new RectangleF({x : 0, y : 0}, {width : 100, height : 50}));
// save the document.
document.save('output.pdf');
// destroy the document
document.destroy();