Skip to main content
February 2, 2016
Question

Launch and save preflight report by Javascript

  • February 2, 2016
  • 2 replies
  • 2570 views

Hi everyone

I'v learn here in this forum that the document properties ( fonts ) is not reachable by javascript

But is it possible to launch a preflight then collect the report as XML

all by javascript....

from there i'm able to get the info that i want about font embeding.... in xojo

thanks

This topic has been closed for replies.

2 replies

Karl Heinz  Kremer
Community Expert
Community Expert
February 3, 2016

You are parsing XML, so you will have to use the correct syntax to access information in that XML data structure. Look at the documentation for XMLData.parse(). The following will list all fonts in the "fonts" XML node:

var oXMLData = XMLData.parse(cXMLData, false);

var fonts = oXMLData.report.document.resources.fonts;

for (var i=0; i<fonts.nodes.length; i++) {

    console.println(fonts.nodes.item(i).name.value);

}

That is, with your manually extracted XML file. I don't know how to get the list of fonts via JavaScript either.

February 3, 2016

Reading the XML will be done in XOJO ( MAC developing software )

But before exporting, i'v to know if the XML contain the info that i need

And " NO "

Its not the report that i need

But the ( Summary ) of preflight... and it's not in acrobat javascript function

Karl Heinz  Kremer
Community Expert
Community Expert
February 3, 2016

You may want to talk to the people at Callas (who as you can see based on the schema information in the XML file have written the Acrobat preflight tool), and see if they have a standalone application that does what you need to do.

try67
Community Expert
Community Expert
February 2, 2016

It's possible to run a preflight profile, yes, but I don't think it's possible to collect its results. You can test it out, though.

To do it you use the preflight method of the Document object.

February 3, 2016

Thanks

i'm able to run my preflight and get an XML object

But i can't dig inside the XML further than report.name

when a try to go deeper like

var myValue = oXMLData.report.document.name; (i'v try everything like all node tree to fonts )

i'v got a error undefined

Can you help me to reach the font info

thanks

------------

var oProfile = Preflight.getProfileByName("Pre-fontes")

if( oProfile != undefined )

{

  var oThermometer = app.thermometer;

  var myPreflightResult = this.preflight( oProfile, false, oThermometer);

  var cXMLData = myPreflightResult.report(oThermometer);

  var oXMLData = XMLData.parse(cXMLData, false);

  var myValue = oXMLData.report.name;

  console.println("Purpose: " + oProfile.description);

  console.println("myValue: " + myValue);

}

---------------------------------------------------------------

This is a manually export report XML

......

<?xml version="1.0" encoding="UTF-8" ?>

<report>

     <document>

     <doc_info></doc_info>

     <xmp_doc_info></xmp_doc_info>

     <pages></pages>

     <resources>

          <colorspaces></colorspaces>

     <fonts>

               <font id="FNT1" type="Type1" embedded="1" subset="1" has_unicode_cmap="1">

                 <name>HelveticaNeue-HeavyCond</name>

                 <encoding>WinAnsiEncoding</encoding>

               </font>

       </fonts>

       <embedded_files></embedded_files>

       </resources>

  </document>

</report

frameexpert
Community Expert
Community Expert
February 3, 2016

When you have an XML object, the top-level element is already implied. So you should be able to do this:

var myFonts = oXMLData.document.fonts.name;


-Rick

www.frameexpert.com