Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.0.0
Description
error in code of class - org.apache.pdfbox.pdmodel.PDResources
private COSName createKey(COSName kind, String prefix) { COSDictionary dict = (COSDictionary)resources.getDictionaryObject(kind); if (dict == null) { return COSName.getPDFName(prefix + 1); } // find a unique key String key; do { key = prefix + (dict.keySet().size() + 1); } while (dict.containsKey(key)); <--------------- infinite loop of searching for a key return COSName.getPDFName(key); }
my test code:
public class pdfmain_svg { public static void main(String[] args) throws Exception { System.out.println("hello"); PDDocument document = PDDocument.load(new File( "d:\\Project\\pdfbox-image\\Acro6JSGuide.pdf")); float fontSize = 10f; PDFont font = PDType0Font.load(document, new File( "c:\\Windows\\Fonts\\Arial.TTF")); for (int pageIndex = 0; pageIndex < document.getNumberOfPages(); pageIndex++) { System.out.println("page index = " + pageIndex); PDPage page = document.getPage(pageIndex); PDPageContentStream contentStream = new PDPageContentStream( document, page, true, true); contentStream.setFont(font, fontSize); <---------------- hang on page 6 contentStream.setNonStrokingColor(Color.LIGHT_GRAY); contentStream.beginText(); contentStream.newLineAtOffset(100, 100); contentStream.showText("Test printing"); contentStream.endText(); contentStream.close(); } File f = new File("d:\\work\\kostya.pdf"); document.save(f); document.close(); System.out.println("f=" + f.getAbsolutePath() + ": " + f.exists()); } }
Attachments
Attachments
Issue Links
- is duplicated by
-
PDFBOX-2907 Non-termination in PDResources.createKey()
- Closed