Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Launch and save preflight report by Javascript

Guest
Feb 02, 2016 Feb 02, 2016

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

TOPICS
Acrobat SDK and JavaScript
2.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 02, 2016 Feb 02, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 03, 2016 Feb 03, 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 03, 2016 Feb 03, 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 03, 2016 Feb 03, 2016

Check that. It should be

var myFonts = oXmlData.document.resources.fonts.name;

or

var myFonts = oXmlData..fonts.name;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 03, 2016 Feb 03, 2016

Sorry, one more time. This time I tested it :-).

var myFonts = xmlObject..fonts.font.name;

Rick

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 03, 2016 Feb 03, 2016

Thanks Rick

But i'v got this Error

XML descendants internal method called on incompatible XFAObject

..

is there a way to display full node tree... i doubt that the report is really the full report !!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 03, 2016 Feb 03, 2016

Can you email me a sample PDF with the "Pre-fontes" profile in it? Please send it to rick at frameexpert dot com. Thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 03, 2016 Feb 03, 2016

The profile would actually not be in the PDF file, but in a separate file that can be exported from Acrobat's Preflight dialog:

2016-02-03_11-18-28.png

Select the profile you want to export, then click on the "Options" button to bring up the menu and select "Export Preflight Profile" from the menu. This is also how you import a profile (just use the "Import Preflight Profile" option from the menu).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 03, 2016 Feb 03, 2016

When I run this, I get an XML report, but it only contains the embedding information instead of the summary information that you get when you export an XML report from the Profiles.

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);

}

console.println (cXMLData.toString ());

I am having the same problem as you: I don't know how to get the full summary programmatically. I am sorry I couldn't help.

-Rick

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 03, 2016 Feb 03, 2016

That's what i'v worry

It only report the problematic font ( not embeded )

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

<report xsi:schemaLocation="http://www.callassoftware.com/namespace/js js_results_schema.xsd" xmlns="http://www.callassoftware.com/namespace/js" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <fixups>

  </fixups>

  <results>

  <result severity="Info">

  <rule>Font not embedded</rule>

  <page number="1" hits="1"></page>

  </result>

  </results>

</report>

Thank you

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 03, 2016 Feb 03, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 03, 2016 Feb 03, 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 03, 2016 Feb 03, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 03, 2016 Feb 03, 2016
LATEST

I have already a 3rd party software who can do that

The idea is to use acrobat integrate tool

which everyone ( in the shop ) have in hand

Thanks for the info

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines