You are viewing limited content. For full access, please sign in.

Question

Question

pdf import fails using XML in Import Agent

asked on August 14, 2024

Does anyone has some experience with importing PDF files along with template field values into Laserfiche, using XML files in Import Agent and provide me with some badly needed guidance as to how to accomplish that? 

Any Help will be greatly appreciated!

when I try to import PDF files using an XML file with and Import Agent Profile, it fails. If I change the file type in the XML from .pdf to .tiff it succeeds. The file comes with a template and fields correctly defined in the XML and so, when TIFF is imported it passes with fields and everything, right. When using PDF it just doesn´t do it.

This is the readout of the error in the Windows Event Viewer:

summary
An error occurred while importing the XML list file “\\ADMINISTRACIÓN\OFSOL\ADM1_OFSOL_987654.xml” when executing the ADMIN_OFSOL profile xml.
message
Lfi_GetFileInfo failed.(FileStream: name [Unknown], length 174363)(HRESULT: 0x88982F07 : WINCODEC_ERR_UNKNOWNIMAGEFORMAT)
stackTrace
at Laserfiche.Imaging.LfiBitmapDecoder..ctor(Stream bitmapStream, BitmapCreateOptions createOptions) at Laserfiche.ImportAgent.Service.ExecuteProfileXmlFile.ProcessImagesInXML(ExecutionContext context, XmlDocument document) at Laserfiche.ImportAgent.Service.ExecuteProfileXmlFile.ProcessXMLFile(ExecutionContext context, Session LFDatabase, Boolean willBurnPdfAnnotation) in Laserfiche.ImportAgent.Service.ExecuteProfileXmlFile.ImportFile(ExecutionContext context) 

 

AND this is the xml file that is to be processed by Import Agent but fails (if I only change the PDF for a TIFF file in the XML definition, and of course provide an actual TIFF file in the right location, it works great.) 

<?xml version="1.0" encoding="utf-8"?>
<LF:importengine xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://laserfiche.com/namespaces/importengine ImportEngine.xsd" xmlns:LF="http://laserfiche.com/namespaces/importengine" version="1.0">
 <LF:toc on_document_conflict="unique" on_folder_conflict="unique">
  <LF:document name="Doc 1 - 1 page(s)" template="ADMIN_OFSOL">
   <LF:metadata>
    <LF:field_values>
       <LF:field_value name="Dependencia">Pruebas Innovación X</LF:field_value>
       <LF:field_value name="NumerodeOficio">987654</LF:field_value>
       <LF:field_value name="Fecha">15/05/2023</LF:field_value>
       <LF:field_value name="Economico">Número Económico X</LF:field_value>
       <LF:field_value name="Placas">Placas X</LF:field_value>
       <LF:field_value name="Modelo">Módulo X</LF:field_value>
       <LF:field_value name="Tipo">Tipo X</LF:field_value>
       <LF:field_value name="ServicioaRealizar">Servicio a Realizar X</LF:field_value>
    </LF:field_values>
   </LF:metadata>
      <LF:pages>
        <LF:page ocr="false">
          <LF:imagepart>
            <LF:fileref ref="\\\ADMINISTRACION\OFSOL\ADM1_OFSOL_987654.pdf" />
          </LF:imagepart>
        </LF:page>
      </LF:pages>
    </LF:document>
  </LF:toc>
</LF:importengine>

 

0 0

Answer

SELECTED ANSWER
replied on August 14, 2024 Show version history

The issue is that a PDF is considered an electronic file so the XML is different then when you import a TIF.

If you format your XML like below it will work:

?xml version="1.0" encoding="utf-8"?>
  <LF:importengine xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xsi:schemaLocation="http://laserfiche.com/namespaces/importengine ImportEngine.xsd"
                   xmlns:LF="http://laserfiche.com/namespaces/importengine" version="1.0">
    
    <LF:toc on_document_conflict="unique" on_folder_conflict="unique">      
      <LF:document name="Sample1" comment="" language="" template="Invoice">
		<LF:metadata>
			<LF:field_values>
			<LF:field_value name="Status">3. Awaiting Approval</LF:field_value>
			<LF:field_value name="Date Received">01/3/2018</LF:field_value>
			<LF:field_value name="Amount">8.75</LF:field_value>
			<LF:field_value name="Purchase Order">ABC123</LF:field_value>
			</LF:field_values>
		</LF:metadata>
        <LF:electronic_document content_type="application/pdf" extension="pdf">
			<LF:fileref ref="..\0002\sample1.pdf" />
        </LF:electronic_document>
      </LF:document>
    </LF:toc>
  
</LF:importengine>

Note: Sample List files can be found in the installation directory of Import Agent.

Ex. C:\Program Files\Laserfiche\Import Agent\List File Examples

Good Luck!

4 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.