各種の開発言語(C/C++、.Net、Java、Pythonなど)を使用して新たにPDFファイルを作成できます。
PDFファイルを作成した後、Toolbox Add-onを使用してコンテンツの追加、フォーム フィールドの追加、メタデータの管理などができます。
Toolbox Add-onのAPIリファレンスはこちらです。(すべて英文)
C#のサンプルプロジェクトではPdftools SDK(Toolbox Add-on)ライブラリ(DLL)をNuGetから自動でダウンロードします。
CのサンプルプロジェクトにはPdftools SDK(Toolbox Add-on)ライブラリ(DLL)が含まれています。
ライセンスキー無し(無償)で試用できます。ただし、結果に「透かし」が入ります。
「透かし」の削除をご希望の場合は問い合わせページまたはメールでお問い合わせください。
License Agreement(利用許諾契約書)が含まれていますので必ず確認してください。
全1ページの新しいPDFドキュメントを作成し、このページの指定された矩形領域内に両端揃えレイアウトのテキストブロックを追加します。
// Create output document using (Stream outStream = new FileStream(outPath, FileMode.CreateNew, FileAccess.ReadWrite)) using (Document outDoc = Document.Create(outStream, null, null)) { Font font = Font.CreateFromSystem(outDoc, "Arial", "Italic", true); // Create page Page outPage = Page.Create(outDoc, PageSize); // Add text as justified text LayoutText(outDoc, outPage, textPath, font, 20); // Add page to document outDoc.Pages.Add(outPage); }
private static void LayoutText(Document outputDoc, Page outPage, string textPath, Font font, double fontSize) { // Create content generator using ContentGenerator gen = new ContentGenerator(outPage.Content, false); // Create text object Text text = Text.Create(outputDoc); // Create text generator using TextGenerator textGenerator = new TextGenerator(text, font, fontSize, null); // Calculate position Point position = new Point { X = Border, Y = outPage.Size.Height - Border }; // Move to position textGenerator.MoveTo(position); // Loop through all lines of the textinput string[] lines = File.ReadAllLines(textPath, Encoding.Default); foreach (string line in lines) { // Split string in substrings string[] substrings = line.Split(new char[] { ' ' }, StringSplitOptions.None); string currentLine = null; double maxWidth = outPage.Size.Width - Border * 2; int wordcount = 0; // Loop through all words of input strings foreach (string word in substrings) { string tempLine; // Concatenate substrings to line if (currentLine != null) tempLine = currentLine + " " + word; else tempLine = word; // Calculate the current width of line double width = textGenerator.GetWidth(currentLine); if (textGenerator.GetWidth(tempLine) > maxWidth) { // Calculate the word spacing textGenerator.WordSpacing = (maxWidth - width) / (wordcount - 1); // Paint on new line textGenerator.ShowLine(currentLine); textGenerator.WordSpacing = 0; currentLine = word; wordcount = 1; } else { currentLine = tempLine; wordcount++; } } textGenerator.WordSpacing = 0; // Add given stamp string textGenerator.ShowLine(currentLine); } // Paint the positioned text gen.PaintText(text); }
質問のページからお送りいただくようお願いします。
または、メールでsupport@trustss.co.jpあてにお送りください。
ご購入前の技術的質問も無償で対応します。サポート受付ページからお願いします。