mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 15:50:13 +00:00
Merge pull request #30367 from taoqf/master
Add type definition pdf2image
This commit is contained in:
53
types/pdf2image/index.d.ts
vendored
Normal file
53
types/pdf2image/index.d.ts
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
// Type definitions for pdf2image 1.2
|
||||
// Project: https://bitbucket.org/RicardoCacheira/pdf2image#readme
|
||||
// Definitions by: taoqf <https://github.com/taoqf>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// TypeScript Version: 2.9
|
||||
|
||||
/**
|
||||
* A token starts with the character '%'
|
||||
*
|
||||
* d - the page number, if the first page of the PDF is page 1
|
||||
* D - the page number, if the first page of the PDF is page 0
|
||||
* i - the processed page number, if the first processed page is page 1
|
||||
* I - the processed page number, if the first processed page is page 0
|
||||
* t - the total number of pages in the pdf
|
||||
* T - the total of processed pages
|
||||
* s - the name of the pdf file
|
||||
* p - the path of the pdf file
|
||||
* % - the character '%'
|
||||
* {...} - a custom piece of code where all of the above values can be used
|
||||
*/
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
export type OutputFormat = ((pageNum: number, pageIndex: number, totalPagesProcessed: number, totalPDFPages: number, name: string, path: string, vm: typeof import ('vm')) => string) | string;
|
||||
|
||||
export interface Options {
|
||||
density: number;
|
||||
height: number;
|
||||
width: number;
|
||||
outputType: 'jpg' | 'png' | '.jpg' | '.png';
|
||||
quality: number;
|
||||
pages: '*' | string; // * | even | odd | '/1,/3,5-6,-8, 9-'
|
||||
singleProcess: boolean;
|
||||
backgroundColor: string; // #ffffff
|
||||
outputFormat: OutputFormat;
|
||||
}
|
||||
|
||||
export interface ConvertedFile {
|
||||
page: number;
|
||||
index: number;
|
||||
name: string;
|
||||
path: string;
|
||||
}
|
||||
|
||||
export function convertPDF(pdfFilePath: string, options?: Partial<Options>): Promise<ConvertedFile[]>;
|
||||
|
||||
export interface Converter {
|
||||
convertPDF(pdfFilePath: string): Promise<ConvertedFile[]>;
|
||||
convertPDFList(pdfList: string[]): Promise<ConvertedFile[]>;
|
||||
}
|
||||
|
||||
export function compileConverter(options?: Partial<Options>): Converter;
|
||||
8
types/pdf2image/pdf2image-tests.ts
Normal file
8
types/pdf2image/pdf2image-tests.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { convertPDF } from 'pdf2image';
|
||||
|
||||
// converts all the pages of the given pdf using the default options
|
||||
convertPDF('example.pdf').then(
|
||||
(pageList) => {
|
||||
console.log(pageList);
|
||||
}
|
||||
);
|
||||
23
types/pdf2image/tsconfig.json
Normal file
23
types/pdf2image/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"strictFunctionTypes": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"pdf2image-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/pdf2image/tslint.json
Normal file
1
types/pdf2image/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user