PDF zuwa HTML

Maida PDF zuwa HTML ta amfani da NET REST API.

Takardun PDF sanannen zaɓi ne don raba bayanai saboda daidaiton tsarin su a cikin na’urori da dandamali daban-daban. Amma idan ya zo ga nuna abun ciki akan gidan yanar gizo, PDFs na iya zama ba koyaushe zaɓi mafi kyawun mai amfani ba. Koyaya, juyar da fayilolin PDF zuwa tsarin HTML yana buɗe duniyar yuwuwar masu haɓaka gidan yanar gizo da masu ƙirƙirar abun ciki. Wani dalili na wannan jujjuya shi ne cewa gabatarwar abun ciki da samun dama sune mahimman dalilai don nasarar kan layi yayin da ya zama mai ƙididdigewa ta injunan bincike.

A cikin wannan labarin, za mu shiga cikin cikakkun bayanai kan yadda ake canza PDF zuwa HTML ta amfani da .NET REST API.

API ɗin REST don Canjawar PDF zuwa HTML

Aiwatar da fassarar PDF zuwa HTML yana da sauƙi tare da ƙarfin ƙarfin Aspose.PDF Cloud SDK don NET. Wannan API ɗin yana ba ku damar haɗa ayyukan jujjuya PDF ba tare da ɓata lokaci ba cikin aikace-aikacen NET ɗinku da tafiyar aiki. Tare da ƴan layukan code kawai, zaku iya juyar da takaddun PDF zuwa tsarin HTML ba tare da wahala ba, yana sa su dace da nunin gidan yanar gizo da hulɗa. API ɗin REST yana ba da fa’idodi da yawa don sarrafa tsarin juyawa. Hakanan zaka iya keɓance fitarwar HTML ta hanyar ƙididdige sunan font tsoho, nau’in takarda, shimfidar wuri, ƙudurin hoto da sauran jeri daban-daban.

Domin farawa da wannan tsarin jujjuyawa, da farko muna buƙatar ƙara bayanin SDK a cikin aikinmu kuma don wannan dalili, da fatan za a bincika ‘Aspose.PDF-Cloud’ a cikin manajan fakitin NuGet a cikin Visual Studio IDE kuma danna maɓallin ‘Ƙara Kunshin’ . 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.

Maida PDF zuwa HTML ta amfani da C# .NET

Yanzu muna buƙatar aiwatar da snippet code mai zuwa don yin jujjuya don mu iya sanya PDF zuwa gidan yanar gizo.

// 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 = "4d84d5f6584160cbd91dba1fe145db14";
string clientID = "bb959721-5780-4be6-be35-ff5c3a6aa4a2";

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

// Shigar da sunan fayil na PDF
String inputFile = "Binder1-1.pdf";
// karanta abun ciki na shigar da fayil ɗin PDF
var pdfFile = System.IO.File.OpenRead(inputFile);

// Kira API don canza fayil ɗin PDF zuwa HTML kuma adana fitarwa zuwa ma'ajin gajimare
// Mun ayyana tsarin fitarwa na HTML a matsayin `HTML5` 
// Tuta don adana kowane shafi na PDF azaman fayil ɗin HTML daban yana kunna
// Za a samar da fitarwa azaman .ZIP archive
pdfApi.PutPdfInRequestToHtml("converted.zip",documentType: "Html5", 
    splitIntoPages: true, rasterImagesSavingMode: "AsPngImagesEmbeddedIntoSvg", 
    outputFormat: "Zip" , file: pdfFile);
PDF zuwa HTML

PDF zuwa HTML samfoti.

An bayar a ƙasa akwai cikakkun bayanai game da snippet na sama da aka bayyana.

PdfApi pdfApi = new PdfApi(clientSecret, clientID);

Da fari dai, ƙirƙiri wani abu na ajin PdfApi yayin ƙaddamar da bayanan abokin ciniki azaman mahawara ta shigarwa.

var pdfFile = System.IO.File.OpenRead(inputFile);

Karanta abun cikin fayil ɗin PDF daga faifan gida.

pdfApi.PutPdfInRequestToHtml("converted.html",documentType: "Html5", splitIntoPages: true, rasterImagesSavingMode: "AsPngImagesEmbeddedIntoSvg", outputFormat: "Zip" , file: pdfFile);

Kira API don canza PDF daga rafi na shigarwa zuwa tsarin HTML. A lokacin jujjuyawa, mun ƙayyadadden ƙimar don adana kowane shafi na PDF zuwa fayil ɗin HTML ɗaya.

Da fatan za a ziyarci PutPdfInRequestToHtml don cikakken jerin goyan bayan muhawara ta wannan kiran API da cikakkun bayanai masu alaƙa.

Za a iya sauke takardun shigar da PDF da aka yi amfani da shi a cikin misalin da ke sama daga Binder1.pdf.

PDF zuwa HTML Online ta amfani da Umarnin CURL

Mayar da PDF zuwa HTML ta amfani da umarnin cURL a hade tare da Aspose.PDF Cloud kuma hanya ce mai dacewa da inganci. Ta hanyar yin amfani da ikon umarni na cURL, zaku iya haɗa Aspose.PDF Cloud API cikin sauƙi cikin aikace-aikacenku kuma ku sarrafa tsarin PDF zuwa HTML. Bugu da ƙari, yin amfani da umarnin cURL yana ba da damar hulɗa mai sauƙi tare da RESTful wuraren ƙarewa, yana ba da damar sadarwa maras kyau da musayar bayanai. Don haka don nuna PDF a cikin burauzar HTML, kawai muna buƙatar canza fayilolin PDF zuwa HTML ta hanyar kiran wasu umarni na CURL, kuma yana rage haɓaka lokaci da ƙoƙari sosai.

Mataki na farko a wannan tsarin 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=bb959721-5780-4be6-be35-ff5c3a6aa4a2&client_secret=4d84d5f6584160cbd91dba1fe145db14" \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -H "Accept: application/json"

Yanzu muna buƙatar aiwatar da umarnin cURL mai zuwa wanda ke ɗaukar fayil ɗin PDF daga ajiyar girgije, yana canza duk takaddun zuwa tsarin HTML kuma yana adana fitarwa azaman .ZIP archive akan drive na gida (sunan da aka ƙayyade tare da hujja -o).

curl -v "https://api.aspose.cloud/v3.0/pdf/{inputPDF}/convert/html?compressSvgGraphicsIfAny=false&documentType=Html5&fixedLayout=true&splitIntoPages=false&rasterImagesSavingMode=AsPngImagesEmbeddedIntoSvg&removeEmptyAreasOnTopAndBottom=true&flowLayoutParagraphFullWidth=true" \
-X GET \
-H  "accept: multipart/form-data" \
-H  "authorization: Bearer {accessToken}" \
-o "Converted.zip"

Sauya ‘inputPDF’ tare da sunan shigar da takaddun PDF da ke cikin ma’ajiyar girgije, da ‘accessToken’ tare da alamar samun damar JWT da aka samar a sama.

Kammalawa

A ƙarshe, canza PDF zuwa HTML tare da Aspose.PDF Cloud API yana ba da cikakkiyar bayani mai mahimmanci. Ko yin amfani da .NET REST API don haɗin kai maras kyau ko umarnin cURL don ingantaccen canji, Aspose.PDF Cloud SDK yana ba da fa’idodi masu yawa da zaɓuɓɓukan gyare-gyare. Waɗannan hanyoyin suna tabbatar da ingantacciyar ma’anar abun ciki na PDF zuwa HTML mai amsawa, adana shimfidawa da tsarawa don ingantaccen ƙwarewar mai amfani. Bugu da ƙari, ikon shigar da abun ciki na PDF a cikin shafukan HTML yana ba da damar yin amfani da aikace-aikacen gidan yanar gizo mai ma’ana da ma’amala, haɓaka samun dama da haɗin kai mai amfani.

Hanyoyin haɗi masu amfani

Labarai masu alaka

Muna ba da shawarar ziyartar shafukan yanar gizo masu zuwa: