Planet PDF Forum Archive

Planet PDF  ForumThe page you are viewing is part of our 160,000 page discussion forum archive. See below for PDF-related discussions spanning 1999-2008. To ask questions and get help, head to the live Planet PDF Forum.


How to search this archive. The quickest way is to use the filters on our Advanced Search page so that only archive pages are included in the results.


Previous | Next | (P-PDF) Engineering


Topic: iText 3D PDF and JavaScript
Conf: (P-PDF) Engineering, Msg: 160606
From: aheckmeier
Date: 6/11/2007 12:36 AM

Hello,

I've added a 3D modell to an existing PDF with iText. When i add a Script like "host.getField("testField").value = clickedMesh.name;", i get the error message "host is undefined".

If i add the 3D modell and script manually, it works fine ...

Any clue?
Thanks in advance!


Toni




Here is the code of iTexte:


public class PDF3DObject extends PdfAnnotation
{
// See also PDF reference 1.6 (Page 757)
public static final String PDF_NAMESAPCE = "iTextSharp.text.pdf.";
public static final String PDF_NAME_3D = "3D";
public static final String PDF_NAME_3DD = "3DD";
public static final String PDF_NAME_3DV = "3DV";
public static final String PDF_NAME_3DVIEW = "3DView";
public static final String PDF_NAME_C2W = "C2W"; // Transformation matrix (optional)
public static final String PDF_NAME_IN = "IN"; // internal name of the view (optional)
public static final String PDF_NAME_MS = "MS"; //
public static final String PDF_NAME_XN = "XN"; // The external name of the view (required)

public static final String PDF_NAME_U3D = "U3D";
public static final String PDF_NAME_U3DPATH = "U3DPath";


/**
*
* @param writer PdfWriter
* @param u3dFile File
* @param previewImage File
* @param rectangle Rectangle
*/
public PDF3DObject(PdfStamper stamper, File u3dFile, Rectangle rectangle, int page)
{
super(stamper.getWriter(), rectangle);

try
{
PdfWriter writer = stamper.getWriter();

PdfIndirectReference streamRef;
PdfIndirectObject objRef;

PdfContentByte cb = stamper.getOverContent(page);

// Create stream to carry attachment
FileInputStream fistrm = new FileInputStream(u3dFile);
PdfStream stream = new PdfStream(fistrm, writer);

// Mandatory keys
stream.put(PdfName.TYPE, new PdfName(PDF_NAME_3D));
stream.put(PdfName.SUBTYPE, new PdfName(PDF_NAME_U3D));
stream.flateCompress();

// Write stream contents, get reference to stream object, write actual stream length
streamRef = writer.addToBody(stream, false).getIndirectReference();
stream.writeLength();

// Create 3D view dictionary
// PDF documentation states that this can be left out, but without normally we will just get a blank
// 3D image because of wrong coordinate space transformations, etc.
// Instead of providing camera-to-world transformation here, we could also reference view in U3D file itself
// (would be U3DPath key instead of C2W key, U3D value instead of M value for MS key), but i haven't tried
// up to now
// We could also provide an activation dictionary (defining activation behavior), and field-of-view for
// P entry if needed
PdfDictionary dict = new PdfDictionary(new PdfName(PDF_NAME_3DVIEW));

dict.put(new PdfName(PDF_NAME_XN), new PdfString("DefaultView"));
dict.put(new PdfName(PDF_NAME_IN), new PdfString("Unnamed"));

dict.put(new PdfName(PDF3DObject.PDF_NAME_MS), new PdfName(PDF3DObject.PDF_NAME_U3D));

// NOTE: The initial release of Acrobat 7.0 does not correctly display the default view in the U3D data.
// This behavior is expected to be corrected in future releases and hence.
dict.put(new PdfName(PDF3DObject.PDF_NAME_U3DPATH), new PdfString("DefaultView"));

// Write view dictionary, get reference
objRef = writer.addToBody(dict, false);

//
// Create appearance
PdfAppearance ap = cb.createAppearance(rectangle.width(), rectangle.height());
ap.setBoundingBox(rectangle);


put(PdfName.CONTENTS, new PdfString("3D Model"));

// Mandatory keys
put(PdfName.SUBTYPE, new PdfName(PDF_NAME_3D));
put(PdfName.TYPE, PdfName.ANNOT);

// Reference to stream object
put(new PdfName(PDF_NAME_3DD), streamRef);

// Reference to view dictionary object
put(new PdfName(PDF_NAME_3DV), objRef.getIndirectReference());

// Assign appearance and page
setAppearance(PdfAnnotation.APPEARANCE_NORMAL, ap);
}
catch (IOException ex)
{
Debug.error("Internal Error: ", ex);
}
}
}


PDF In-Depth Free Product Trials Ubiquitous PDF

Pitstop Pro

Now graphic arts professionals have even broader and more expert control over their PDF documents. With...

Download free demo

ARTS PDF Aerialist

The ultimate plug-in for Adobe Acrobat and #1 selling product at PDF Store. Advanced splitting, merging,...

Download free demo

Ubiquitous PDF: Got holiday catering?

Bret Thompson, chef and owner of LA's Milk restaurant on Beverly, has joined forces with the California Milk Processor Board to compile a set of dairy-based recipes for the holiday season.

November 20, 2008
Search Planet PDF
more searching options...






PDF Resources
Platinum Sponsor
Create & Edit PDF - Nitro PDF Software

ARTS PDF

Silver Sponsors

PDF-Tools enfocus

FileOpen PDFNet SDK: PDF Component. Cross-platform PDF library

PDF Converter: Create, Convert PDF to Word/Excel Solid Documents - PDF to Word Converter

Debenu: Desktop Document Management, Archiving and Tagging Software Visual Integrity: Convert, Create, Extract, Merge and Modify PDF

SmartSoft

Get Nitro PDF Professional
Featured Product

NITRO PDF Professional

Built from the ground up, the perfect desktop PDF product for business and enterprise. Nitro PDF Professional has an uncompromising feature set so you can create, combine, edit, collaborate on and...

Featured Event

Adobe Acrobat & PDF Central Conference 2008

September 23 - 25, 2008 - Minneapolis, Minnesota

Dedicated exclusively to Adobe Acrobat and PDF, the 2008 Adobe Acrobat and PDF Central Conference presents a unique opportunity to broaden your understanding of how PDF technologies can positively affect your business productivity.

Discover the new features of Acrobat 9 and expand your knowledge of PDF technology. Participate in various educational seminars, such as Acrobat Form Fundamentals, Acrobat Security, Creating PDF Portfolios, Scripting with the new Flash Annotation in PDF, JavaScript for Acrobat, and much more.

PDF Store Categories