Aspose.PDF FOSS for TypeScript היא ספרייה קוד פתוח ליצירה, עריכה, המרה והגנה של מסמכי PDF ביישומי Node.js (>=22). המחלקות Document ו-Page הן נקודות הכניסה המרכזיות: Document.OpenFile() / Document.Open() טוענות קבצים קיימים או בתים בזיכרון, Document.New() מתחילה מסמך ריק, ו-WriteTo() / Save() כותבות את התוצאה חזרה, במידת הצורך עם דחיסת xref-stream. הפרויקט הוא חבילה ללא תלויות (Node.js הוא דרישת הריצה היחידה) והוא נמצא בפיתוח פעיל בשלבים מוקדמים (כרגע גרסה 0.1.0).
מעבר לעריכה הליבת של מסמכים ודפים — פיצול, מיזוג, חילוץ, סידור מחדש והוספת דפים עם Document.Split(), Document.Merge(), Document.ExtractPages() ו-Document.Append() — הספרייה ממירה דפים ומסמכים שלמים לפורמטים אחרים באמצעות ToHtml(), ToMarkdown(), ToDocx(), ToSvg(), ToImage() ו-ToEpub(). תמיכת ההערות כוללת הדגשה, קו תחתי, קו משולב, קו חוצה, קישור, הערת טקסט, טקסט חופשי וחותמת דרך שיטות כגון Page.AddHighlight() ו-Page.AddStamp(). שדות AcroForm (טקסט, תיבת סימון, רדיו, תיבת משולבת, תיבת רשימה וכפתור) נבנים באמצעות המחלקה Form ותתי-מחלקות Field המוגדרות, והמסמכים יכולים להיות מוצפנים ב-AES-128, AES-256 או RC4, חתומים דיגיטלית עם Document.Sign(), ולבעלי עריכה עם Document.Redact() / Page.ApplyRedactions().
Aspose.PDF FOSS for TypeScript משוחררת ברישיון MIT ללא דמי ריצה או הגבלות שימוש (ראו את סעיף ההתקנה למטה). עבור משפחת המוצרים הארגונית, ראו Aspose.PDF — Enterprise Product Family.
Document.OpenFile() / Document.Open(), או התחל ריק עם Document.New()Document.Split(), Document.Merge(), Document.ExtractPages(), Document.Reorder(), ו-Document.Append()Document.SetMetadata() / Document.GetMetadata()Document.WriteTo(), אופציונלית במצב דחוס באמצעות זרמי xref וזרמי אובייקטיםDocument.ToHtml() ול-Markdown בטעם GitHub באמצעות Document.ToMarkdown().docx עם פריסה מתחדשת או קבועה באמצעות Document.ToDocx() / Page.ToDocx()Page.ToSvg() או לבייטים של PNG/TIFF רסטריים באמצעות Page.ToImage()Document.ToEpub() להפצת קוראי-ספריםPage.AddHighlight(), Page.AddUnderline(), Page.AddSquiggly() ו-Page.AddStrikeOut()Page.AddTextNote() ו-Page.AddFreeText()Page.AddStamp() וקישורים לחיצים עם Page.AddLink()Annotation.Flatten() המופיעה בתתי-סוגים כגון MarkupAnnotation ו-StampAnnotationForm (AddTextField(), AddCheckbox(), AddRadioGroup(), AddComboBox(), AddListBox(), AddPushButton())SetStyle() ו-GenerateAppearance() על מחלקות שדה ממומנות כגון TextField, ChoiceField ו-ButtonFieldSetActions() על כל FieldDocument.FlattenForm()encrypt של Document.WriteTo(), עם Permissions מפורטותDocument.Sign() ואמת חתימות עם Document.VerifySignatures()Document.AddDocumentTimestamp()Document.Redact(), Document.RedactText(), ו-Page.ApplyRedactions()פתח קובץ PDF והמר אותו למספר פורמטים במורד הזרם בפעולה אחת.
git clone https://github.com/aspose-pdf-foss/Aspose.PDF-FOSS-for-TypeScript.git
cd Aspose.PDF-FOSS-for-TypeScript
npm install
npm run buildimport { Document } from '@asposefoss/pdf';
const doc = Document.OpenFile('in.pdf');
const svg = doc.Pages[0].ToSvg(); // standalone <svg> string
// fs.writeFileSync('page1.svg', svg);
const png = doc.Pages[0].ToImage({ scale: 2 }); // Uint8Array of PNG bytes @144 DPI
// fs.writeFileSync('page1.png', png);
const html = doc.ToHtml(); // standalone semantic HTML, all pages
// fs.writeFileSync('out.html', html);
const md = doc.ToMarkdown(); // GFM Markdown, all pages
// fs.writeFileSync('out.md', md);
const docx = doc.ToDocx(); // .docx bytes, reflowed, images in the package
// fs.writeFileSync('out.docx', docx);
const fixed = doc.ToDocx({ mode: 'textbox' }); // .docx keeping each page's own geometry
// fs.writeFileSync('fixed.docx', fixed);
טען קובץ PDF, ערוך את העמודים והמטא-נתונים שלו, וכתוב אותו בחזרה עם דחיסה.
import { Document } from '@asposefoss/pdf';
// Open from disk (or Document.Open(uint8array) for in-memory data)
const doc = Document.OpenFile('input.pdf');
// Inspect and edit pages
console.log(doc.Pages.length);
doc.Pages[0].Rotate = 90;
doc.RemovePage(2); // 1-based page number
doc.Reorder([3, 1, 2]);
// Metadata
doc.SetMetadata({ title: 'Report', author: 'Jane', custom: { Dept: 'R&D' } });
// Save
doc.WriteTo('output.pdf'); // or: const bytes = doc.Save();
doc.WriteTo('small.pdf', { compressed: true }); // xref stream + object streams
התחל מסמך ריק, הוסף טקסט ממוקם, והוסף דף נוסף.
import { Document, PageFormat } from '@asposefoss/pdf';
const doc = Document.New(PageFormat.A4); // one blank A4 page
doc.Pages[0].AddText('Hello', 72, 720, { fontSize: 14 });
doc.AddPage(PageFormat.A4.landscape()); // append more as you go
doc.WriteTo('scratch.pdf');
הצפין PDF קיים עם זוג סיסמת משתמש/בעלים ו-AES-256, תוך הגבלת העתקה ושינוי.
import { Document } from '@asposefoss/pdf';
const doc = Document.OpenFile('in.pdf');
doc.WriteTo('locked.pdf', {
encrypt: {
userPassword: 'open-me', // required to open (default '')
ownerPassword: 'full-rights', // default: same as userPassword
algorithm: 'aes256', // 'aes256' (default) | 'aes128' | 'rc4'
permissions: { copying: false, modifying: false },
encryptMetadata: true,
},
});
Aspose.PDF FOSS for TypeScript משוחרר תחת רישיון MIT, מאפשר שימוש חופשי במוצרים מסחריים ללא תשלומי זמן ריצה. הקוד המקור זמין לציבור ב-GitHub.
החבילה ממוקדת ב-Node.js 22 ומעלה ואין לה תלות אחרות בזמן ריצה. ראה את סעיף ה-install למעלה עבור פקודת ה-install הנוכחית.
הספרייה קוראת וכותבת PDF, Markdown, SVG ו-TIFF, ויכולה לייצר פלט DOCX, HTML, PNG ו-EPUB.
השתמש ב-Document.New(PageFormat.A4) כדי ליצור מסמך ריק, לאחר מכן הוסף עמודים ושמור באמצעות Document.WriteTo().
לא נדרש מפתח רישיון או שלב הפעלה. הספרייה פועלת ללא רישיון במלואה ללא עלות תחת רישיון MIT.