Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

45
LINES

< > BotCompany Repo | #1028292 // Test PDFBox-Layout [dev.]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 5264K of libraries. Click here for Pure Java version (2317L/13K).

!7

import org.apache.pdfbox.pdmodel.font.*;
import rst.pdfbox.layout.text.*;
import rst.pdfbox.layout.elements.*;
import rst.pdfbox.layout.elements.Document;
import rst.pdfbox.layout.util.*;

lib 1400393 // pdfbox2-layout
lib 1400391 // pdfbox
lib 1400394 // fontbox
lib 1400355 // commons logging

cprint {
  start-thread {
    Document document = new(Constants.A4, 40, 60, 40, 60);
     
    new Paragraph title;
    title.addMarkup("*This is a header*", 30, BaseFont.Times);
    document.add(title);
    document.add(new VerticalSpacer(5));

    new Paragraph paragraph;
    paragraph.addText(repString("Hello World. ", 100), 20, PDType1Font.HELVETICA);
    document.add(paragraph);
    
    S bulletOdd = CompatibilityHelper.getBulletCharacter(1) + " ";
    
    paragraph = new Paragraph;
    paragraph.add(new Indent(bulletOdd, 4, SpaceUnit.em, 11,
      PDType1Font.TIMES_BOLD, Alignment.Right));
    paragraph.addMarkup("This is a list item\n", 11, BaseFont.Times);
    paragraph.add(new Indent(bulletOdd, 4, SpaceUnit.em, 11,
      PDType1Font.TIMES_BOLD, Alignment.Right));
    paragraph.addMarkup("Another list item\n", 11, BaseFont.Times);
    document.add(paragraph);
     
    File f = prepareProgramFile("test1.pdf");
    {
      temp OutputStream outputStream = newFileOutputStream(f);
      document.save(outputStream);
    }
    printFileInfo(f);
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1028292
Snippet name: Test PDFBox-Layout [dev.]
Eternal ID of this version: #1028292/15
Text MD5: c588a72ee6756a88a60fe98ef9a2f44b
Transpilation MD5: d4f8f222e1b6394cf8767246824ff5af
Author: stefan
Category: javax / pdf
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-06-09 18:46:26
Source code size: 1415 bytes / 45 lines
Pitched / IR pitched: No / No
Views / Downloads: 255 / 613
Version history: 14 change(s)
Referenced in: [show references]