Error: GetPdfInStorageToXml. Exception: Logical element does not contain K entry…
Does any one know what this error is about?
Error: GetPdfInStorageToXml. Exception: Logical element does not contain K entry…
Does any one know what this error is about?
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 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
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:
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.
$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’;
$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?