()
| 8 | |
| 9 | public class DocumentTest implements Executable { |
| 10 | @Override |
| 11 | public void execute() throws Exception { |
| 12 | ByteArrayOutputStream out = new ByteArrayOutputStream(); |
| 13 | try (OutputWStream stream = new OutputWStream(out); |
| 14 | Document doc = Document.makePDF(stream)) { |
| 15 | |
| 16 | try (Canvas canvas = doc.beginPage(100, 100)) { |
| 17 | canvas.annotateNamedDestination(0, 0, "start"); |
| 18 | Paint paint = new Paint().setColor(0xFFFF0000); |
| 19 | Rect rect = Rect.makeXYWH(10, 10, 80, 80); |
| 20 | canvas.drawRect(rect, paint); |
| 21 | canvas.annotateRectWithURL(rect, "https://example.org/"); |
| 22 | canvas.annotateLinkToDestination(Rect.makeXYWH(0, 80, 100, 20), "start"); |
| 23 | } |
| 24 | doc.endPage(); |
| 25 | doc.close(); |
| 26 | } |
| 27 | |
| 28 | byte[] pdfBytes = out.toByteArray(); |
| 29 | if (pdfBytes.length < 4) { |
| 30 | throw new RuntimeException("PDF output too short"); |
| 31 | } |
| 32 | assertEquals((byte) '%', pdfBytes[0]); |
| 33 | assertEquals((byte) 'P', pdfBytes[1]); |
| 34 | assertEquals((byte) 'D', pdfBytes[2]); |
| 35 | assertEquals((byte) 'F', pdfBytes[3]); |
| 36 | } |
| 37 | } |
nothing calls this directly
no test coverage detected