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

liu edited comment on PDFBOX-5839 at 6/14/24 8:53 AM:
------------------------------------------------------

2.0.31 version can be get an exception.
{code:java}
//代码占位符

public static void main(String[] args) throws IOException, InterruptedException 
{
   File file = new File("C:\\Users\\LYCIT\\Downloads\\2.pdf");
   final PDDocument load = PDDocument.load(file, 
MemoryUsageSetting.setupTempFileOnly());
   PDFRenderer renderer = new PDFRenderer(load);
   renderer.setSubsamplingAllowed(true);
   int pageIndex = 0;
   float scale = 2f;
   BufferedImage bufferedImage = renderer.renderImage(pageIndex, scale, 
ImageType.RGB);
}{code}


was (Author: JIRAUSER297279):
2.0.31 version can be get an exception.
{code:java}
//代码占位符
{code}
public static void main(String[] args) throws IOException, InterruptedException 
\{ File file = new File("C:\\Users\\LYCIT\\Downloads\\加水印pdfbox报错\\2.pdf"); 
final PDDocument load = PDDocument.load(file, 
MemoryUsageSetting.setupTempFileOnly()); PDFRenderer renderer = new 
PDFRenderer(load); renderer.setSubsamplingAllowed(true); int pageIndex = 0; 
float scale = 2f; BufferedImage bufferedImage = renderer.renderImage(pageIndex, 
scale, ImageType.RGB); }

> ClassCastException: org.apache.pdfbox.cos.COSNull cannot be cast to 
> org.apache.pdfbox.cos.COSDictionary
> -------------------------------------------------------------------------------------------------------
>
>                 Key: PDFBOX-5839
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-5839
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Rendering
>    Affects Versions: 2.0.31, 3.0.2 PDFBox
>            Reporter: liu
>            Priority: Major
>         Attachments: 1.pdf, 2.pdf, image-2024-06-14-15-36-01-099.png, 
> image-2024-06-14-16-35-39-381.png, image-2024-06-14-16-39-47-557.png
>
>
> [^1.pdf][^2.pdf]
> ^!image-2024-06-14-15-36-01-099.png|width=395,height=214!^
> When rendering 1.pdf and 2.pdf, there will be a ClassCastException problem.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to