Sunting PDF ing Node SDK

Gunakake REST API kanggo nyunting PDF ing JavaScript kanthi terprogram

Nalika pangembang ngowahi PDF dokumen nganggo perpustakaan JavaScript iki, sing lagi diowahi yaiku Model Obyek Dokumen (DOM). Dadi, meh kabeh owah-owahan bisa ditindakake kanggo PDF dokumen sing diwakili minangka DOM. Kanthi Node SDK sing disedhiyakake, pangembang bisa kanthi gampang nyunting dokumen: ngowahi teks, nganyari tabel, nambah gambar lan liya-liyane. Cukup mbukak PDF, gawe owah-owahan sing dibutuhake kanthi program lan ekspor asil menyang format nyimpen sing padha utawa sing didhukung.

Ndeleng potongan kode

Sunting PDF ing JavaScript nggunakake REST API

Pustaka Node kita menehi pangembang kemampuan kanggo ngowahi PDF dokumen kanthi langsung kanthi nyunting Document Object Model (DOM), tegese ora ana piranti lunak tambahan sing kudu diinstal.

Sunting teks ing PDF file nggunakake JavaScript

Kasus sing paling populer kanggo nyunting PDF file yaiku nyunting teks. Kanthi solusi piranti lunak sing diwenehake, sampeyan bisa nambah, ngowahi utawa mbusak teks nggunakake JavaScript ing dokumen kasebut.

Sunting tabel ing PDF file nggunakake JavaScript

Pilihan editing PDF liyane sing populer yaiku nyunting tabel. Node SDK kita ngidini sampeyan nggarap tabel lan teks ing sel tabel.

Pangembang JavaScript bisa nambah utawa mbusak sel tabel lan tabel, uga nambah, ngowahi lan mbusak teks ing njero.

Tambah gambar menyang PDF file nggunakake JavaScript

Saliyane nyunting teks lan tabel ing PDF, ana pilihan umum liyane: nambahake gambar menyang dokumen ing JavaScript. Pangembang Node uga bisa nambah gambar menyang PDF file nggunakake DOM.

Sunting PDF kanthi terprogram

Coba Node SDK sing kuat iki lan evaluasi sawetara opsi ing panyuntingan PDF dokumen. Nggunakake conto ing ngisor iki, muat PDF dokumen lan gawe sawetara owah-owahan: nambah teks, nambah tabel lan sel tabel kanthi teks utawa lebokake gambar menyang PDF dokumen:

Unggah dokumen sing pengin diowahi
Kode roto
Unggah gambar sing pengin dilebokake
Pilih format target saka dhaptar
import * as fs from "fs";

const wordsApi = new WordsApi("####-####-####-####-####", "##################");

const requestDocument = fs.createReadStream("Input.pdf");
const requestParagraph = new model.ParagraphInsert({
    text: "Morbi enim nunc faucibus a."
})
const insertParagraphRequest = new model.InsertParagraphOnlineRequest({
    document: requestDocument,
    paragraph: requestParagraph
});

wordsApi.insertParagraphOnline(insertParagraphRequest)
.then((insertParagraphResult) => {    
    const requestDocument = insertParagraphResult.Document.Values();
    const convertDocument = new model.ConvertDocumentRequest({
        document: requestDocument,
        format: "pdf"
    });

    wordsApi.convertDocument(convertDocument)
    .then((convertDocumentResult) => {
        console.log("Result of ConvertDocument: ", convertDocumentResult);
    });
});
import * as fs from "fs";

const wordsApi = new WordsApi("####-####-####-####-####", "##################");

const requestDocument = fs.createReadStream("Input.pdf");
const requestTable = new model.TableInsert({
    columnsCount: 1,
    rowsCount: 2
})
const insertTableRequest = new model.InsertTableOnlineRequest({
    document: requestDocument,
    table: requestTable,
    nodePath: ""
});

wordsApi.insertTableOnline(insertTableRequest)
.then((insertTableResult) => {    
    const requestDocument = insertTableResult.Document.Values();
    const convertDocument = new model.ConvertDocumentRequest({
        document: requestDocument,
        format: "pdf"
    });

    wordsApi.convertDocument(convertDocument)
    .then((convertDocumentResult) => {
        console.log("Result of ConvertDocument: ", convertDocumentResult);
    });
});
import * as fs from "fs";

const wordsApi = new WordsApi("####-####-####-####-####", "##################");

const requestDocument = fs.createReadStream("Input1.pdf");
const requestDrawingObject = new model.DrawingObjectInsert({
    height: 0,
    left: 0,
    top: 0,
    width: 0,
    relativeHorizontalPosition: model.DrawingObjectInsert.RelativeHorizontalPositionEnum.Margin,
    relativeVerticalPosition: model.DrawingObjectInsert.RelativeVerticalPositionEnum.Margin,
    wrapType: model.DrawingObjectInsert.WrapTypeEnum.Inline
})
const requestImageFile = fs.createReadStream("Input2.pdf");
const insertDrawingObjectRequest = new model.InsertDrawingObjectOnlineRequest({
    document: requestDocument,
    drawingObject: requestDrawingObject,
    imageFile: requestImageFile,
    nodePath: "sections/0"
});

wordsApi.insertDrawingObjectOnline(insertDrawingObjectRequest)
.then((insertDrawingObjectResult) => {    
    const requestDocument = insertDrawingObjectResult.Document.Values();
    const convertDocument = new model.ConvertDocumentRequest({
        document: requestDocument,
        format: "pdf"
    });

    wordsApi.convertDocument(convertDocument)
    .then((convertDocumentResult) => {
        console.log("Result of ConvertDocument: ", convertDocumentResult);
    });
});
Kode roto
  
Nyalin kode JavaScript menyang clipboard

Cara Ngowahi PDF ing JavaScript

  1. Pasang 'Aspose.Words Cloud kanggo Node'
  2. Tambah referensi perpustakaan (ngimpor perpustakaan) menyang proyek JavaScript sampeyan
  3. Muat PDF kanggo nyunting ing JavaScript
  4. Lebokake isi ing wiwitan PDF
  5. Download dokumen asil saka panyimpenan maya

Pustaka JavaScript kanggo nggunakake panyuntingan PDF.

Instal 'Aspose.Words Cloud SDK for Node.js' nggunakake manajer paket NPM. npm install asposewordscloud --save saka baris perintah kanggo nginstal SDK liwat manajer paket NPM. Minangka alternatif, sampeyan bisa kanthi manual kloning Aspose.Words Cloud SDK for Node.js saka GitHub lan nggunakake ing project. Tututi Instructions iki supaya cepet entuk kredensial keamanan sing dibutuhake lan ngakses REST API kita.

Requirements Sistem

  • @types/request (version 2.48.3+)
  • lodash (version 4.17.15+)
  • lodash.template (version 4.5.0+)
  • request (version 2.88.0+)
  • request-debug (version 0.2.0+)

Deleng Repository Documentation kanggo ndeleng rincian liyane.

Format file liyane sing didhukung

Sampeyan bisa nindakake operasi suntingan kanggo format file liyane:

5%

Langganan kanggo Aspose Update Product

Entuk buletin saben wulan lan tawaran langsung dikirim menyang kothak layang.

© Aspose Pty Ltd 2001-2024. Kabeh hak dilindhungi undhang-undhang.