400 error code converting Pdf to xml

Error: GetPdfInStorageToXml. Exception: Logical element does not contain K entry…

Does any one know what this error is about?

@yulianto8327
Please share your input document and code sample to reproduce the issue.

Profileen.pdf (37.4 KB)

It’s a pdf exported from LinkedIn.

Code is

$pdfApi = new PdfApi(null, $config);
$name = 'Profileen.pdf';//in server
$response = $pdfApi->getPdfInStorageToXmlWithHttpInfo($name);

@yulianto8327
We will investigate this issue.

@yulianto8327
We have noticed the reported issues and logged the following tickets in our issue tracking system for further investigation and rectification. We will notify you as soon as these issues are resolved.

PDFCLOUD-4344: getPdfInStorageToXmlWithHttpInfo returns 400 http code

Hi Kiril, do you know when this kind of issue can usually be solved? Thanks

@yulianto8327
Issue will resolved in version 24.8 (middle of august)

@yulianto8327
The issues you have found earlier (filed as PDFCLOUD-4344) have been fixed in this version 24.8. Please update client sdk.

Thanks, it’s running now. Now, I want to convert the pdf to XML. But I could not find the documentation/sample code for this. Are you able to show how I can convert pdr to XML.

@yulianto8327
You can use one of two methods to convert pdf to xml, depending on your needs:

  1. aspose-pdf-cloud-php/docs/PdfApi.md at master · aspose-pdf-cloud/aspose-pdf-cloud-php (github.com)
  2. aspose-pdf-cloud-php/docs/PdfApi.md at master · aspose-pdf-cloud/aspose-pdf-cloud-php (github.com)

The pdf cloud api also provides methods for exporting fields from a pdf document to xml. You can find a list of all api methods in the repository: aspose-pdf-cloud-php/docs/PdfApi.md at master · aspose-pdf-cloud/aspose-pdf-cloud-php (github.com)

You can also find examples in the repository: aspose-pdf-cloud-php/Examples at master · aspose-pdf-cloud/aspose-pdf-cloud-php (github.com)

Thanks. I use this now:

>   $file = $pdfApi->getPdfInStorageToXml("Profileen.pdf");
>   $response = $pdfApi->putPdfInRequestToXml(dirname(__FILE__)."/result.xml",null,$file);
>   print_r($response);

I got this error:

Fatal error : Uncaught Aspose\PDF\ApiException: [500] Server error: PUT https://api.aspose.cloud/v3.0/pdf/convert/xml?outPath=%2Fxxxxxxxresult.xml resulted in a 500 Internal Server Error response: {“RequestId”:“0b3063ea8acc0dadf7e9ddf8c1590305”,“Error”:{“Code”:“internalError”,“Message”:“Incorrect file header”,"Descr (truncated…) in /xxxxxxxx/aspose/src/Aspose/PDF/Api/PdfApi.php:

@yulianto8327
The third parameter of the putPdfInRequestToXml method must be a pdf file.
Due to the fact that the xml received from the getPdfInStorageToXml method is being passed, an error occurs.
Can you explain in more detail what exactly you want to do?

I just want to convert Profileen.pdf to a XML file

You can use this code snippet, and the xml result file will be returned in response, or you can use putPdfInStorageToXml, If you want to store the xml file in the storage.

Thanks. I’m able to convert the pdf and store it in server.

  1. Is it possible to use the pdf in our own server? and the store the XML in our own server?
  2. how do I upload pdf in Internal Storage, and then retrieve it?

@yulianto8327

  1. You can use Self-Hosting image from aspose/pdf-cloud - Docker Image | Docker Hub to deploy the storage locally, in other cases, calling the api method will use cloud storage.
  2. In your case use this code snippet:
    	$sourceFilename = __DIR__.'/Profileen.pdf';
        $resultFilename = __DIR__.'/Profileen.xml';
        $pdfApi->uploadFile(basename($sourceFilename), $sourceFilename);
        $pdfApi->putPdfInStorageToXml(basename($sourceFilename), basename($resultFilename));
        $xml = $pdfApi->downloadFile(basename($resultFilename));
        rename($xml->getPathname(), $resultFilename);

It’s able to save the XML in cloud storage. But it’s not saved in my server, in this case DIR.‘/Profileen.xml’;

@yulianto8327

        $xml = $pdfApi->downloadFile(basename($resultFilename));
        rename($xml->getPathname(), $resultFilename);

This code will download the file from the repository and save it in the directory where the script is located.

Does some exception occurs?

it does not saved the xml, and no exception occurs

@yulianto8327
$xml->getPathname() is a path to temp file. Does it exists on the server?
Can you provide server configuration?