You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "ASF subversion and git services (JIRA)" <ji...@apache.org> on 2018/12/06 20:12:00 UTC

[jira] [Commented] (PDFBOX-3359) Drawing to Graphics2D / ScratchFileBuffer not closed

    [ https://issues.apache.org/jira/browse/PDFBOX-3359?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16711978#comment-16711978 ] 

ASF subversion and git services commented on PDFBOX-3359:
---------------------------------------------------------

Commit 1848359 from tilman@apache.org in branch 'pdfbox/trunk'
[ https://svn.apache.org/r1848359 ]

PDFBOX-2999, PDFBOX-3359: close existing buffer to avoid "ScratchFileBuffer not closed" log message

> Drawing to Graphics2D / ScratchFileBuffer not closed
> ----------------------------------------------------
>
>                 Key: PDFBOX-3359
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-3359
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Rendering
>    Affects Versions: 2.0.1
>            Reporter: Ivan Ridao Freitas
>            Priority: Major
>             Fix For: 3.0.0 PDFBox
>
>
> First, there is a little bug on PDFRenderer.renderPageToGraphics(int pageIndex, Graphics2D graphics, float scale) when using scale != 1 the call to clearRect() fills the original size with white background, but it should fill the scaled size.
> Second, I implemented a JPanel which is painted using that function and on every paint this message goes to the console:
> "DEBUG ScratchFileBuffer:516 - ScratchFileBuffer not closed!". Here is the code to test it, run it and *resize the JFrame*:
> {code:title=PanelTest.java|borderStyle=solid}
> import java.awt.Dimension;
> import java.awt.Graphics;
> import java.awt.Graphics2D;
> import java.io.File;
> import java.io.IOException;
> import javax.swing.JFrame;
> import javax.swing.JPanel;
> import javax.swing.SwingUtilities;
> import javax.swing.WindowConstants;
> import org.apache.pdfbox.pdmodel.PDDocument;
> import org.apache.pdfbox.rendering.PDFRenderer;
> public class PanelTest {
>    
>     private static JPanel getTestPanel() {
>         PDDocument doc = null;
>         try {
>             doc = PDDocument.load(new File("anyfile.pdf"));
>         } catch (IOException e) {
>             e.printStackTrace();
>         }
>         final PDFRenderer renderer = new PDFRenderer(doc);
>         JPanel panel = new JPanel() {
>             @Override
>             protected void paintComponent(Graphics g) {
>                 try {
>                     renderer.renderPageToGraphics(0, (Graphics2D) g, 0.5f);
>                 } catch (IOException e) {
>                     e.printStackTrace();
>                 }
>             }
>         };
>         return panel;
>     }
>     public static void main(String[] args) throws Exception {
>         SwingUtilities.invokeLater(new Runnable() {
>             @Override
>             public void run() {
>                 JFrame frame = new JFrame();
>                 frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
>                 frame.add(getTestPanel());
>                 frame.pack();
>                 frame.setSize(600, 400);
>                 Dimension paneSize = frame.getSize();
>                 Dimension screenSize = frame.getToolkit().getScreenSize();
>                 frame.setLocation((screenSize.width - paneSize.width) / 2, (screenSize.height - paneSize.height) / 2);
>                 frame.setTitle("Test");
>                 frame.setVisible(true);
>             }
>         });
>     }
> }
> {code}
> Ivan 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org