danishiumca / xdocreport

Automatically exported from code.google.com/p/xdocreport
0 stars 0 forks source link

ODT -> PDF conversion - image in frames are not produced in PDF #442

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I get pdf with missing images while converting odt to pdf.

Java sample to reproduce problem:
package com.mobitel.pdfgenerator.test;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import fr.opensagres.xdocreport.converter.ConverterRegistry;
import fr.opensagres.xdocreport.converter.ConverterTypeTo;
import fr.opensagres.xdocreport.converter.IConverter;
import fr.opensagres.xdocreport.converter.Options;
import fr.opensagres.xdocreport.core.XDocReportException;
import fr.opensagres.xdocreport.core.document.DocumentKind;

public class XDocReport {

    public static void main(String[] args) {
        // 1) Load ODT file and set Velocity template engine and cache it to the
        // registry
        try {

            // 1) Create options ODT 2 PDF to select well converter form the registry
            Options options = Options.getFrom(DocumentKind.ODT).to(ConverterTypeTo.PDF);

            // 2) Get the converter from the registry
            IConverter converter = ConverterRegistry.getRegistry().getConverter(options);

            // 3) Convert ODT 2 PDF
            InputStream in= new FileInputStream(new File("/home/klemen/temp/sample.odt"));
            OutputStream out = new FileOutputStream(new File("/home/klemen/temp/sample.pdf"));
            converter.convert(in, out, options);                                

        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (XDocReportException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }
}

dependencies and versions:

<dependency>
  <groupId>fr.opensagres</groupId>
  <artifactId>xdocreport</artifactId>
  <version>1.0.4</version>
</dependency>
<dependency>
    <groupId>org.apache.velocity</groupId>
    <artifactId>velocity</artifactId>
    <version>1.7</version>
</dependency>
<dependency>
    <groupId>org.freemarker</groupId>
    <artifactId>freemarker</artifactId>
    <version>2.3.14</version>
</dependency>
<dependency>
    <groupId>org.apache.ant</groupId>
    <artifactId>ant-apache-oro</artifactId>
    <version>1.9.4</version>
</dependency>
<dependency>
    <groupId>org.odftoolkit</groupId>
    <artifactId>odfdom-java</artifactId>
    <version>0.8.7</version>
</dependency>

            // 1) Create options ODT 2 PDF to select well converter form the registry
            Options options = Options.getFrom(DocumentKind.ODT).to(ConverterTypeTo.PDF);

            // 2) Get the converter from the registry
            IConverter converter = ConverterRegistry.getRegistry().getConverter(options);

            // 3) Convert ODT 2 PDF
            InputStream in= new FileInputStream(new File("/home/klemen/temp/sample.odt"));
            OutputStream out = new FileOutputStream(new File("/home/klemen/temp/sample.pdf"));
            converter.convert(in, out, options);      

templates and resulting pdf is attached.

Original issue reported on code.google.com by klemenzi...@gmail.com on 18 Sep 2014 at 11:12

Attachments:

GoogleCodeExporter commented 9 years ago
Hi,

Thank's for attaching your odt.

@Leszek could you see this problem when you will have time?

Thank's!

Regard's Angelo

Original comment by angelo.z...@gmail.com on 18 Sep 2014 at 11:20

GoogleCodeExporter commented 9 years ago
In what maven artifact should I look for required change/fix? I would like to 
reproduce this, so I would like to download source code.
Which one do I need to check/debug:

odftoolkit?
freemaker?
velocity?
xdocreport?

Original comment by klemenzi...@gmail.com on 22 Sep 2014 at 8:47

GoogleCodeExporter commented 9 years ago
In what maven artifact should I look for required change/fix?

> xdocreport

I think you must improve this vistor class :
https://code.google.com/p/xdocreport/source/browse/thirdparties-extension/org.od
ftoolkit.odfdom.converter.pdf/src/main/java/org/odftoolkit/odfdom/converter/pdf/
internal/ElementVisitorForIText.java

Original comment by angelo.z...@gmail.com on 22 Sep 2014 at 8:51

GoogleCodeExporter commented 9 years ago
mvn dependency:sources
could not dowlnoad sources - are they not packaged with maven in let's say: 
converter-1.0.4-sources.jar ?

Original comment by klemenzi...@gmail.com on 22 Sep 2014 at 8:59

GoogleCodeExporter commented 9 years ago
I'm checking code for this class.
In my case whole <draw:frame> has been left out (not visible in final pdf).

I cannot find section where <draw:frame> is processed...

For my case:

      <draw:frame draw:style-name="fr1" draw:name="Okvir6" text:anchor-type="page" text:anchor-page-number="1" svg:x="5.8272in" svg:y="0.1965in" svg:width="1.852in" draw:z-index="0">
        <draw:text-box fo:min-height="0.7736in">
          <table:table table:name="Tabela20" table:style-name="Tabela20">
            <table:table-column table:style-name="Tabela20.A" table:number-columns-repeated="3"/>
            <table:table-row>
              <table:table-cell table:style-name="Tabela20.A1" table:number-columns-spanned="3" office:value-type="string">
                <text:p text:style-name="P2">
                  <draw:frame draw:style-name="fr4" draw:name="barcode128" text:anchor-type="as-char" svg:width="1.7717in" svg:height="0.5902in" draw:z-index="1">
                    <draw:image xlink:href="Pictures/10000000000005C800000162EAE3116E.png" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
                  </draw:frame>
                </text:p>
              </table:table-cell>
              <table:covered-table-cell/>
              <table:covered-table-cell/>
            </table:table-row>
            <table:table-row table:style-name="Tabela20.2">
              <table:table-cell table:style-name="Tabela20.A2" office:value-type="string">
                <text:p text:style-name="Standard">
                  <text:user-defined style:data-style-name="N0" text:name="subscription_inet_id">126886</text:user-defined>
                </text:p>
              </table:table-cell>
              <table:table-cell table:style-name="Tabela20.B2" office:value-type="string">
                <text:p text:style-name="P2"/>
              </table:table-cell>
              <table:table-cell table:style-name="Tabela20.A2" office:value-type="string">
                <text:p text:style-name="P3">
                  <text:user-defined style:data-style-name="N0" text:name="id_stra">731443</text:user-defined>
                </text:p>
              </table:table-cell>
            </table:table-row>
            <table:table-row>
              <table:table-cell table:style-name="Tabela20.B2" office:value-type="string">
                <text:p text:style-name="Standard">ID</text:p>
              </table:table-cell>
              <table:table-cell table:style-name="Tabela20.B2" office:value-type="string">
                <text:p text:style-name="P2"/>
              </table:table-cell>
              <table:table-cell table:style-name="Tabela20.B2" office:value-type="string">
                <text:p text:style-name="Standard">ID <text:span text:style-name="T1">customer</text:span></text:p>
              </table:table-cell>
            </table:table-row>
          </table:table>
          <text:p text:style-name="P31"/>
        </draw:text-box>
      </draw:frame>

Original comment by klemenzi...@gmail.com on 22 Sep 2014 at 10:11

GoogleCodeExporter commented 9 years ago
OK found it :)

Original comment by klemenzi...@gmail.com on 22 Sep 2014 at 10:13

GoogleCodeExporter commented 9 years ago
I see problem is that it doesn't visits <draw:image>

    <draw:frame draw:style-name="fr1" draw:name="Okvir6" text:anchor-type="page" text:anchor-page-number="1" svg:x="5.8299in" svg:y="0.2in" svg:width="1.852in" draw:z-index="0">
        <draw:text-box fo:min-height="0.7736in">
          <table:table table:name="Tabela20" table:style-name="Tabela20">
            <table:table-column table:style-name="Tabela20.A" table:number-columns-repeated="3"/>
            <table:table-row>
              <table:table-cell table:style-name="Tabela20.A1" table:number-columns-spanned="3" office:value-type="string">
                <text:p text:style-name="P2">
                  <draw:frame draw:style-name="fr4" draw:name="barcode128" text:anchor-type="as-char" svg:width="1.7717in" svg:height="0.5902in" draw:z-index="1">
                    <draw:image xlink:href="Pictures/10000000000005C800000162EAE3116E.png" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>

I attached even simpler sample for reproducing that...

Original comment by klemenzi...@gmail.com on 22 Sep 2014 at 12:43

Attachments:

GoogleCodeExporter commented 9 years ago
I see that visit(DrawFrameElement ele) method in class ElementVisitorForIText 
was no implemented - but I don't know how to implement it correctly - is there 
someone beside @Leszek to check this?:

    @Override
    public void visit ( DrawFrameElement ele )
    {
        System.out.println("aha");
        //processParagraphOrHeading( ele, null );
        super.visit( ele );
    }

Original comment by klemenzi...@gmail.com on 22 Sep 2014 at 12:49