Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test for issue #261. Confirm fast renderer does not launch exception #414

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<html>
<head>
<title>Sample file</title>
<style>
div,body,html{border:0;margin:0;padding:0}
.container{page-break-after:always}
</style>
</head>
<body>
<div class="container">
<h2>Table of Contents</h2>
<ul>
<li><a href="#actionHistory">History</a></li>
</ul>
</div>
<div id="actionHistory"></div>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.apache.pdfbox.pdmodel.interactive.form.PDTextField;
import org.apache.pdfbox.util.Charsets;
import org.hamcrest.CustomTypeSafeMatcher;
import org.junit.Ignore;
import org.junit.Test;

import com.openhtmltopdf.pdfboxout.PdfRendererBuilder;
Expand Down Expand Up @@ -717,6 +716,24 @@ public void testInputWithoutNameAttribute() throws IOException {
assertEquals(0, form.getFields().size());
remove("input-without-name-attribute", doc);
}

/**
* See issue: https://github.com/danfickle/openhtmltopdf/issues/261 .
* This will fail using the slow renderer as the calculated index for the link is wrong.
*/
@Test
public void testIssue261IndexOutOfBoundExceptionWithWrongPageLink() throws IOException {
PDDocument doc = run("issue-261-index-out-of-bound-exception");
assertEquals(1, doc.getPage(0).getAnnotations().size());

PDAnnotationLink link = (PDAnnotationLink) doc.getPage(0).getAnnotations().get(0);
PDActionGoTo action = (PDActionGoTo) link.getAction();
assertThat(action.getDestination(), instanceOf(PDPageXYZDestination.class));
PDPageXYZDestination dest = (PDPageXYZDestination) action.getDestination();
// note, the div id="actionHistory" is empty, so it will not generate a second page
assertEquals(dest.getPage(), doc.getPage(0));
remove("issue-261-index-out-of-bound-exception", doc);
}

// TODO:
// + More form controls.
Expand Down