forked from qzind/tray
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PDF font render improvements (qzind#1108)
* PDF font rendering improvements * Improvements to "ignoreTransparency" logic Co-authored-by: Berenz <thebrettberenz@gmail.com>
- Loading branch information
Showing
10 changed files
with
645 additions
and
98 deletions.
There are no files selected for viewing
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
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 was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package qz.printer.action.pdf; | ||
|
||
import org.apache.pdfbox.pdmodel.PDDocument; | ||
import org.apache.pdfbox.rendering.PDFRenderer; | ||
import org.apache.pdfbox.rendering.PageDrawer; | ||
import org.apache.pdfbox.rendering.PageDrawerParameters; | ||
import qz.printer.rendering.OpaqueDrawObject; | ||
import qz.printer.rendering.OpaqueGraphicStateParameters; | ||
import qz.printer.rendering.PdfFontPageDrawer; | ||
|
||
import java.io.IOException; | ||
|
||
public class ParamPdfRenderer extends PDFRenderer { | ||
|
||
private boolean useAlternateFontRendering; | ||
private boolean ignoreTransparency; | ||
|
||
public ParamPdfRenderer(PDDocument document, boolean useAlternateFontRendering, boolean ignoreTransparency) { | ||
super(document); | ||
|
||
this.useAlternateFontRendering = useAlternateFontRendering; | ||
this.ignoreTransparency = ignoreTransparency; | ||
} | ||
|
||
@Override | ||
protected PageDrawer createPageDrawer(PageDrawerParameters parameters) throws IOException { | ||
if (useAlternateFontRendering) { | ||
return new PdfFontPageDrawer(parameters, ignoreTransparency); | ||
} else if(ignoreTransparency) { | ||
return new OpaquePageDrawer(parameters); | ||
} | ||
// Fallback to default PageDrawer | ||
return new PageDrawer(parameters); | ||
} | ||
|
||
// override drawer to make use of customized draw object | ||
private static class OpaquePageDrawer extends PageDrawer { | ||
public OpaquePageDrawer(PageDrawerParameters parameters) throws IOException { | ||
super(parameters); | ||
|
||
// Note: These must match PdfFontPageDrawer's ignoreTransparency condition | ||
addOperator(new OpaqueDrawObject()); | ||
addOperator(new OpaqueGraphicStateParameters()); | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.