albrechtf / mcf2pdf

"My CEWE Photobook" MCF to PDF converter
Other
41 stars 36 forks source link

IllegalArgumentException: Width (0) and height (0) cannot be <= 0 #50

Closed chharms closed 3 years ago

chharms commented 5 years ago

I last used mcf2pdf on 2018-06-02, and it was working fine on my Fotobuch with excellent result. Awesome! Now I tried again to convert on a new Fotobuch and it failed. I retested to convert the previous Fotobuch (which was working before) and it failed, too. [INFO ] net.sf.mcf2pdf.Mcf2FoConverter Rendering cover... [ERROR] net.sf.mcf2pdf.Main An exception has occured java.lang.IllegalArgumentException: Width (0) and height (0) cannot be <= 0 at java.awt.image.DirectColorModel.createCompatibleWritableRaster(Unknown Source) at java.awt.image.BufferedImage.<init>(Unknown Source) at net.sf.mcf2pdf.pagebuild.BitmapPageBuilder.addToDocumentBuilder(BitmapPageBuilder.java:66) at net.sf.mcf2pdf.Mcf2FoConverter.convert(Mcf2FoConverter.java:211) at net.sf.mcf2pdf.Main.main(Main.java:188)

rbodziony commented 5 years ago

Can you check this version https://github.com/rbodziony/mcf2pdf/releases/tag/0.3.6 with enabled debug and provide log?

chharms commented 5 years ago

Hello, I ran the new version 0.3.6. This time, the 2017 book was generated fine, just some (handled) exceptions. The 2018 book fails now at a later stage (which I did not reach before). I consider the initial issue as solved. Just for information: the newly observed error is caused by a clipart item. After removing that clipart, also the 2018 book can be generated.

chharms commented 5 years ago

For completeness I like to add the 2018 logfile, but "Something went really wrong, and we can’t process that file."

rbodziony commented 5 years ago

Ok can you share part of 2018 book which contains this clipart?

chharms commented 5 years ago

Yes, here is the page description: `

23.0.07.: Cap Fréhel

]]>

360° ↓

]]>
`
rbodziony commented 5 years ago

You removed this ... <area areatype="clipartarea" width="170.3823206431....?

chharms commented 5 years ago

Yes, I removed the clipart and error was gone. The actual error was:

java.lang.NullPointerException
    at java.base/java.util.regex.Matcher.getTextLength(Unknown Source)
    at java.base/java.util.regex.Matcher.reset(Unknown Source)
    at java.base/java.util.regex.Matcher.<init>(Unknown Source)
    at java.base/java.util.regex.Pattern.matcher(Unknown Source)
    at net.sf.mcf2pdf.pagebuild.PageRenderContext.getClipart(PageRenderContext.java:126)
    at net.sf.mcf2pdf.pagebuild.PageClipart.renderAsBitmap(PageClipart.java:51)
    at net.sf.mcf2pdf.pagebuild.BitmapPageBuilder.addToDocumentBuilder(BitmapPageBuilder.java:75)
    at net.sf.mcf2pdf.Mcf2FoConverter.convert(Mcf2FoConverter.java:253)
    at net.sf.mcf2pdf.Main.main(Main.java:202)
rbodziony commented 5 years ago

Ok so issue was because mcf2pdf expected that clipart has name and this didn't haven have you got more this kind of cliparts in your .mcf files?

chharms commented 5 years ago

Rarely. In the 2018 book I had two cliparts.

wombatstampede commented 5 years ago

Edit: In the meantime I checked also with 0.3.8 of bodziony (which loads the resources for the backgrounds but still reports them as missing). But I see there's already some bug filed for 6.4.3 so I'll just wait and see. Thank you.

Original post: I encountered this error when trying to render a new Photobook with the Pixum CEWE Software. (Pixum Fotowelt 6.4.3 of 16.04.2019) with the 0.3.7, 0.3.8 (bodziony) version (with 0.3.4 as well).


...
[DEBUG] net.sf.mcf2pdf.Mcf2FoConverter Checking XML file for product catalogue: C:\Program Files\Pixum\Pixum Fotowelt\Resources\products\TS102.xml
[DEBUG] net.sf.mcf2pdf.Mcf2FoConverter Adding product catalogue found in C:\Program Files\Pixum\Pixum Fotowelt\Resources\products\TS102.xml
[DEBUG] net.sf.mcf2pdf.Mcf2FoConverter Searching for MCF resources in [C:\Program Files\Pixum\Pixum Fotowelt\Resources, C:\ProgramData\tmp, C:\ProgramData\hps]
[DEBUG] net.sf.mcf2pdf.mcfglobals.McfResourceScanner Processing default backgrounds C:\Program Files\Pixum\Pixum Fotowelt\Resources\photofun\categories\backgrounds_default.xml
[DEBUG] net.sf.mcf2pdf.Mcf2FoConverter Reading MCF file
[DEBUG] net.sf.mcf2pdf.Mcf2FoConverter Preparing temporary working directory
[INFO ] net.sf.mcf2pdf.Mcf2FoConverter Rendering cover...
[DEBUG] net.sf.mcf2pdf.pagebuild.PageText processing html<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"><html><head><meta name="qrichtext" content="1" /><style type="text/css">p, li { white-space: pre-wrap; }</style></head><body style=" font-family:'Calibri'; font-size:16pt; font-weight:400; font-style:normal;"><table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"><tr><td style="border: none;"><p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Bookman Old Style'; font-size:48pt; font-weight:600; color:#ffffff;">England &amp; Wales</span></p><p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Bookman Old Style'; font-size:48pt; font-weight:600; color:#ffffff;"> 2019</span></p></td></tr></table></body></html>
[DEBUG] net.sf.mcf2pdf.pagebuild.PageText body =<body style=" font-family:'Calibri'; font-size:16pt; font-weight:400; font-style:normal;">
 <table style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;">
  <tbody>
   <tr>
    <td style="border: none;"><p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Bookman Old Style'; font-size:48pt; font-weight:600; color:#ffffff;">England &amp; Wales</span></p><p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Bookman Old Style'; font-size:48pt; font-weight:600; color:#ffffff;"> 2019</span></p></td>
   </tr>
  </tbody>
 </table>
</body>
[DEBUG] net.sf.mcf2pdf.pagebuild.PageText tablestyle=-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;
[DEBUG] net.sf.mcf2pdf.pagebuild.PageText p =<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Bookman Old Style'; font-size:48pt; font-weight:600; color:#ffffff;">England &amp; Wales</span></p>
[DEBUG] net.sf.mcf2pdf.pagebuild.PageText p.tagname =p
[DEBUG] net.sf.mcf2pdf.pagebuild.PageText para =net.sf.mcf2pdf.pagebuild.FormattedTextParagraph@136aa0c
[DEBUG] net.sf.mcf2pdf.pagebuild.PageText p =<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Bookman Old Style'; font-size:48pt; font-weight:600; color:#ffffff;"> 2019</span></p>
[DEBUG] net.sf.mcf2pdf.pagebuild.PageText p.tagname =p
[DEBUG] net.sf.mcf2pdf.pagebuild.PageText para =net.sf.mcf2pdf.pagebuild.FormattedTextParagraph@df8434
[DEBUG] net.sf.mcf2pdf.pagebuild.BitmapPageBuilder Creating full page image from page elements
[WARN ] net.sf.mcf2pdf.pagebuild.PageBackground Background not found for page 0: kraeftige_farben_cover_back_portrait
[WARN ] net.sf.mcf2pdf.pagebuild.PageBackground Background not found for page 0: schwarz_collage_cover_back_portrait
[DEBUG] net.sf.mcf2pdf.pagebuild.PageText Rendering text
[ERROR] net.sf.mcf2pdf.Main An exception has occured
java.lang.IllegalArgumentException: Width (0) and height (0) cannot be <= 0
    at java.awt.image.DirectColorModel.createCompatibleWritableRaster(Unknown Source)
    at java.awt.image.BufferedImage.<init>(Unknown Source)
    at net.sf.mcf2pdf.pagebuild.PageText.renderAsBitmap(PageText.java:215)
    at net.sf.mcf2pdf.pagebuild.BitmapPageBuilder.addToDocumentBuilder(BitmapPageBuilder.java:75)
    at net.sf.mcf2pdf.Mcf2FoConverter.convert(Mcf2FoConverter.java:224)
    at net.sf.mcf2pdf.Main.main(Main.java:202)

The missing page styles/backgrounds are in photofun/categories/12860_specials.xml which itself is listed in photofun/white_list.conf. So far, I found no width or height tags with negative values in the mcf.

boggiz commented 5 years ago

Hello, I have the same errors on an "empty. mcf" initialized by Cewe 6.4.5 or 6.3 with mcf2pdf 0.3.4 and his snapshot 0.3.7. The program search for fullcoverpage_quad and fullcoverpage_with_text_quad in ..\photofun\categoriesbackgrounds_default.xml : background designElementId="82070" layout="1" templatename="fullcoverpage_quad,normal" and background designElementId="82076" layout="1" templatename= "fullcoverpage_with_text_quad,normal" But it does not exists in that file !

Have you find a solution to this problem ?

chharms commented 5 years ago

Easiest workaround was to remove the cliparts.

boggiz commented 5 years ago

Thank you for your answer. I would have liked it to be a clipart problem but there is none in my empty.mcf file!

Any other solution ?

wombatstampede commented 5 years ago

Just if you want to go the "manual" way. I went the "screenshot" way:

1: Install an image capture tool (used an older, but free version of faststone image capture)

2: Tell your graphics card driver (in my case a custom resolution in NVIDIA Settings) to use a higher resolution. My Monitor just does HD (1920,1080). I set the resolution to 2880x1620. My monitor could still display this albeit blurry. The reason for this is to get a higher resolution when capturing the preview. If you own a 4k Monitor or similar you may just skip this step.

3 Open the Photobook software and preview your book. Adjust the zoom so that the pages are displayed as big as possible but are still completely visible. Do a Screenshot of the cover then proceed to the "inner pages". If possible: make sure by going forth and back that they always appear in the same place (this eases automatic cropping later). Do screenshots of each page (faststone has a hot-key for that). (Format should be PNG)

Be aware: The preview window can chew up ridiculously high amounts of memory. I had a memory consumption of some 12GB. Results may vary depending on the compression settings when creating the PDF.

4 Check the Screenshots with some image viewer to make sure that they cover all pages, are valid and (except the cover) are aligned equally.

5 Close the Photobook software and reset your screen resolution to a normal one.

6 Crop the Screenshots. For the cover you might to do that manually. For the other pages you can do this as a batch. The free tool IrfanView i.e. allows to open one picture, mark a section then select pictures in the thumbnails views and start a batch-crop for all pictures with the same rectangle. Do this first for all "left" pages. Then for all "right" pages. Output format should be PNG again.

7 Join the resulting PNG files into a PDF. One tool to do this is "PDFCreator". Or it should be also possible via ImageMagick ( https://superuser.com/questions/687849/how-to-generate-a-pdf-from-a-series-of-images ). Personally, I used a licensed version of Acrobat Professional.

Depending on the converting software and your photobook you might want to set the pdf to open with a view of 2 pages at once. (except the cover).

boggiz commented 5 years ago

Thank you for your answer. Unfortunately it is not possible for me to use this procedure : it is too long to convert an album of 104 pages with photos and text.

chharms commented 4 years ago

Actually I found out that with V7.0.1 CeWe changed the structure slightly and current tools need adaption. Currently I give cewe2pdf a try.

thorsten-klein commented 4 years ago

Is someone working on a support for CEWE v7.0.1 ?

chharms commented 4 years ago

I switched to https://github.com/bash0/cewe2pdf

beaune33 commented 4 years ago

Last time I used https://github.com/rbodziony/mcf2pdf with quite nice results, but I am not sure which CEWE version I used. Maybe give it a try.