A zamanin dijital na yau, PDFs sun zama sanannen tsari don musayar bayanai, takardu, da rahotanni. Koyaya, kawai kallon PDF bazai isa ga masu amfani da yawa ba. Wani lokaci, masu amfani na iya so su haskaka ko ƙara bayanin kula zuwa takamaiman sassa na PDF don samar da ƙarin mahallin ko ra’ayi. Abin farin ciki, akwai masu ba da labari na PDF kyauta da yawa waɗanda ke ba masu amfani damar ƙara sharhi cikin sauƙi, haskaka rubutu, da ƙari. Koyaya, a cikin wannan labarin, zamu bincika yadda ake amfani da REST API don tallafawa bayanan PDF, da nuna muku yadda ake haskakawa, yin sharhi, da ƙara bayanin kula a takaddun PDF ɗinku.
- API ɗin REST don Bayanin PDF
- Ƙara sharhi zuwa PDF ta amfani da C#
- Ƙara Bayanin Rubutun Kyauta zuwa PDF ta amfani da Umarnin CURL
API ɗin REST don Bayanin PDF
Aspose.PDF Cloud yana ba da sauƙi-da-amfani da cikakkiyar bayani don ƙara bayanai zuwa takaddun PDF ta hanyar shiri. Tare da Aspose.PDF Cloud, zaku iya ƙara nau’ikan bayanai daban-daban zuwa takaddun PDF, gami da rubutu, hoto, tambari, da bayanan alamomi daban-daban. Hakanan zaka iya canza bayanan da ke akwai, kamar canza matsayi, girma, launi, ko duk wani kaddarorin.
Bayanan da aka goyan bayan sun haɗa da Rubutu, Da’irar, Polygon, PolyLine, Line, Square, FreeText, Highlight, Underline, Squiggly, StrikeOut, Caret, Ink, Link, Popup, FileAttachment, Sound, Movie, Screen, Widget, Watermark, TrapNet, PrinterMark, Redaction, Stamp, RichMedia da PDF3D.
Yanzu, don ƙara SDK a cikin aikinku, da fatan za a bincika ‘Aspose.PDF-Cloud’ a cikin manajan fakitin NuGet kuma danna maɓallin Ƙara Kunshin. Muhimmin mataki na gaba shine yin rijistar asusu akan dashboard na Cloud kuma ku sami takaddun shaidar abokin cinikin ku. Da fatan za a duba jagorar Quick Start don ƙarin cikakkun bayanai.
Ƙara sharhi zuwa PDF ta amfani da C#
Bari mu kalli snippet code C# NET wanda ake amfani da shi don ƙara Annotation zuwa takaddun PDF.
// Don cikakkun misalai da fayilolin bayanai, da fatan za a je zuwa
https://github.com/aspose-pdf-cloud/aspose-pdf-cloud-dotnet
// Samu bayanan abokin ciniki daga https://dashboard.aspose.cloud/
string clientSecret = "7f098199230fc5f2175d494d48f2077c";
string clientID = "ee170169-ca49-49a4-87b7-0e2ff815ea6e";
// ƙirƙirar wani abu na PdfApi
PdfApi api = new PdfApi(clientSecret, clientID);
// Ƙirƙiri abin Lissafi ya ƙunshi FreeTextAnnotations
List<FreeTextAnnotation> annotations = new List<FreeTextAnnotation>
{
new FreeTextAnnotation(
// saka yankin rectangular mai riƙe da FreeTextAnnotation
// kuma ayyana bayanan tsara rubutu
Rect: new Rectangle(100, 800, 350, 830),
TextStyle:new TextStyle(
FontSize: 26, Font: "Arial",
ForegroundColor: new Aspose.Pdf.Cloud.Sdk.Model.Color(0xFF, 0, 0xFF, 0),
BackgroundColor: new Aspose.Pdf.Cloud.Sdk.Model.Color(0xFF, 0xFF, 0, 0)
))
{
// Abubuwan da za a nuna a cikin FreeTextAnnotation
Contents = "Confidential !",
Color = new Aspose.Pdf.Cloud.Sdk.Model.Color(0, 0, 0, 0),
Id = "id1",
Name = "Test Free Text",
Flags = new List<AnnotationFlags> {AnnotationFlags.Default},
HorizontalAlignment = HorizontalAlignment.Center,
Intent = FreeTextIntent.FreeTextTypeWriter,
RichText = "Rich Text",
Subject = "Text Box Subj",
ZIndex = 1,
Justification = Justification.Center,
Title = "Title",
PageIndex = 1
}
};
var response = api. PostPageFreeTextAnnotations("Binder1.pdf", 1, annotations);
Yanzu, bari mu fahimci snippet code a cikin ƙarin cikakkun bayanai.
PdfApi api = new PdfApi(clientSecret, clientID);
Ƙirƙiri misali na ajin PdfApi wanda ke ɗaukar bayanan abokin ciniki azaman mahawara a cikin maginin sa.
List<FreeTextAnnotation> annotations = new List<FreeTextAnnotation>
Kamar yadda API ɗin ke goyan bayan damar ƙara ɗaya ko fiye da Bayani na nau’in nau’in iri ɗaya a lokaci guda, don haka muna buƙatar ƙirƙirar abun jeri na nau’inAnnotation na FreeText.
new FreeTextAnnotation(
Rect: new Rectangle(100, 800, 350, 830),
TextStyle:new TextStyle(
FontSize: 26, Font: "Arial",
ForegroundColor: new Aspose.Pdf.Cloud.Sdk.Model.Color(0xFF, 0, 0xFF, 0),
BackgroundColor: new Aspose.Pdf.Cloud.Sdk.Model.Color(0xFF, 0xFF, 0, 0)
))
Ƙirƙiri wani abu na FreeTextAnnotation inda muke ayyana yankin rectangular don Bayani da cikakkun bayanan tsara rubutu.
Contents = "Confidential !"
Anan mun ayyana abun ciki don FreeTextAnnotation.
var response = api. PostPageFreeTextAnnotations("Binder1.pdf", 1, annotations);
Kira API ɗin REST don ƙara FreeTextAnnotation a shafi na farko na takaddun PDF wanda aka rigaya ya samu a ma’ajiyar gajimare.
An ba da ƙasa akwai yuwuwar ƙimar da za a iya sanyawa ga kaddarorin da aka yi amfani da su a cikin snippet na sama.
- Ƙimar annotation - Ƙididdiga masu goyan baya na iya zama `[Tsoffin, Ganuwa, Boye, Buga, NoZoom, NoRotate, NoView, ReadOnly, Locked, ToggleNoView, LockedContents]’.
- Juyawa - kusurwar juyawa don rubutu. Ƙididdiga masu yiwuwa na iya zama `[Babu, on90, on180, on270]'.
- Tutocin annotation - Saitin tutoci masu ƙayyadaddun halaye daban-daban na bayanin. Ƙimar da za ta iya zama ‘[Tsoffin, Ganuwa, Boye, Buga, NoZoom, NoRotate, NoView, ReadOnly, Locked, ToggleNoView, LockedContents]’.
- FreeTextIntent - Yana ƙididdige manufar bayanin rubutun kyauta. Ƙididdiga masu yiwuwa na iya zama `[Ba a bayyana ba, FreeTextCallout, FreeTextTypeWriter]'.
Ƙara Bayanin Rubutun Kyauta zuwa PDF ta amfani da Umarnin CURL
Amfani da umarnin cURL don kiran Aspose.PDF Cloud API hanya ce mai kyau don cika wannan buƙatu. Hakanan yana da kyau idan kun saba da kayan aikin layin umarni ko fi son amfani da su. Don haka, tare da kayan aikin layin umarni na cURL, zaku iya yin buƙatun HTTP kuma kuyi ayyuka daban-daban dangane da sarrafa fayil ɗin PDF.
Yanzu, don ƙara bayanai zuwa takaddun PDF ta amfani da umarnin cURL, da farko muna buƙatar samar da alamar tabbatarwa ta hanyar aika buƙatu zuwa ƙarshen alamar tare da App SID da Maɓallin App. Da fatan za a aiwatar da umarni mai zuwa don samar da accessToken.
curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=ee170169-ca49-49a4-87b7-0e2ff815ea6e&client_secret=7f098199230fc5f2175d494d48f2077c" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"
Da zarar an samar da accessToken, da fatan za a aiwatar da umarni mai zuwa wanda ke ƙara FreeTextAnnotation zuwa takaddar PDF. Ana sabunta Fayil ɗin Fayil ɗin Fayil ɗin Fayil ɗin Bayani akan Ma’ajiyar Cloud.
curl -v "https://api.aspose.cloud/v3.0/pdf/{inputPDF}/pages/1/annotations/freetext" \
-X POST \
-H "accept: application/json" \
-H "authorization: Bearer {accessToken}" \
-H "Content-Type: application/json" \
-d "[ { \"Color\": { \"A\": 0, \"R\": 0, \"G\": 0, \"B\": 0 }, \"Contents\": \"Confidential !\", \"Modified\": \"01/05/2023 12:00:00.000 PM\", \"Id\": \"id0\", \"Flags\": [ \"Default\" ], \"Name\": \"comment\", \"Rect\": { \"LLX\": 100, \"LLY\": 800, \"URX\": 350, \"URY\": 830 }, \"PageIndex\": 0, \"ZIndex\": 1, \"HorizontalAlignment\": \"Center\", \"VerticalAlignment\": \"Center\", \"CreationDate\": \"03/05/2023 16:00:00.000 PM\", \"Subject\": \"Subj.\", \"Title\": \"Main Heading\", \"RichText\": \"Hello world...\", \"Justification\": \"Left\", \"Intent\": \"FreeTextTypeWriter\", \"Rotate\": \"None\", \"TextStyle\": { \"FontSize\": 26, \"Font\": \"Arial\", \"ForegroundColor\": { \"A\": 10, \"R\": 10, \"G\": 100, \"B\": 120 }, \"BackgroundColor\": { \"A\": 0, \"R\": 0, \"G\": 50, \"B\": 80 } } }]"
Sauya
{inputPDF}
tare da sunan shigar da fayil ɗin PDF da aka rigaya akwai akan ma’ajiyar Cloud, `{accessToken}’ tare da alamar samun damar JWT da aka samar a sama.
Ana iya sauke daftarin aiki na PDF da aka yi amfani da shi a cikin misalin da ke sama daga wannan hanyar haɗi.
Kammalawa
A ƙarshe, ƙara bayanai zuwa PDFs na iya haɓaka fa’ida da aikin su sosai. Ko kuna neman haskaka mahimman rubutu, ƙara sharhi, ko ɗaukar bayanin kula kai tsaye a cikin takaddar, to Aspose.PDF Cloud zaɓi ne mai ban mamaki don cimma wannan. Mun kuma koyi cewa Aspose.PDF Cloud SDK don NET da umarnin cURL suna ba da mafita mai ƙarfi don annotating PDFs, yana ba ku ikon ƙirƙirar ayyukan aiki na musamman da hanyoyin sarrafa kansa. Don haka, tare da waɗannan kayan aikin, zaku iya ƙara bayanai cikin sauri da sauƙi zuwa PDFs, yayin adana lokaci da haɓaka yawan aiki.
Hanyoyin haɗi masu amfani
- Reference
- Jagorar Mai Haɓakawa
- SDK Source Code
- [Zauren Tallafawa Kyauta 6
- Live Demos
Labarai masu alaka
Muna ba da shawarar yin amfani da shafukan yanar gizo masu zuwa: