Skip navigation
This discussion is locked
Currently Being Moderated

PDF  to XML conversion

Jul 2, 2007 4:38 AM

Hi all,

I asked a question in Acrobat SDK forum about using Acrobat standard SDK for automatic PDF to XML conversion on a server and I was told that Acrobat lisence does not permit that and I need to use the Adobe LiveCycle ES.

I just need to automatically convert the incoming PDF files to XML on a server (automating Acrobat Standard's "SaveAS XML" function)

Could you please tell me which LiveCyle component can do this for me and also give me its approximate price.

Thanks very much for your help,
Arash
 
Replies
  • Currently Being Moderated
    Jul 5, 2007 12:51 PM   in reply to (Arash_Joorabchi)
    What excactly are you trying to get in that XML file. The data from the PDF document, the metadata,etc.

    Can you be a little bit more specific because there might be different products to do different things. I did a quick test with the SaveXML form Acrobat and it seem to contain only the metadata, but I'd lie to confirm.

    Thanks,

    Jasmin
     
    |
    Mark as:
  • Currently Being Moderated
    Jul 23, 2007 10:18 AM   in reply to (Arash_Joorabchi)
    So is this really a html representation of the PDF.

    PDFG should be the product that can convert PDF into HTML. The operation is ExportPDF.

    Jasmin
     
    |
    Mark as:
  • Currently Being Moderated
    Aug 28, 2007 7:13 AM   in reply to (Arash_Joorabchi)
    Hi,
    My requirement is send the xml to a server and there allow another application use this xml.

    I am trying to use ASP to take this xml and save it on the server but I am unable to do it because dont know how. Is it possible?
    Thanks,
    merlin
     
    |
    Mark as:
  • Currently Being Moderated
    Aug 28, 2007 3:48 PM   in reply to (Arash_Joorabchi)
    You can definitely post XML to an ASP from a PDF. You need to add a submit button into the form and make sure you specify the location where you want to post the information to ( in you case XML). You also need to specify what you want to post (PDF, XML, XDP).

    In your asp, you can then get the xml out of the request object.

    Is that what you're trying to do?

    Jasmin
     
    |
    Mark as:
  • Currently Being Moderated
    Aug 29, 2007 6:38 AM   in reply to (Arash_Joorabchi)
    Hi Jasmin,

    I am using Acrobat Pro 6 and when I defined the submit button I just saw FDF, HTML, XFDF and PDF. Now, If I want to get the xml I guess I could use the XFDF option. However, what should I do in asp in order to get this xfdf file. I read something about request object, but don't know it. Could you please let me know what is the syntax I need to use.
    Thank you very much.
     
    |
    Mark as:
  • Currently Being Moderated
    Aug 29, 2007 9:07 AM   in reply to (Arash_Joorabchi)
    This is a java example, but the ASP should be very similar.

    public static byte[] getRequestBufferAsBytes(HttpServletRequest request)
    throws IOException, ServletException
    {
    ServletInputStream oInput = request.getInputStream();
    long nContentLength = request.getContentLength();
    String contentType = request.getContentType();
    if(nContentLength <= 0L)
    return null;
    byte cContent[] = new byte[(int)nContentLength];
    int nRead = 0;
    int nToRead = (int)nContentLength;
    int nBlkSize = 512;
    byte cTemp[] = new byte[512];
    do
    {
    int n = 0;
    int i = 0;
    if(nToRead - nRead < 512)
    nBlkSize = nToRead - nRead;
    n = oInput.read(cTemp, 0, nBlkSize);
    for(i = 0; i < n; i++)
    cContent[i + nRead] = cTemp[i];

    nRead += i;
    } while(nRead < nToRead);
    Long nBytesRead = new Long(nRead);
    return cContent;
    }

    Jasmin
     
    |
    Mark as:
  • Currently Being Moderated
    Aug 30, 2007 6:43 AM   in reply to (Arash_Joorabchi)
    Jasmin,

    I will try to do the convertion to asp.

    Another question: what about if I try to call my WebService from a button in the pdf. My webservice is defined on Apache-Axis. Is valid the command soap.connect(myURL) from pdf javascript to connect to Apache-Axis?. Is that doc wrapped for SOAP when I use the soap command?. I am afraid i have more question, I am new in this matter.

    Thank you very much for your answers
    M
     
    |
    Mark as:
  • Currently Being Moderated
    Feb 11, 2008 4:42 AM   in reply to (Arash_Joorabchi)
    hi, want to know how you did the conversion of pdf to xml using the acrobat standard??... did you use the acrobat javascript object?...
    please as i need the function that properly does the conversion of pdf to xml...

    Private oapp As New Acrobat.AcroApp
    Private oavdoc As New Acrobat.AcroAVDoc
    Private odoc As New Acrobat.AcroPDDoc
    Dim ojs As Object
    Dim osaveas As Object
    Dim input As String

    input = "d:\document\time.pdf"

    If oavdoc.Open(input, Path.GetFileName(input)) Then
    odoc = oavdoc.GetPDDoc()
    ojs = odoc.GetJSObject()
    ojs.Saveas("/c/test.xml", "com.adobe.acrobat.xml-1-00")

    End If
    odoc.Close()
    oapp.Exit()

    here's the code in vb.net but i'm getting security error in acrobat professional please help me out
     
    |
    Mark as:
  • Currently Being Moderated
    Mar 12, 2008 2:17 AM   in reply to (Arash_Joorabchi)
    hi
    i too having the same issue as converting PDF file to XML format/file. this should be done using pure java code and till now i got the pdf file name by selecting the file using the choose file browser and storing it in a variable then with the help of PDFBOX i tried but the result is converted but not in XML format(i.e.,when i open the converted XML file it is in normal format but only the extension has been changed .PDF to .XML no other changed)so please let me know how to achive this
    i have paste the code i have used

    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.OutputStreamWriter;
    import java.io.Writer;
    import java.net.MalformedURLException;
    import java.net.URL;

    import org.pdfbox.pdmodel.PDDocument;
    import org.pdfbox.pdmodel.encryption.AccessPermission;
    import org.pdfbox.pdmodel.encryption.StandardDecryptionMaterial;
    import org.pdfbox.util.PDFText2HTML;
    //import org.pdfbox.util.PDFTextStripper;
    import org.pdfbox.pdmodel.font.PDFont.* ;
    import org.pdfbox.util.PDFTextStripper;
    import org.pdfbox.util.*;
    import org.pdfbox.pdmodel.*;
    import com.activegrid.util.AGObject;
    //import executesqljavaxsd.types.*;
    import com.activegrid.util.Logger;
    import com.activegrid.data.DataService;
    import java.util.List;
    import java.util.ArrayList;

    public class pdf2xml {
    public static final String DEFAULT_ENCODING =
    null;
    //"ISO-8859-1";
    //"ISO-8859-6"; //arabic
    //"US-ASCII";
    //"UTF-8";
    //"UTF-16";
    //"UTF-16BE";
    //"UTF-16LE";

    private static final String PASSWORD = "-password";
    private static final String ENCODING = "-encoding";
    private static final String CONSOLE = "-console";
    private static final String START_PAGE = "-startPage";
    private static final String END_PAGE = "-endPage";
    private static final String SORT = "-sort";
    private static final String HTML = "-html"; // jjb - added simple HTML output
    private static String a;
    public static void main( String[] args ) throws Exception
    {

    }
    public static void abc(String inp)throws Exception
    {
    boolean toConsole = false;
    boolean toHTML = false;
    boolean sort = false;
    String password = "";
    String encoding = DEFAULT_ENCODING;
    String pdfFile = inp;
    String textFile = "C:/tut.xml";//file to store in XML format
    int startPage = 1;
    int endPage = Integer.MAX_VALUE;
    a ="txt";
    if( pdfFile == null )
    {
    usage();
    }
    else
    {

    Writer output = null;
    PDDocument document = null;
    try
    {
    try
    {
    //basically try to load it from a url first and if the URL
    //is not recognized then try to load it from the file system.
    URL url = new URL( pdfFile );
    document = PDDocument.load( url );
    String fileName = url.getFile();
    if( textFile == null && fileName.length() >4 )
    {
    File outputFile =
    new File( fileName.substring( 0, fileName.length() -4 ) + ".txt" );
    textFile = outputFile.getName();
    }
    }
    catch( MalformedURLException e )
    {
    document = PDDocument.load( pdfFile );
    if( textFile == null && pdfFile.length() >4 )
    {
    textFile = pdfFile.substring( 0, pdfFile.length() -4 ) + ".txt";
    }
    }

    //document.print();
    if( document.isEncrypted() )
    {
    StandardDecryptionMaterial sdm = new StandardDecryptionMaterial( password );
    document.openProtection( sdm );
    AccessPermission ap = document.getCurrentAccessPermission();

    if( ! ap.canExtractContent() )
    {
    throw new IOException( "You do not have permission to extract text" );
    }
    }
    if( toConsole )
    {
    output = new OutputStreamWriter( System.out );
    }
    else
    {
    if( encoding != null )
    {
    output = new OutputStreamWriter(
    new FileOutputStream( textFile ), encoding );
    }
    else
    {
    //use default encoding
    output = new OutputStreamWriter(
    new FileOutputStream( textFile ) );
    }
    }

    PDFTextStripper stripper = null;
    if(toHTML)
    {
    stripper = new PDFText2HTML();
    }
    else
    {
    stripper = new PDFTextStripper();
    }
    stripper.setSortByPosition( sort );
    stripper.setStartPage( startPage );
    stripper.setEndPage( endPage );
    stripper.writeText( document, output );
    }
    finally
    {
    if( output != null )
    {
    output.close();
    }
    if( document != null )
    {
    document.close();
    }
    }
    }
    }
    /**
    * This will print the usage requirements and exit.
    */
    private static void usage()
    {
    System.err.println( "Usage: java org.pdfbox.ExtractText [OPTIONS] <PDF file> [Text File]\n" +
    " -password <password> Password to decrypt document\n" +
    " -encoding <output encoding> (ISO-8859-1,UTF-16BE,UTF-16LE,...)\n" +
    " -console Send text to console instead of file\n" +
    " -html Output in HTML format instead of raw text\n" +
    " -sort Sort the text before writing\n" +
    " -startPage <number> The first page to start extraction(1 based)\n" +
    " -endPage <number> The last page to extract(inclusive)\n" +
    " <PDF file> The PDF document to use\n" +
    " [Text File] The file to write the text to\n"
    );
    System.exit( 1 );
    }
    public static java.lang.String pdf2xml(java.lang.String inp) {
    try{
    abc(inp);
    }
    catch( Exception e){}
    a = inp;
    java.lang.String out = a;

    // your custom code goes here

    return out;
    }

    }

    reply me ASAP
    regards
    yuvaraj
     
    |
    Mark as:
  • Currently Being Moderated
    Jun 5, 2008 5:04 AM   in reply to (Arash_Joorabchi)
    How to convert a pdf document into xml file format... Help me with codings... I am in need of it.. Pls help me
     
    |
    Mark as:
  • Currently Being Moderated
    Jun 6, 2008 6:45 AM   in reply to (Arash_Joorabchi)
    We can get the XML data out of a PDF, but we can't convert the PDF to XML.

    Jasmin
     
    |
    Mark as:
  • Currently Being Moderated
    Jun 12, 2008 11:18 AM   in reply to (Arash_Joorabchi)
    How do I get the XML data out of a PDF?
     
    |
    Mark as:
  • Currently Being Moderated
    Jun 12, 2008 1:12 PM   in reply to (Arash_Joorabchi)
    Using the LiveCycle Form Data Integration's Export data or LiveCycle Form's processFormSubmission.

    Jasmin
     
    |
    Mark as:
  • Currently Being Moderated
    Jun 13, 2008 4:45 AM   in reply to (Arash_Joorabchi)
    I just want to rectify something I said in a post earlier:

    "...but we can't convert the PDF to XML"

    We actually CAN convert PDF to XML using ExportPDF( ) and ExportPDF2( ) operations in GeneratePDF service.

    Sorry for the confusion.

    Jasmin
     
    |
    Mark as:
  • Currently Being Moderated
    Aug 14, 2008 7:09 PM   in reply to (Arash_Joorabchi)
    How to convert pdf file to xml
     
    |
    Mark as:
  • Currently Being Moderated
    Sep 10, 2008 6:42 PM   in reply to (Arash_Joorabchi)
    hi
    can any1 plz tel mi how to convert a pdf file into an xml file......Thank u
     
    |
    Mark as:
  • Currently Being Moderated
    Sep 11, 2008 1:55 AM   in reply to (ashwinseq)
    > can any1 plz tel mi how to convert a pdf file into an xml file......Thank u

    What sort of XML file? What PDF content?


    Aandi Inston
     
    |
    Mark as:
  • Currently Being Moderated
    Sep 11, 2008 3:05 AM   in reply to (Arash_Joorabchi)
    hi linston.....actually i hav got a application form frm one comapy....its in pdf format....they hav told us to fill tat forn n send it back in .xml format.....i wantd to knw how to convert tat .pdf file into .xml file.......am usin adobe 9.......liston can u givmi ur email address....i will mail tat form to u......dude plzzz help mi
     
    |
    Mark as:
  • Currently Being Moderated
    Sep 11, 2008 7:23 AM   in reply to (ashwinseq)
    Sorry, no email. Messages are all public so people can benefit in
    future.

    The people who sent you the form need to explain what you need to do.
    For instance, there may be a button on the form to click.

    Aandi Inston
     
    |
    Mark as:
  • Currently Being Moderated
    Jan 8, 2009 9:42 AM   in reply to (Arash_Joorabchi)
    Hi Aandi

    Is there a way to convert PDF to XML? If yes, how do I do that?

    Thanks
    Jayashree
     
    |
    Mark as:
  • Currently Being Moderated
    Jan 8, 2009 10:49 AM   in reply to (Arash_Joorabchi)
    Are you looking at getting the data out of the form in an xml format or are you trying to convert the whole pdf to xml?
     
    |
    Mark as:
  • Currently Being Moderated
    Jan 20, 2009 4:45 PM   in reply to (Arash_Joorabchi)
    Re Jasmin's answer from 10:18am Jul 23, 07 PST (#6 of 27) "So is this really a html representation of the PDF. PDFG should be the product that can convert PDF into HTML. The operation is ExportPDF." What version of PDFG would that be? We have v 6.0 and it doesn't have the Export PDF function. We just need to convert a PDF to HTML keeping tables etc in tact. Help please!
     
    |
    Mark as:
  • Currently Being Moderated
    Jan 21, 2009 4:57 AM   in reply to (Arash_Joorabchi)
    The HTML conversion in PDF/G was added in version 8
     
    |
    Mark as:
  • Currently Being Moderated
    Jan 27, 2009 1:26 PM   in reply to (Arash_Joorabchi)
    I have a pdf form and i want to get data from form in a XML format. I assume that is doable using Export feature of Adobe Live Cycle.
    However, by default, in this XML, every cell is converted to an element in XML. However, I want to get some cells as attributes.
    Is it doable?
    Please advise.
    Thanks!
     
    |
    Mark as:
  • Currently Being Moderated
    Jan 28, 2009 5:16 AM   in reply to (Arash_Joorabchi)
    No ....by default that is the way it works. You coudl apply a style sheet to reformat the XML in the way that you want.
     
    |
    Mark as:
  • Currently Being Moderated
    Jan 29, 2009 5:48 AM   in reply to (Arash_Joorabchi)
    Thanks,Paul.

    Do you have some online resources which could be helpful in learning and applying style sheets for reformatting XML?
    some links etc..
    Thank you!
     
    |
    Mark as:
  • Currently Being Moderated
    Jan 29, 2009 6:51 AM   in reply to (Arash_Joorabchi)
    There are plenty of sites out there. Simply do a search for XSLT and you will find plenty of material.
     
    |
    Mark as:
  • Currently Being Moderated
    Feb 9, 2009 5:51 AM   in reply to (Arash_Joorabchi)
    hi all,

    actually i want to know is there some code to extract xsd from pdf form in java through itext.

    thanx and regards,
    Gaurav
     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)