Skip to content

Commit

Permalink
playground_sample: Update the github sample.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sri-hari-haran-g committed Aug 26, 2024
1 parent 495506c commit 3c4b32a
Show file tree
Hide file tree
Showing 34 changed files with 42 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ static void Main(string[] args) {
//Draw the text.
graphics.DrawString("Hello World!!!", font, PdfBrushes.Black, new PointF(0, 0));
//Create a fileStream.
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.CreateNew, FileAccess.ReadWrite);
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite);
//Save and close the PDF document.
document.Save(fileStream);
document.Close(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
PdfDocument document = htmlConverter.Convert(urlToConvert);

//Create file stream.
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.CreateNew, FileAccess.ReadWrite);
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite);

//Save and close the PDF document
document.Save(fileStream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
PdfDocument document = htmlConverter.Convert("https://www.example.com");

//Create file stream.
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.CreateNew, FileAccess.ReadWrite);
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite);

//Save and close the PDF document
document.Save(fileStream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
//Convert URL to PDF.
PdfDocument document = htmlConverter.Convert("file:///D:/PDF-Examples/HTML%20to%20PDF/Blink/Accessible_PDF_In_HTML_to_PDF/.NET/Accessible%20PDF/Data/Input.html");
//Save and close the PDF document.
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.CreateNew, FileAccess.ReadWrite);
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite);
//Save and close the PDF document
document.Save(fileStream);
document.Close(true);
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
PdfDocument document = htmlConverter.Convert("https://www.google.com");

//Create file stream.
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.CreateNew, FileAccess.ReadWrite);
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite);

//Save and close the PDF document.
document.Save(fileStream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
PdfDocument document = htmlConverter.Convert(Path.GetFullPath(@"Data/Input.html"));

//Create file stream to save the PDF document.
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.CreateNew, FileAccess.ReadWrite);
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite);

//Save and close the PDF document
document.Save(fileStream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
PdfDocument document = htmlConverter.Convert("https://www.google.com");

//Create file stream.
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.CreateNew, FileAccess.ReadWrite);
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite);

//Save and close the PDF document.
document.Save(fileStream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
PdfDocument document = htmlConverter.Convert("https://www.example.com");

//Create file stream.
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.CreateNew, FileAccess.ReadWrite);
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite);

//Save and close the PDF document
document.Save(fileStream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
PdfDocument document = htmlConverter.ConvertPartialHtml(Path.GetFullPath(@"Data/Input.html"), "picture");

//Create file stream.
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.CreateNew, FileAccess.ReadWrite);
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite);

//Save and close the PDF document
document.Save(fileStream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
PdfDocument document = htmlConverter.Convert(htmlText, baseUrl);

//Create the file stream.
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.CreateNew, FileAccess.ReadWrite);
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite);

//Save and close the PDF document
document.Save(fileStream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
PdfDocument document = htmlConverter.Convert("https://httpbin.org/headers");

//Create file stream.
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.CreateNew, FileAccess.ReadWrite);
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite);

//Save and close the PDF document.
document.Save(fileStream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
PdfDocument document = htmlConverter.Convert("https://www.google.com");

//Create file stream for PDF document.
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.CreateNew, FileAccess.ReadWrite);
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite);

//Save and close the PDF document
document.Save(fileStream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
PdfDocument document = htmlConverter.Convert("https://www.example.com");

//Create file stream.
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.CreateNew, FileAccess.ReadWrite);
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite);

//Save and close the PDF document
document.Save(fileStream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
PdfDocument document = htmlConverter.Convert(Path.GetFullPath(@"Data/Input.html"));

//Create file stream to save the PDF document.
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.CreateNew, FileAccess.ReadWrite);
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite);

//Save and close the PDF document.
document.Save(fileStream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
PdfDocument document = htmlConverter.Convert(Path.GetFullPath(@"Data/Input.html"));

//Create file stream to save the PDF document.
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.CreateNew, FileAccess.ReadWrite);
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite);

//Save and close the PDF document
document.Save(fileStream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
PdfDocument document = htmlConverter.Convert(Path.GetFullPath(@"Data/Input.html"));

//Create file stream.
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.CreateNew, FileAccess.ReadWrite);
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite);

//Save and close the PDF document.
document.Save(fileStream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
PdfDocument document = htmlConverter.Convert("https://www.google.com");

//Create file stream.
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.CreateNew, FileAccess.ReadWrite);
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite);
//Save and close the PDF document.
document.Save(fileStream);
document.Close(true);
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com");

//Create a filestream.
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.CreateNew, FileAccess.ReadWrite);
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite);
//Save and close the PDF document.
document.Save(fileStream);
document.Close(true);
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
PdfDocument document = htmlConverter.Convert("https://www.google.com");

//Create file stream.
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.CreateNew, FileAccess.ReadWrite);
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite);

//Save and close the PDF document.
document.Save(fileStream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
PdfDocument document = htmlConverter.Convert("https://www.google.com");

//Create file stream.
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.CreateNew, FileAccess.ReadWrite);
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite);

//Save and Close the PDF document.
document.Save(fileStream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
PdfDocument document = htmlConverter.Convert("https://www.google.com");

//Create file stream.
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.CreateNew, FileAccess.ReadWrite);
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite);

//Save and close the PDF document
document.Save(fileStream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
PdfDocument document = htmlConverter.Convert(Path.GetFullPath(@"Data/Input.html"));

//Create file stream.
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.CreateNew, FileAccess.ReadWrite);
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite);

//Save and close the PDF document
document.Save(fileStream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com");

//Create file stream to save the PDF document.
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.CreateNew, FileAccess.ReadWrite);
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite);
//Save and close the PDF document.
document.Save(fileStream);
document.Close(true);
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
//Convert URL to PDF
PdfDocument document = htmlConverter.Convert("https://www.google.com");
//Create a file stream.
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.CreateNew, FileAccess.ReadWrite);
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite);
//Save and close the PDF document.
document.Save(fileStream);
//Close the document.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
<None Update="Data\Input.pdf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Output\.gitkeep">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// See https://aka.ms/new-console-template for more information

using Syncfusion.Drawing;
using Syncfusion.Pdf;
using Syncfusion.Pdf.Exporting;
using Syncfusion.Pdf.Parsing;
Expand All @@ -16,5 +17,12 @@
//Extracts all the images info from first page.
PdfImageInfo[] imagesInfo = pageBase.GetImagesInfo();

//Get each image and save to the separate file.
for (int i = 0; i < imagesInfo.Length; i++)
{
Stream image = imagesInfo[i].ImageStream;
File.WriteAllBytes(Path.GetFullPath(@"Output/" + i.ToString() + ".jpg"), (image as MemoryStream).ToArray());
}

//Close the document.
loadedDocument.Close(true);
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static void Main(string[] args)
string text = processor.PerformOCR(lDoc);

//Create file stream.
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.CreateNew);
FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite);

//Save the document into stream.
lDoc.Save(fileStream);
Expand Down
2 changes: 1 addition & 1 deletion OCR/.NET/Perform-OCR-AWS-Textract/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ using (OCRProcessor processor = new OCRProcessor())
//Perform OCR with input document.
string text = processor.PerformOCR(lDoc);
//Create file stream.
FileStream fileStream = new FileStream("Output.pdf", FileMode.CreateNew);
FileStream fileStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite);
//Save the document into stream.
lDoc.Save(fileStream);
//Close the document.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static void Main(string[] args)
processor.PerformOCR(lDoc);

//Create file stream.
FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.CreateNew);
FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite);

//Save the document into stream.
lDoc.Save(outputStream);
Expand Down
2 changes: 1 addition & 1 deletion OCR/.NET/Perform-OCR-Azure-Vision/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ using (OCRProcessor processor = new OCRProcessor())
processor.PerformOCR(lDoc);

//Create file stream.
FileStream outputStream = new FileStream("../../../OCR.pdf", FileMode.CreateNew);
FileStream outputStream = new FileStream("../../../OCR.pdf", FileMode.Create);

//Save the document into stream.
lDoc.Save(outputStream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static void Main(string[] args)
void LoadDocument_DocumentSplitEvent(object sender, PdfDocumentSplitEventArgs args)
{
//Save the resulting document.
FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/" + Guid.NewGuid().ToString() + ".pdf"), FileMode.CreateNew);
FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/" + Guid.NewGuid().ToString() + ".pdf"), FileMode.Create, FileAccess.ReadWrite);
args.PdfDocumentData.CopyTo(outputStream);
outputStream.Close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static void Main(string[] args)
void LoadDocument_DocumentSplitEvent(object sender, PdfDocumentSplitEventArgs args)
{
//Save the resulting document.
FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/" + Guid.NewGuid().ToString() + ".pdf"), FileMode.CreateNew);
FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/" + Guid.NewGuid().ToString() + ".pdf"), FileMode.Create, FileAccess.ReadWrite);
args.PdfDocumentData.CopyTo(outputStream);
outputStream.Close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
// Import the pages to the new PDF document
document.ImportPageRange(loadedDocument, bookmark.Destination.PageIndex, endIndex);
//Save the document as stream
using (FileStream stream = new FileStream(Path.GetFullPath(@"Output/" + bookmark.Title +".pdf"),FileMode.CreateNew,FileAccess.Write))
using (FileStream stream = new FileStream(Path.GetFullPath(@"Output/" + bookmark.Title +".pdf"),FileMode.Create,FileAccess.Write))
{
document.Save(stream);
}
Expand Down

0 comments on commit 3c4b32a

Please sign in to comment.