Viewing 1 post (of 1 total)
  • Author
    Posts
  • #33733

    I am having trouble producing PDF’s without the “Demo watermark” appearing. Has anyone experienced this? I have the paid version api key, but the demo watermark appears on some pdfs and not others. I have provided a test file that demonstrates this (and also shows how I’m using the java library). I’m using version 4.0.6fx1-SNAPSHOT. Any help is appreciated.

    class PD4MLTest {

    private static String tempDir = “./”;
    private static String apiKey = “_api_key_”;

    private static final String html_showsDemo = “<p>Hello World!</p>”;

    private static final String html_noDemo = “<p>Hello World!</p><pd4ml:page.break>”;

    @Test
    void pdfCreationTest_notWorking() throws Exception {

    PD4ML pd4ml = new PD4ML(apiKey);
    pd4ml.setPageSize(PageSize.LETTER);

    // Convert
    ByteArrayInputStream bais = new ByteArrayInputStream(html_showsDemo.getBytes(StandardCharsets.UTF_8.name()));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    pd4ml.readHTML(bais);
    pd4ml.writePDF(baos);

    InputStream is = new ByteArrayInputStream(baos.toByteArray());
    String filePath = tempDir + “pdf_test_demo.pdf”;
    File targetFile = new File(filePath);
    FileUtils.copyInputStreamToFile(is, targetFile);

    System.out.println(“PDF file created, location: ” + filePath);
    }

    @Test
    void pdfCreationTest_working() throws Exception {

    PD4ML pd4ml = new PD4ML(apiKey);
    pd4ml.setPageSize(PageSize.LETTER);

    // Convert
    ByteArrayInputStream bais = new ByteArrayInputStream(html_noDemo.getBytes(StandardCharsets.UTF_8.name()));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    pd4ml.readHTML(bais);
    pd4ml.writePDF(baos);

    InputStream is = new ByteArrayInputStream(baos.toByteArray());
    String filePath = tempDir + “pdf_test_noDemo.pdf”;
    File targetFile = new File(filePath);
    FileUtils.copyInputStreamToFile(is, targetFile);

    System.out.println(“PDF file created, location: ” + filePath);
    }

    }

    • This topic was modified 5 years, 1 month ago by Burton.
    • This topic was modified 5 years, 1 month ago by Burton.
    Attachments:
    You must be logged in to view attached files.
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.