rtf zuwa pdf

Canza takaddar RTF zuwa PDF ta amfani da C# .NET

Tsarin Rubutun Mawadaci (RTF) tsari ne na fayil da aka yi amfani da shi sosai don ƙirƙirar takaddun da ke ɗauke da wadataccen rubutu, hotuna, da sauran abubuwan tsarawa. Koyaya, a wasu lokuta, kuna iya buƙatar canza takaddun RTF ɗinku zuwa PDF, ko dai don adanawa, bugu, ko dalilai na rabawa. PDF sanannen tsarin fayil ne wanda aka yarda da shi a ko’ina cikin dandamali da na’urori daban-daban, yana mai da shi kyakkyawan zaɓi don canza takarda. A cikin wannan labarin, za mu bincika dalilan da ya sa za ku buƙaci canza RTF zuwa PDF, kuma mu nuna muku yadda ake aiwatar da tsarin juyawa ta amfani da NET Cloud SDK. Ko kai mai haɓakawa ne da ke neman sarrafa tsarin jujjuyawa ko kuma mai amfani da ba fasaha ba wanda ke buƙatar canza wasu takardu, wannan labarin na ku ne.

API ɗin Canjawar Takardun PDF zuwa RTF

Hakanan akwai sabis na tushen gajimare da APIs da yawa don wannan dalili. Koyaya, Aspose.Words Cloud don NET, wanda ke ba da hanya mai sauƙi da inganci don canza fayilolin RTF zuwa PDF.

API ɗin REST ne wanda za’a iya haɗa shi cikin sauƙi cikin aikace-aikacen NET ɗinku don aiwatar da ayyuka daban-daban akan takaddun Word, gami da ƙirƙira, gyarawa, canzawa, da sarrafa rubutu. Tare da fasalulluka masu ƙarfi da cikakkun takardu, Aspose.Words Cloud SDK don NET kyakkyawan zaɓi ne ga masu haɓakawa da ke neman sarrafa tsarin RTF zuwa PDF. Don haka da fatan za a bincika ‘Aspose.Words-Cloud’ a cikin manajan fakitin NuGet kuma danna maɓallin Ƙara Kunshin don ƙara bayanin SDK a cikin aikin NET. Na biyu, sami takaddun shaidar abokin ciniki daga Cloud dashboard.

Yi rajista kawai idan ba ku da asusun da ke akwai akan dashboard ɗin Cloud.

Canza RTF zuwa PDF akan layi ta amfani da C#

Wannan sashe yana bayanin matakai da cikakkun bayanai game da yadda ake haɓaka RTF zuwa mai sauya PDF akan layi ta amfani da C# .NET.

// Don cikakkun misalai da fayilolin bayanai, da fatan za a je zuwa 
https://github.com/aspose-words-cloud/aspose-words-cloud-dotnet

// Samu bayanan abokin ciniki daga https://dashboard.aspose.cloud/
string clientSecret = "4d84d5f6584160cbd91dba1fe145db14";
string clientID = "bb959721-5780-4be6-be35-ff5c3a6aa4a2";

// ƙirƙiri abin daidaitawa ta amfani da ClinetID da bayanan Sirrin Abokin ciniki
var config = new Aspose.Words.Cloud.Sdk.Configuration { ClientId = clientID, ClientSecret = clientSecret };
// fara misali WordsApi
var wordsApi = new WordsApi(config);

// shigar da daftarin aiki
string inputFile = "file-sample.rtf";
string format = "PDF";
string resultant = "output.pdf";

try
{
 // loda fayil ɗin daga rumbun gida
    using (var file = System.IO.File.OpenRead(inputFile))
    {
        var uploadFileRequest = new UploadFileRequest(file, inputFile);
        
        // loda fayil zuwa ma'ajiyar Cloud
        wordsApi.UploadFile(uploadFileRequest);
   }
    
    // ƙirƙirar DocumentWithFormat abu nema
    var response = new GetDocumentWithFormatRequest(inputFile, format,outPath: resultant);
    
    // fara aikin daftarin aiki
    wordsApi.GetDocumentWithFormat(response);

    // buga saƙon nasara idan tuba ya yi nasara
    if (response != null && response.Equals("OK"))
    {
        Console.WriteLine("RFT to PDF conversion successfull !");
        Console.ReadKey();
    }
}catch (Exception ex)
{
    Console.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace);
}
rtf zuwa pdf mai canzawa

Hoto: - RTF zuwa PDF Samfoti na Juyin Juya.

Bari mu haɓaka fahimta game da guntun lambar juyawa.

var config = new Configuration { ClientId = clientID, ClientSecret = clientSecret };
var wordsApi = new WordsApi(config);

Ƙirƙiri wani abu na Kanfigareshan da misalin WordsApi inda ake amfani da takaddun shaidar abokin ciniki azaman muhawara.

var response = new GetDocumentWithFormatRequest(inputFile, format: format, outPath: resultant);

Ƙirƙiri misalin abu na GetDocumentWithFormat inda muke samar da sunan RTF shigarwa, tsarin sakamako kamar ‘PDF’ da sunan sakamakon daftarin aiki PDF azaman muhawara.

wordsApi.GetDocumentWithFormat(response);

Yanzu, kira wannan hanyar don fara aikin RFT zuwa PDF. Sakamakon PDF ana adana shi a cikin ma’ajiyar gajimare.

Idan muka tsallake gardamar waje, za a dawo da sakamakon PDF a rafin martani.

Za a iya sauke fayil ɗin shigarwar RFT da aka yi amfani da shi a cikin misalin da ke sama daga input-sample.rft.

Maida Takardun Rubutun Mai Arziki zuwa PDF ta amfani da Umarnin CURL

Wata hanyar canza RTF zuwa PDF ita ce ta amfani da umarnin CURL. cURL kayan aiki ne na layin umarni wanda ke ba ku damar canja wurin bayanai daga zuwa sabobin ta amfani da ka’idoji daban-daban, gami da HTTP, FTP, da SMTP. Tare da cURL, zaku iya sauya fayilolin RTF zuwa PDF cikin sauƙi ta yin buƙatun API zuwa sabis na canza RTF zuwa PDF akan layi.

A cikin wannan labarin, za mu nuna muku yadda ake amfani da umarnin cURL don canza RTF zuwa PDF, samar da jagorar mataki-mataki wanda ya haɗa da mahimman bayanai akan sabis na canza RTF na kan layi zuwa PDF, yadda ake tantancewa tare da APIs ɗin su, da kuma ta yaya. don aiwatar da tsarin juyawa ta amfani da umarnin cURL.

Don haka, mataki na farko shine samar da alamar samun damar JWT (bisa ga shaidar abokin ciniki) ta amfani 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 mun sami accessToken, da fatan za a aiwatar da umarni mai zuwa wanda ke loda daftarin aiki na RFT daga ma’ajin gajimare kuma ya canza shi zuwa tsarin PDF. Hakanan ana adana sakamakon PDF a cikin ma’ajiyar gajimare.

curl -v "https://api.aspose.cloud/v4.0/words/{inputFile}?format=PDF&outPath={resultantFile}" \
-X GET \
-H  "accept: application/octet-stream" \
-H  "Authorization: Bearer {accessToken}"

Sauya {inputFile} tare da sunan shigar da takaddun RFT da ke cikin Cloud Cloud, {accessToken} tare da alamar samun damar JWT da aka samar a sama da `{resultantFile}’ tare da suna/hanyar zuwa fayil ɗin PDF.

Kammalawa

Mayar da RTF zuwa PDF abu ne gama gari ga masu amfani da yawa, kuma akwai hanyoyi da yawa don cimma wannan burin, gami da amfani da C# .NET, sabis na tushen girgije, da umarnin cURL. A cikin wannan labarin, mun bincika hanyoyi daban-daban game da canza RTF zuwa PDF, samar da cikakken jagora wanda ya haɗa da umarnin mataki-mataki da bayanai masu mahimmanci. Ko kai mai haɓakawa ne da ke neman sarrafa tsarin jujjuyawa ko mai amfani da ba fasaha ba wanda ke buƙatar canza ƴan takardu, wannan labarin yana ba da kewayon mafita waɗanda zasu dace da bukatun ku.

Hanyoyin haɗi masu amfani

Labarai masu alaka

Da fatan za a ziyarci hanyoyin haɗin yanar gizon don ƙarin koyo game da: