-
Notifications
You must be signed in to change notification settings - Fork 364
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Based heavily on code by @syjer whom I'm indebted to. Thanks. Still todo: + Prevent duplicate file embeds. Possibly create a map of uris to PDComplexFileSpecification and reuse if encountered again. I have to peruse the PDF spec to see if this is allowed. + Logging on fail.
- Loading branch information
Showing
5 changed files
with
193 additions
and
22 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
openhtmltopdf-examples/src/main/resources/visualtest/html/issue-508-file-embed.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<html> | ||
<head> | ||
<style> | ||
@page { | ||
size: 200px 200px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
Embedded <a href="stylesheets/basic.css" download="basic.css" data-content-type="text/plain">text <br/> document</a>. | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
openhtmltopdf-pdfbox/src/main/java/com/openhtmltopdf/pdfboxout/AnnotationContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.openhtmltopdf.pdfboxout; | ||
|
||
import org.apache.pdfbox.pdmodel.common.PDRectangle; | ||
import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation; | ||
import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationFileAttachment; | ||
import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationLink; | ||
import org.apache.pdfbox.pdmodel.interactive.annotation.PDBorderStyleDictionary; | ||
|
||
public abstract class AnnotationContainer { | ||
public void setRectangle(PDRectangle rectangle) { | ||
getPdAnnotation().setRectangle(rectangle); | ||
} | ||
|
||
public void setPrinted(boolean printed) { | ||
getPdAnnotation().setPrinted(printed); | ||
} | ||
|
||
public void setQuadPoints(float[] quadPoints) {}; | ||
|
||
public abstract void setBorderStyle(PDBorderStyleDictionary styleDict); | ||
|
||
public abstract PDAnnotation getPdAnnotation(); | ||
|
||
public static class PDAnnotationFileAttachmentContainer extends AnnotationContainer { | ||
private final PDAnnotationFileAttachment pdAnnotationFileAttachment; | ||
|
||
public PDAnnotationFileAttachmentContainer(PDAnnotationFileAttachment pdAnnotationFileAttachment) { | ||
this.pdAnnotationFileAttachment = pdAnnotationFileAttachment; | ||
} | ||
|
||
@Override | ||
public PDAnnotation getPdAnnotation() { | ||
return pdAnnotationFileAttachment; | ||
} | ||
|
||
@Override | ||
public void setBorderStyle(PDBorderStyleDictionary styleDict) { | ||
pdAnnotationFileAttachment.setBorderStyle(styleDict); | ||
} | ||
} | ||
|
||
public static class PDAnnotationLinkContainer extends AnnotationContainer { | ||
private final PDAnnotationLink pdAnnotationLink; | ||
|
||
public PDAnnotationLinkContainer(PDAnnotationLink pdAnnotationLink) { | ||
this.pdAnnotationLink = pdAnnotationLink; | ||
} | ||
|
||
@Override | ||
public PDAnnotation getPdAnnotation() { | ||
return pdAnnotationLink; | ||
} | ||
|
||
@Override | ||
public void setQuadPoints(float[] quadPoints) { | ||
pdAnnotationLink.setQuadPoints(quadPoints); | ||
} | ||
|
||
@Override | ||
public void setBorderStyle(PDBorderStyleDictionary styleDict) { | ||
pdAnnotationLink.setBorderStyle(styleDict); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters