Ɗaya daga cikin ƙa’idodin defacto don bayanai da raba bayanai akan intanit shine PDF. Dalilin shahararsa shine yana kiyaye shimfidawa da amincin takaddun idan an duba shi akan kowane dandamali ciki har da Desktop ko wayar hannu. Koyaya, don duba waɗannan fayilolin, kuna buƙatar amfani da aikace-aikacen duba PDF. Koyaya, mafita mai sauƙi shine canza PDF zuwa HTML kuma a sauƙaƙe loda HTML a cikin burauzar gidan yanar gizo. Don haka a cikin wannan labarin, za mu ƙara tattauna cikakkun bayanai kan yadda ake haɓaka PDF zuwa HTML ta amfani da REST API.
- API ɗin Canjin PDF zuwa HTML
- PDF zuwa HTML Converter a Java
- Maida PDF zuwa HTML ta amfani da Umarnin CURL
API ɗin Canjin SXC zuwa Excel
Domin ƙirƙira, sarrafa da canza fayilolin PDF zuwa wasu tsari, da fatan za a gwada amfani da Aspose.PDF Cloud SDK don Java. Yanzu don amfani da SDK, da fatan za a ƙara bayanin da ke gaba a cikin pom.xml na nau’in gini na maven.
<repositories>
<repository>
<id>aspose-cloud</id>
<name>artifact.aspose-cloud-releases</name>
<url>https://artifact.aspose.cloud/repo</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-pdf-cloud</artifactId>
<version>21.11.0</version>
</dependency>
</dependencies>
Yanzu da aka ƙara Aspose.PDF Cloud SDK don bayanin Java a cikin aikinku, mataki na gaba shine ƙirƙirar asusun kyauta akan Aspose Cloud. Shiga ta amfani da sabon asusun da aka ƙirƙira kuma bincika/ƙirƙiri ID na abokin ciniki da Sirrin Abokin ciniki a Cloud Dashboard. Ana buƙatar waɗannan cikakkun bayanai a cikin sassan da ke gaba.
PDF zuwa HTML Converter a Java
Bari mu tattauna cikakkun bayanai kan yadda ake haɓaka PDF zuwa mai sauya HTML ta amfani da Java Cloud SDK. Da fatan za a lura cewa a cikin bin snippet code, ana amfani da sigogi na asali sosai yayin aikin juyawa amma muna ba da shawarar ziyartar sashin API Reference don jerin duk sigogin da aka goyan baya da kuma bayanin su.
- Da farko muna buƙatar ƙirƙirar abu na PdfApi yayin samar da ClientID da sirrin abokin ciniki azaman muhawara
- Na biyu, shigar da fayil ɗin PDF ta amfani da misalin Fayil
- Na uku, loda shigar da PDF zuwa ma’ajiyar gajimare ta amfani da hanyar uploadFile(…).
- Tunda kawai muna buƙatar musanya shafi na biyu na PDF, don haka muna samar da ƙimar shafi na 2 a cikin abu List
- Yanzu kira hanyar putPdfInStorageToHtml(…) da ke buƙatar shigar da PDF, sunan sakamakon HTML da sauran sigogin juyawa daban-daban.
try
{
// Samu ClientID da ClientSecret daga https://dashboard.aspose.cloud/
String clientId = "bb959721-5780-4be6-be35-ff5c3a6aa4a2";
String clientSecret = "4d84d5f6584160cbd91dba1fe145db14";
// ƙirƙirar misali na PdfApi
PdfApi pdfApi = new PdfApi(clientSecret,clientId);
// sunan shigar da takaddun PDF
String inputFile = "PdfWithScreenAnnotations.pdf";
// sunan resultant HTML fayil
String resultantImage = "Resultant.html";
// karanta abun ciki na shigar da fayil ɗin PDF
File file = new File("//Users//"+inputFile);
// loda PDF zuwa ma'ajiyar gajimare
pdfApi.uploadFile("input.pdf", file, null);
// jerin shafukan PDF da za a canza
List<Integer> list = new ArrayList<Integer>();
//list.kara (1);
list.add(2); // only convert second page of PDF
// kira API don canza PDF zuwa HTML
pdfApi.putPdfInStorageToHtml("input.pdf",resultant,null,null,null, null, "Html5",false, null,
null, null, false, false, null, null,null, list, null,
"AlwaysSaveAsTTF",null,null,null,"EmbedAllIntoHtml","AsEmbeddedPartsOfPngPageBackground",
null, null, null, null, null, null, null, null, null, "Zip");
// buga sakon nasara
System.out.println("PDF to HTML Successsul !");
}catch(Exception ex)
{
System.out.println(ex);
}
Za a iya sauke samfurin fayil ɗin PDF da aka yi amfani da shi a cikin misalin sama daga PdfWithScreenAnnotations.pdf
Maida PDF zuwa HTML ta amfani da Umarnin CURL
Umarnin CURL kuma ɗayan hanyoyi ne masu dacewa don samun damar APIs REST ta tashar layin umarni. Yanzu abin da ake buƙata don wannan hanyar shine ƙirƙirar alamar samun damar JWT (bisa ga shaidar abokin ciniki) yayin 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"
Da zarar muna da alamar JWT, muna buƙatar aiwatar da umarni mai zuwa don canza PDF zuwa HTML. Sakamakon HTML an adana shi azaman Rumbun ajiya na Cloud akan ma’ajiyar girgije.
curl -v -X PUT "https://api.aspose.cloud/v3.0/pdf/input.pdf/convert/html?outPath=resultant.zip&documentType=Html5&fixedLayout=false&splitCssIntoPages=false&splitIntoPages=false&explicitListOfSavedPages=2&fontSavingMode=AlwaysSaveAsTTF&partsEmbeddingMode=EmbedAllIntoHtml&rasterImagesSavingMode=AsEmbeddedPartsOfPngPageBackground&outputFormat=Zip" \
-H "accept: application/json" \
-H "authorization: Bearer <JWT Token>"
Kammalawa
Mun koyi matakai don haɓaka PDF zuwa mai sauya HTML ta amfani da Java Cloud SDK. Don haka ko dai za mu iya amfani da snippet code na Jave don canza PDF zuwa HTML ko kuma za mu iya amfani da umarnin cULR don canza PDF zuwa HTML5. Idan kuna son yin kowane canje-canje ga lambar tushe na Java Cloud SDK, ana iya sauke cikakkiyar lambar tushe daga GitHub. Kuna iya la’akari da kusantar mu don saurin warware batutuwa ta hanyar kyauta Tallafin tallafin samfur.
Labarai masu alaka
Muna ba da shawarar ziyartar hanyoyin haɗin yanar gizo masu zuwa don ƙarin koyo game da: