// internal constructor: the public interface is a factory method // on the Processor object internal XsltCompiler(JConfiguration config) { this.factory = new TransformerFactoryImpl(config); this.config = config; this.info = new JCompilerInfo(); info.setURIResolver(config.getURIResolver()); info.setErrorListener(config.getErrorListener()); }
// internal constructor: the public interface is a factory method // on the Processor object internal XsltCompiler(Processor processor) { this.processor = processor; this.config = processor.config; this.factory = new TransformerFactoryImpl(config); this.info = new JCompilerInfo(); info.setURIResolver(config.getURIResolver()); info.setErrorListener(config.getErrorListener()); }
/// <summary> /// Get the Area Tree from Antenna House Formatter /// </summary> /// <param name="inputStream">XSL:FO tree as ByteArryInputStream</param> /// <param name="configFileName">FOP configuration file name: Setting file for Antenna House Formatter rendering</param> /// <returns></returns> protected XPathDocument GetAreaTrea(ByteArrayInputStream inputStream, string configFileName) { ByteArrayOutputStream outStream = new ByteArrayOutputStream(); FOUserAgent userAgent = new FOUserAgent(FopFactory.newInstance()); FopFactoryConfigurator configurator = new FopFactoryConfigurator(userAgent.getFactory()); if (string.IsNullOrEmpty(configFileName) == false) { userAgent.getFactory().setUserConfig(configFileName); } Fop fop = userAgent.getFactory().newFop(MimeConstants.__Fields.MIME_FOP_AREA_TREE, userAgent, outStream); TransformerFactory tf = new TransformerFactoryImpl(); Transformer transformer = tf.newTransformer(); Source src = new StreamSource(inputStream); Result res = new SAXResult(fop.getDefaultHandler()); transformer.transform(src, res); return(outStream.ToXPathDocument()); }
private void DoMetadata() { java.util.TimeZone timeZone = java.util.TimeZone.getTimeZone("GMT"); Calendar instance = Calendar.getInstance(); instance.setTimeZone(timeZone); PDDocumentInformation documentInformation = this.doc.getDocumentInformation(); documentInformation.setModificationDate(instance); if (documentInformation.getAuthor() == null) { documentInformation.setAuthor("Aquaforest"); } if ((string.IsNullOrEmpty(documentInformation.getProducer()) ? true : documentInformation.getProducer() == " ")) { documentInformation.setProducer("Aquaforest PDFA - http://www.aquaforest.com"); } if (documentInformation.getKeywords() == null) { documentInformation.setKeywords(""); } documentInformation.getCreationDate(); instance.setTime(this.GetDate(documentInformation.getCreationDate())); documentInformation.setCreationDate(instance); this.doc.setDocumentInformation(documentInformation); this.doc.save(this.tempFileName); documentInformation = this.doc.getDocumentInformation(); PDDocumentCatalog documentCatalog = this.doc.getDocumentCatalog(); XMPMetadata xMPMetadatum = XMPMetadata.createXMPMetadata(); if (this.ConformanceLevel.Trim().ToLower() == "a") { PDMarkInfo pDMarkInfo = new PDMarkInfo(); pDMarkInfo.setMarked(true); documentCatalog.setMarkInfo(pDMarkInfo); } PDFAIdentificationSchema pDFAIdentificationSchema = xMPMetadatum.createAndAddPFAIdentificationSchema(); pDFAIdentificationSchema.setConformance(this.ConformanceLevel); pDFAIdentificationSchema.setPart(new Integer(this.pdfaversion)); DublinCoreSchema dublinCoreSchema = xMPMetadatum.createAndAddDublinCoreSchema(); string title = documentInformation.getTitle(); if (title != null) { dublinCoreSchema.setTitle(title); } title = documentInformation.getSubject(); if (title != null) { dublinCoreSchema.setDescription(title); } title = documentInformation.getAuthor(); if (title != null) { dublinCoreSchema.addCreator(title); } AdobePDFSchema adobePDFSchema = xMPMetadatum.createAndAddAdobePDFSchema(); title = documentInformation.getProducer(); if (title != null) { adobePDFSchema.setProducer(title); } title = documentInformation.getKeywords(); if (title != null) { adobePDFSchema.setKeywords(title); } XMPBasicSchema xMPBasicSchema = xMPMetadatum.createAndAddXMPBasicSchema(); title = documentInformation.getCreator(); if (title != null) { xMPBasicSchema.setCreatorTool(title); } if (documentInformation.getCreationDate() != null) { xMPBasicSchema.setCreateDate(documentInformation.getCreationDate()); } if (documentInformation.getModificationDate() != null) { xMPBasicSchema.setModifyDate(documentInformation.getModificationDate()); } xMPBasicSchema.setMetadataDate(new GregorianCalendar()); XmpSerializer xmpSerializer = new XmpSerializer(); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); SAXParserFactoryImpl sAXParserFactoryImpl = new SAXParserFactoryImpl(); TransformerFactoryImpl transformerFactoryImpl = new TransformerFactoryImpl(); xmpSerializer.serialize(xMPMetadatum, byteArrayOutputStream, false); PDMetadata pDMetadatum = new PDMetadata(this.doc); pDMetadatum.importXMPMetadata(byteArrayOutputStream.toByteArray()); documentCatalog.setMetadata(pDMetadatum); this.doc.save(this.tempFileName); documentInformation = this.doc.getDocumentInformation(); }