Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions openpdf-core/src/main/java/org/openpdf/text/pdf/PdfWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,22 @@ protected PdfWriter(PdfDocument document, OutputStream os) {
directContentUnder = new PdfContentByte(this);
}

/**
* Creates and configures a PdfDocument using the settings.
*
* @param document The <CODE>Document</CODE> that will be used
* @return a configured <CODE>PdfDocument</CODE>
*/

public static PdfDocument createPdfDocument(Document document) {
PdfDocument pdf = new PdfDocument();

pdf.setTextRenderingOptions(document.getTextRenderingOptions());
pdf.setGlyphLayoutManager(document.getGlyphLayoutManager());

return pdf;
}

/**
* Use this method to get an instance of the <CODE>PdfWriter</CODE>.
*
Expand All @@ -766,12 +782,13 @@ protected PdfWriter(PdfDocument document, OutputStream os) {

public static PdfWriter getInstance(Document document, OutputStream os)
throws DocumentException {
PdfDocument pdf = new PdfDocument();
pdf.setTextRenderingOptions(document.getTextRenderingOptions());
pdf.setGlyphLayoutManager(document.getGlyphLayoutManager());
PdfDocument pdf = createPdfDocument(document);

document.addDocListener(pdf);

PdfWriter writer = new PdfWriter(pdf, os);
pdf.addWriter(writer);

return writer;
}

Expand All @@ -787,13 +804,14 @@ public static PdfWriter getInstance(Document document, OutputStream os)

public static PdfWriter getInstance(Document document, OutputStream os, DocListener listener)
throws DocumentException {
PdfDocument pdf = new PdfDocument();
pdf.setTextRenderingOptions(document.getTextRenderingOptions());
pdf.setGlyphLayoutManager(document.getGlyphLayoutManager());
PdfDocument pdf = createPdfDocument(document);

pdf.addDocListener(listener);
document.addDocListener(pdf);

PdfWriter writer = new PdfWriter(pdf, os);
pdf.addWriter(writer);

return writer;
}

Expand Down