[jira] [Created] (FOP-2263) PDFDocumentGraphics2D.closePage() should not nullify currentStream
Max Gilead created FOP-2263: --- Summary: PDFDocumentGraphics2D.closePage() should not nullify currentStream Key: FOP-2263 URL: https://issues.apache.org/jira/browse/FOP-2263 Project: Fop Issue Type: Improvement Components: pdf Affects Versions: 1.1 Reporter: Max Gilead Priority: Minor In version 1.1 the PDFDocumentGraphics2D.closePage() method nullifies currentStream in line 281: currentStream = null; I suggest to remove this line. Nullifying currentStream prevents the user from obtaining raw (not wrapped inside a PDF document) output using the PDFGraphics2D.getString() method. PDFGraphics2D.dispose() nullifies currentStream so there seems to be no reason for .closePage() to do the same. Current workaround is to create a new PDFDocumentGraphics2D instance like this: g = new PDFDocumentGraphics2D(false, out, w, h) { @Override protected void closePage() { content = super.getString() + "Q\n"; super.closePage(); } }; which works (and proves the data is there) but is, quite obviously, ugly and fragile. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Created] (FOP-2273) Stroke miter limit is not clamped when writing PDFs
Max Gilead created FOP-2273: --- Summary: Stroke miter limit is not clamped when writing PDFs Key: FOP-2273 URL: https://issues.apache.org/jira/browse/FOP-2273 Project: Fop Issue Type: Bug Components: pdf Affects Versions: trunk Reporter: Max Gilead org.apache.fop.svg.PDFGraphics2D line 1240 (as of SVN revision 148001 [1]) is: float ml = bs.getMiterLimit(); but should be (or equivalent): float ml = Math.max(1.0f, bs.getMiterLimit()); Acrobat Reader (on all platforms) refuses to load graphics data after encountering miter limit < 1.0 and reports an error. I can't find a reference to the valid range in the PDF spec but Inkscape also had a problem with values less than 1.0 [2] and SVG spec mandates values >= 1.0 as well [3] so clamping the value to 1.0 or more seems like the right thing to do. [1] http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphics2D.java?revision=1480018&view=markup [2] http://webcache.googleusercontent.com/search?q=cache:RHSt5Wk7-uQJ:inkscape-forum.andreas-s.net/topic/71990+&cd=7&hl=en&ct=clnk&gl=uk&client=firefox-beta [3] http://www.w3.org/TR/SVG11/painting.html#StrokeMiterlimitProperty -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (FOP-2273) Stroke miter limit is not clamped when writing PDFs
[ https://issues.apache.org/jira/browse/FOP-2273?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13707010#comment-13707010 ] Max Gilead commented on FOP-2273: - There should be two lines but Acrobat Reader shows only one. There is no error described above as I couldn't get it to display one with this simple example (the original PDF was generated using a 3rd party library). import org.apache.fop.svg.PDFDocumentGraphics2D; import org.apache.pdfbox.pdfwriter.COSWriter; import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.PDPage; import org.apache.pdfbox.pdmodel.common.PDRectangle; import org.apache.pdfbox.pdmodel.edit.PDPageContentStream; import org.apache.xmlgraphics.java2d.GraphicContext; import java.awt.BasicStroke; import java.io.BufferedOutputStream; import java.io.ByteArrayOutputStream; import java.io.FileOutputStream; import java.io.OutputStream; public class FopTest { public static void main(String[] args) throws Exception { final String[] content = new String[1]; PDFDocumentGraphics2D g = new PDFDocumentGraphics2D(false, new ByteArrayOutputStream(), 100, 100) { @Override protected void closePage() { content[0] = super.getString() + "Q\n"; super.closePage(); } }; g.setGraphicContext(new GraphicContext()); g.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f)); g.drawLine(0, 100, 100, 0); g.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 0.1f)); g.drawLine(0, 0, 100, 100); g.finish(); g.dispose(); final PDDocument document = new PDDocument(); PDPage page = new PDPage(new PDRectangle(100, 100)); document.addPage(page); PDPageContentStream writer = new PDPageContentStream(document, page); writer.appendRawCommands(content[0].getBytes()); writer.close(); OutputStream out = new BufferedOutputStream(new FileOutputStream("FOP_Test.pdf")); COSWriter coswriter = null; coswriter = new COSWriter(out); coswriter.write(document); coswriter.close(); document.close(); out.close(); } } > Stroke miter limit is not clamped when writing PDFs > --- > > Key: FOP-2273 > URL: https://issues.apache.org/jira/browse/FOP-2273 > Project: Fop > Issue Type: Bug > Components: pdf >Affects Versions: trunk >Reporter: Max Gilead > Labels: easyfix > > org.apache.fop.svg.PDFGraphics2D line 1240 (as of SVN revision 148001 [1]) is: > float ml = bs.getMiterLimit(); > but should be (or equivalent): > float ml = Math.max(1.0f, bs.getMiterLimit()); > Acrobat Reader (on all platforms) refuses to load graphics data after > encountering miter limit < 1.0 and reports an error. > I can't find a reference to the valid range in the PDF spec but Inkscape also > had a problem with values less than 1.0 [2] and SVG spec mandates values >= > 1.0 as well [3] so clamping the value to 1.0 or more seems like the right > thing to do. > [1] > http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphics2D.java?revision=1480018&view=markup > [2] > http://webcache.googleusercontent.com/search?q=cache:RHSt5Wk7-uQJ:inkscape-forum.andreas-s.net/topic/71990+&cd=7&hl=en&ct=clnk&gl=uk&client=firefox-beta > [3] http://www.w3.org/TR/SVG11/painting.html#StrokeMiterlimitProperty -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (FOP-2273) Stroke miter limit is not clamped when writing PDFs
[ https://issues.apache.org/jira/browse/FOP-2273?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Max Gilead updated FOP-2273: Attachment: FOP_Test.pdf Test app output > Stroke miter limit is not clamped when writing PDFs > --- > > Key: FOP-2273 > URL: https://issues.apache.org/jira/browse/FOP-2273 > Project: Fop > Issue Type: Bug > Components: pdf >Affects Versions: trunk >Reporter: Max Gilead > Labels: easyfix > Attachments: FOP_Test.pdf > > > org.apache.fop.svg.PDFGraphics2D line 1240 (as of SVN revision 148001 [1]) is: > float ml = bs.getMiterLimit(); > but should be (or equivalent): > float ml = Math.max(1.0f, bs.getMiterLimit()); > Acrobat Reader (on all platforms) refuses to load graphics data after > encountering miter limit < 1.0 and reports an error. > I can't find a reference to the valid range in the PDF spec but Inkscape also > had a problem with values less than 1.0 [2] and SVG spec mandates values >= > 1.0 as well [3] so clamping the value to 1.0 or more seems like the right > thing to do. > [1] > http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphics2D.java?revision=1480018&view=markup > [2] > http://webcache.googleusercontent.com/search?q=cache:RHSt5Wk7-uQJ:inkscape-forum.andreas-s.net/topic/71990+&cd=7&hl=en&ct=clnk&gl=uk&client=firefox-beta > [3] http://www.w3.org/TR/SVG11/painting.html#StrokeMiterlimitProperty -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (FOP-2273) Stroke miter limit is not clamped when writing PDFs
[ https://issues.apache.org/jira/browse/FOP-2273?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13707026#comment-13707026 ] Max Gilead commented on FOP-2273: - As I mentioned in the previous comment: there should be two lines but Acrobat Reader shows only one. Do you see two diagonal lines in AR or only one? Also, there is no error described above as I couldn't get it to display one with this simple example (the original PDF was generated using a 3rd party library) -- This is just a clarification as there is no error popup when opening the attached file yet the end result is the same -- the graphics rendering stops once Acrobat encounters a shape with a miter limit below 1.0 > Stroke miter limit is not clamped when writing PDFs > --- > > Key: FOP-2273 > URL: https://issues.apache.org/jira/browse/FOP-2273 > Project: Fop > Issue Type: Bug > Components: pdf >Affects Versions: trunk >Reporter: Max Gilead > Labels: easyfix > Attachments: FOP_Test.pdf, PDF-Rendering.png > > > org.apache.fop.svg.PDFGraphics2D line 1240 (as of SVN revision 148001 [1]) is: > float ml = bs.getMiterLimit(); > but should be (or equivalent): > float ml = Math.max(1.0f, bs.getMiterLimit()); > Acrobat Reader (on all platforms) refuses to load graphics data after > encountering miter limit < 1.0 and reports an error. > I can't find a reference to the valid range in the PDF spec but Inkscape also > had a problem with values less than 1.0 [2] and SVG spec mandates values >= > 1.0 as well [3] so clamping the value to 1.0 or more seems like the right > thing to do. > [1] > http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphics2D.java?revision=1480018&view=markup > [2] > http://webcache.googleusercontent.com/search?q=cache:RHSt5Wk7-uQJ:inkscape-forum.andreas-s.net/topic/71990+&cd=7&hl=en&ct=clnk&gl=uk&client=firefox-beta > [3] http://www.w3.org/TR/SVG11/painting.html#StrokeMiterlimitProperty -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Comment Edited] (FOP-2273) Stroke miter limit is not clamped when writing PDFs
[ https://issues.apache.org/jira/browse/FOP-2273?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13707026#comment-13707026 ] Max Gilead edited comment on FOP-2273 at 7/12/13 3:47 PM: -- As I mentioned in the previous comment: there should be two lines but Acrobat Reader shows only one. Do you see two diagonal lines in AR or only one? Also, there is no error popup when opening the attached file but the end result is the same -- the graphics rendering stops once Acrobat encounters a shape with a miter limit below 1.0 was (Author: maxgilead): As I mentioned in the previous comment: there should be two lines but Acrobat Reader shows only one. Do you see two diagonal lines in AR or only one? Also, there is no error described above as I couldn't get it to display one with this simple example (the original PDF was generated using a 3rd party library) -- This is just a clarification as there is no error popup when opening the attached file yet the end result is the same -- the graphics rendering stops once Acrobat encounters a shape with a miter limit below 1.0 > Stroke miter limit is not clamped when writing PDFs > --- > > Key: FOP-2273 > URL: https://issues.apache.org/jira/browse/FOP-2273 > Project: Fop > Issue Type: Bug > Components: pdf >Affects Versions: trunk >Reporter: Max Gilead > Labels: easyfix > Attachments: FOP_Test.pdf, PDF-Rendering.png > > > org.apache.fop.svg.PDFGraphics2D line 1240 (as of SVN revision 148001 [1]) is: > float ml = bs.getMiterLimit(); > but should be (or equivalent): > float ml = Math.max(1.0f, bs.getMiterLimit()); > Acrobat Reader (on all platforms) refuses to load graphics data after > encountering miter limit < 1.0 and reports an error. > I can't find a reference to the valid range in the PDF spec but Inkscape also > had a problem with values less than 1.0 [2] and SVG spec mandates values >= > 1.0 as well [3] so clamping the value to 1.0 or more seems like the right > thing to do. > [1] > http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphics2D.java?revision=1480018&view=markup > [2] > http://webcache.googleusercontent.com/search?q=cache:RHSt5Wk7-uQJ:inkscape-forum.andreas-s.net/topic/71990+&cd=7&hl=en&ct=clnk&gl=uk&client=firefox-beta > [3] http://www.w3.org/TR/SVG11/painting.html#StrokeMiterlimitProperty -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (FOP-2273) Stroke miter limit is not clamped when writing PDFs
[ https://issues.apache.org/jira/browse/FOP-2273?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Max Gilead updated FOP-2273: Attachment: Acrobat Reader.png > Stroke miter limit is not clamped when writing PDFs > --- > > Key: FOP-2273 > URL: https://issues.apache.org/jira/browse/FOP-2273 > Project: Fop > Issue Type: Bug > Components: pdf >Affects Versions: trunk >Reporter: Max Gilead > Labels: easyfix > Attachments: Acrobat Reader.png, expected result.png, FOP_Test.pdf, > PDF-Rendering.png > > > org.apache.fop.svg.PDFGraphics2D line 1240 (as of SVN revision 148001 [1]) is: > float ml = bs.getMiterLimit(); > but should be (or equivalent): > float ml = Math.max(1.0f, bs.getMiterLimit()); > Acrobat Reader (on all platforms) refuses to load graphics data after > encountering miter limit < 1.0 and reports an error. > I can't find a reference to the valid range in the PDF spec but Inkscape also > had a problem with values less than 1.0 [2] and SVG spec mandates values >= > 1.0 as well [3] so clamping the value to 1.0 or more seems like the right > thing to do. > [1] > http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphics2D.java?revision=1480018&view=markup > [2] > http://webcache.googleusercontent.com/search?q=cache:RHSt5Wk7-uQJ:inkscape-forum.andreas-s.net/topic/71990+&cd=7&hl=en&ct=clnk&gl=uk&client=firefox-beta > [3] http://www.w3.org/TR/SVG11/painting.html#StrokeMiterlimitProperty -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (FOP-2273) Stroke miter limit is not clamped when writing PDFs
[ https://issues.apache.org/jira/browse/FOP-2273?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Max Gilead updated FOP-2273: Attachment: expected result.png > Stroke miter limit is not clamped when writing PDFs > --- > > Key: FOP-2273 > URL: https://issues.apache.org/jira/browse/FOP-2273 > Project: Fop > Issue Type: Bug > Components: pdf >Affects Versions: trunk >Reporter: Max Gilead > Labels: easyfix > Attachments: Acrobat Reader.png, expected result.png, FOP_Test.pdf, > PDF-Rendering.png > > > org.apache.fop.svg.PDFGraphics2D line 1240 (as of SVN revision 148001 [1]) is: > float ml = bs.getMiterLimit(); > but should be (or equivalent): > float ml = Math.max(1.0f, bs.getMiterLimit()); > Acrobat Reader (on all platforms) refuses to load graphics data after > encountering miter limit < 1.0 and reports an error. > I can't find a reference to the valid range in the PDF spec but Inkscape also > had a problem with values less than 1.0 [2] and SVG spec mandates values >= > 1.0 as well [3] so clamping the value to 1.0 or more seems like the right > thing to do. > [1] > http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphics2D.java?revision=1480018&view=markup > [2] > http://webcache.googleusercontent.com/search?q=cache:RHSt5Wk7-uQJ:inkscape-forum.andreas-s.net/topic/71990+&cd=7&hl=en&ct=clnk&gl=uk&client=firefox-beta > [3] http://www.w3.org/TR/SVG11/painting.html#StrokeMiterlimitProperty -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira