u3d pdf file

Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

u3d pdf file


I am trying to include a pdf file containing a 3d drawing inside a pdf file using fop 2.3 and fop-images-pdf 2.3. However the graphic included is outside of the bound of the containing block (see result.pdf page 4).
Could you please tell what is wrong here ?

For information everything is fine if I incorporate a 'normal' pdf without 3d model.

The process I used is the following:

- including the pdf with
  <fo:block border="1pt solid black" text-align="center">
   <fo:external-graphic src="u3d.pdf" border="1pt solid red" block-progression-dimension="100mm" content-width="scale-to-fit" scaling="uniform" />
- for information the u3d.pdf file containing a u3d graphic is build from a u3d file using the following java code with itext 5.5
    public static void writePdf(String u3dFileUri, OutputStream out) {
        Dimension dimension = new Dimension(100,100);
        Rectangle pageSize = new Rectangle(dimension.width, dimension.height);
        Document doc = new Document();
        try {
            PdfWriter wr = PdfWriter.getInstance(doc, out);
            String script = getScript();
            PdfStream oni = new PdfStream(PdfEncodings.convertToBytes(script, null));
            PdfIndirectReference initScriptRef = wr.addToBody(oni).getIndirectReference();
            ArrayList<PdfIndirectReference> viewList = new ArrayList<PdfIndirectReference>(1);
            PdfDictionary viewDict = new PdfDictionary(new PdfName(PDF_NAME_3DVIEW));
            viewDict.put(new PdfName(PDF_NAME_MS), new PdfString("M"));
            float[] T1 = new float[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
            viewDict.put(new PdfName("C2W"), new PdfArray(T1));
            String cameraName = "Test Camera";
            viewDict.put(new PdfName(PDF_NAME_XN), new PdfString(cameraName));
            PdfIndirectReference ref = wr.addToBody(viewDict).getIndirectReference();
            File u3d = FileProc.newFile(u3dFileUri);
            PdfStream stream = new PdfStream(new FileInputStream(u3d), wr);
            stream.put(new PdfName("OnInstantiate"), initScriptRef);
            stream.put(PdfName.TYPE, new PdfName(PDF_NAME_3D));
            stream.put(PdfName.SUBTYPE, new PdfName(PDF_NAME_U3D));
            PdfIndirectReference u3dStreamRef = wr.addToBody(stream).getIndirectReference();
            PdfDictionary activationDict = new PdfDictionary();
            activationDict.put(PdfName.A, new PdfName("PO"));
            activationDict.put(new PdfName("DIS"), PdfName.I);
            float scale = 0.5f;
            float width = scale * (pageSize.getRight() - pageSize.getLeft());
            float height = scale * (pageSize.getTop() - pageSize.getBottom());
            PdfAppearance ap = PdfAppearance.createAppearance(wr, width, height);
            PdfAnnotation annot = new PdfAnnotation(wr, pageSize);
            annot.put(PdfName.CONTENTS, new PdfString("3D Model"));
            annot.put(PdfName.SUBTYPE, new PdfName(PDF_NAME_3D));
            annot.put(PdfName.TYPE, PdfName.ANNOT);
            annot.put(new PdfName(PDF_NAME_3DD), u3dStreamRef);
            PdfBoolean value3DI = showInventory ? PDFTRUE : PDFFALSE;
            annot.put(new PdfName("3DI"), value3DI);
            annot.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, ap);
            annot.put(new PdfName("3DA"), activationDict);
        } catch (IOException e) {
        } catch (DocumentException de) {

pdf files :
Mozilla Thunderbird permet de partager facilement des fichiers volumineux.

Jean-François MAUREL

To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

attachment2 Download Attachment
attachment3 (2 bytes) Download Attachment