pdf zuwa xml

Maida PDF zuwa XML tare da NET REST API.

A cikin shimfidar wuri na dijital, buƙatar juyawa PDF zuwa XML ) bai taɓa zama mai mahimmanci ba. Ko da yake PDF yana da kyau wajen adana tsari da rabawa, amma sau da yawa yakan haifar da ƙalubale idan ya zo ga cirewa da tsara bayanai. Ganin cewa a daya bangaren, XML harshe ne mai ma’ana wanda aka tsara don tsarawa, adanawa, da jigilar bayanai. Ta hanyar juyar da PDFs zuwa XML, muna ƙaddamar da rata tsakanin abubuwan da ba a tsara su ba da kuma bayanan da aka tsara, suna ba da damar ɗimbin aikace-aikace, kama daga nazarin bayanai zuwa sake amfani da abun ciki.

Bari mu shiga cikin cikakkun bayanai kan yadda ake canza PDF zuwa XML ta amfani da .NET REST API.

API ɗin REST na PDF zuwa Canjin XML

Yin amfani da damar Aspose.PDF Cloud SDK don NET, juyawa ya zama maras kyau da tasiri. Bayan PDF zuwa jujjuya XML kawai, wannan SDK mai ƙarfi yana ba da fa’idodi iri-iri-daga sarrafa daftarin aiki zuwa hakar bayanai. Bari mu bincika tsarin jujjuya PDF zuwa XML don sauya yadda muke sarrafa da amfani da bayanan daftarin aiki.

Da fatan za a bincika ‘Aspose.PDF-Cloud’ a cikin manajan fakiti na NuGet a cikin Visual Studio IDE kuma danna maɓallin ‘Ƙara Kunshin’, don ƙara bayanin SDK a cikin aikin.

Hakanan kuna buƙatar samun takaddun shaidar abokin ciniki daga cloud dashboard. Idan ba ku da asusun da ke akwai, kawai ƙirƙiri asusun kyauta ta bin umarnin da aka kayyade a kan saurin farawa.

Haɓaka PDF zuwa Fayil na XML a cikin C# .NET

Da fatan za a bi umarnin da aka bayar a ƙasa don canza fayil ɗin PDF zuwa XML don tsarin wakilcin bayanai.

// Don ƙarin misalai, https://github.com/aspose-pdf-cloud/aspose-pdf-cloud-dotnet/tree/master/Examples

// Samu bayanan abokin ciniki daga https://dashboard.aspose.cloud/
string clientSecret = "c71cfe618cc6c0944f8f96bdef9813ac";
string clientID = "163c02a1-fcaa-4f79-be54-33012487e783";

// ƙirƙirar misali na PdfApi
PdfApi pdfApi = new PdfApi(clientSecret, clientID);

var response = pdfApi.GetPdfInStorageToXml("Hardy02.pdf");

if (response != null)
{
    Console.WriteLine("PDF to XML conversion completed successfully !");
}
saveToDisk(response,"ResultantFile.xml");


// Hanyar da aka saba don adana abun cikin rafi zuwa fayil akan faifan gida
public static void saveToDisk(Stream responseStream, String resultantFile)
{
    var fileStream = File.Create(resultantFile);
    responseStream.Seek(0, SeekOrigin.Begin);
    responseStream.CopyTo(fileStream);
    fileStream.Close();
}

Ana ba da cikakkun bayanai masu sauri game da snippet na sama da aka bayyana.

PdfApi pdfApi = new PdfApi(clientSecret, clientID);

Ƙirƙiri wani abu na ajin PdfApi yayin ƙaddamar da shaidar abokin ciniki azaman mahawara ta shigarwa.

pdfApi.GetPdfInStorageToXml("Hardy02.pdf");

Yanzu, kira API don canza fayil ɗin PDF mai alamar zuwa tsarin XML. Sa’an nan kuma muna amfani da hanyar da aka saba don adana abin fitarwa zuwa faifan gida.

Maida PDF zuwa XML tare da Umarnin CURL

Juyawa daga PDF zuwa XML ya zama ingantaccen inganci da sassauƙa yayin amfani da Aspose.PDF Cloud API tare da umarnin cURL. Wannan haɗin gwiwa mai ƙarfi ba kawai yana sauƙaƙa tsarin jujjuyawar ba amma yana haɓaka samun damar bayanai da amfani a cikin nau’ikan aikace-aikace. Yanzu bari mu bincika wasu ƙarin cikakkun bayanai game da wannan jujjuya kamar yadda yake sauƙaƙe cire bayanai, rabawa, da fassarar.

Mataki na farko na wannan hanyar shine ƙirƙirar alamar samun damar JWT. Don haka, da fatan za a aiwatar da umarni mai zuwa:

curl -v "https://api.aspose.cloud/connect/token" \
 -X POST \
 -d "grant_type=client_credentials&client_id=163c02a1-fcaa-4f79-be54-33012487e783&client_secret=c71cfe618cc6c0944f8f96bdef9813ac" \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -H "Accept: application/json"

Da zarar an ƙirƙiri alamar JWT, muna buƙatar aiwatar da umarni mai zuwa don canza fayil ɗin PDF mai alamar zuwa tsarin XML. Bayan tuba, ana adana sakamakon XML akan faifan gida.

curl -v "https://api.aspose.cloud/v3.0/pdf/{sourceFile}/convert/xml" \
-X GET \
-H "accept: multipart/form-data" \
-H  "authorization: Bearer {accessToken}" \
-o "Converted.xml"

Sauya ‘sourceFile’ tare da sunan shigar da fayil ɗin PDF da aka rigaya akwai a cikin Cloud Cloud kuma, maye gurbin ‘accessToken’ tare da alamar samun damar JWT da aka samar a sama.

Kammalawa

A ƙarshe, ko neman ingantaccen Aspose.PDF Cloud SDK don NET ko amfani da umarnin cURL tare da Aspose.PDF Cloud, za mu iya cimma manufar mu cikin sauƙi na jujjuya sumul daga PDF zuwa tsarin XML don ingantaccen amfani da bayanai. Don haka, ba tare da la’akari da hanyar da aka zaɓa ba, hanyoyin biyu suna tsaye azaman kayan aiki masu ƙarfi, suna canza yadda muke tsarawa da fitar da bayanai daga PDFs.

Hanyoyin haɗi masu amfani

Labarai masu alaka

Muna ba da shawarar ziyartar shafukan yanar gizo masu zuwa: