Unknown type: Comment

  • Chris Thielen

    Chris Thielen - 2010-09-23

    Thank you for the effort on PDFClown, it seems to be great so far.   I've run into a slight snag.

    I generate many PDFs from HTML, using PD4ML.  I am now trying to use PDFClown to combine them into a single PDF with bookmarks.  PDFClown fails to .clone() Documents generated using PD4ML and I can't figure out why, nor how to fix it.

    My source code is as follows:

           final File testoutput = Pd4mlImpl.getInstance(HTMLToPdf.Implementation.Pd4ml).convert(new File("/Users/sone/test.html"));
            final File srcPDF = new File("/Users/sone/test.pdf");
            it.stefanochizzolini.clown.files.File outputFile = new it.stefanochizzolini.clown.files.File();
            final Document outputDocument = outputFile.getDocument();
            final PageManager pageManager = new PageManager(outputDocument);
            pageManager.add(new it.stefanochizzolini.clown.files.File(srcPDF.getAbsolutePath()).getDocument());

    Here is the error I get from PDFClown:

    Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: Unknown type: Comment
        at it.stefanochizzolini.clown.objects.PdfIndirectObject.getDataObject(PdfIndirectObject.java:199)
        at it.stefanochizzolini.clown.files.IndirectObjects.addExternal(IndirectObjects.java:207)
        at it.stefanochizzolini.clown.objects.PdfIndirectObject.clone(PdfIndirectObject.java:152)
        at it.stefanochizzolini.clown.objects.PdfReference.clone(PdfReference.java:168)
        at it.stefanochizzolini.clown.objects.PdfArray.clone(PdfArray.java:86)
        at it.stefanochizzolini.clown.documents.Page.clone(Page.java:255)
        at it.stefanochizzolini.clown.documents.Page.clone(Page.java:64)
        at it.stefanochizzolini.clown.documents.Document.contextualize(Document.java:173)
        at it.stefanochizzolini.clown.documents.Document.contextualize(Document.java:185)
        at it.stefanochizzolini.clown.tools.PageManager.add(PageManager.java:91)
        at it.stefanochizzolini.clown.tools.PageManager.add(PageManager.java:74)
        at test.URLsToPDF.main(URLsToPDF.java:113)
    Caused by: java.lang.RuntimeException: Unknown type: Comment
        at it.stefanochizzolini.clown.tokens.Parser.parsePdfObject(Parser.java:796)
        at it.stefanochizzolini.clown.objects.PdfIndirectObject.getDataObject(PdfIndirectObject.java:196)

    I naively attempted to get things to work by modifying Parser.java, adding the "missing" case statement for Comment, making it return an empty pdf string.  The errors went away, but it was obviously the wrong thing to do, as the output PDF simply contained two (apparently) blank pages.

    Here's a link to the PD4ML PDF I am using as a test case, which fails to .clone using PDFClown:

  • Chris Thielen

    Chris Thielen - 2010-09-27

    Works like a charm! 
    Much appreciated, Stefano.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks