Skip to content

Commit dece84b

Browse files
committed
986455-1: modified 37 files.
1 parent 84a83d0 commit dece84b

37 files changed

Lines changed: 463 additions & 765 deletions

File tree

  • Images
    • Add-a-mask-to-TIFF-image/.NET/Add-a-mask-to-TIFF-image
    • Add-transparancy-and-rotation-to-the-image/.NET/Add-transparancy-and-rotation-to-the-image
    • Convert_Image_to_PDF/.NET/Convert_Image_to_PDF
    • Converting-multi-page-TIFF-to-PDF/.NET/Converting-multi-page-TIFF-to-PDF
    • Insert-image-in-a-new-PDF-document/.NET/Insert-image-in-a-new-PDF-document
    • Insert-image-in-an-existing-PDF-document/.NET/Insert-image-in-an-existing-PDF-document
    • Paginate-an-image-in-PDF-document/.NET/Paginate-an-image-in-PDF-document
    • Remove-images-from-PDF-document/.NET/Remove-images-from-PDF-document
  • JavaScript
    • Add-JavaScript-action-to-the-form-fields-in-a-PDF/.NET/Add-JavaScript-action-to-the-form-fields-in-a-PDF
    • Add-JavaScript-to-3D-annotation-in-a-PDF-document/.NET/Add-JavaScript-to-3D-annotation-in-a-PDF-document
    • Add-the-JavaScript-action-to-the-PDF-document/.NET/Add-the-JavaScript-action-to-the-PDF-document
  • Layer
    • Add-a-lock-state-to-the-layer-in-a-new-PDF-document/.NET/Add-a-lock-state-to-the-layer-in-a-new-PDF-document
    • Add-annotation-to-the-layer-in-an-existing-PDF-document/.NET/Add-annotation-to-the-layer-in-an-existing-PDF-document
    • Add-nested-layers-in-the-PDF-document/.NET/Add-nested-layers-in-the-PDF-document
    • Add-the-multiple-layers-in-an-existing-PDF-document/.NET/Add-the-multiple-layers-in-an-existing-PDF-document
    • Adding-annotation-to-layer-in-the-PDF-document/.NET/Adding-annotation-to-layer-in-the-PDF-document
    • Adding-layers-in-a-PDF-document/.NET/Adding-layers-in-a-PDF-document
    • Flattening-the-layers-in-an-existing-PDF-document/.NET/Flattening-the-layers-in-an-existing-PDF-document
    • Removing-layers-from-an-existing-PDF-document/.NET/Removing-layers-from-an-existing-PDF-document
    • Toggle-the-visibility-of-layers-in-an-existing-PDF/.NET/Toggle-the-visibility-of-layers-in-an-existing-PDF
    • Toggle-the-visibility-of-layers-in-new-PDF-document/.NET/Toggle-the-visibility-of-layers-in-new-PDF-document
  • Merge PDFs
    • Add_bookmarks_to_merge_PDF_document_NET/.NET/Add_bookmarks_to_merge_PDF_document_NET
    • Combine_and_digitally_sign_the_PDF_files/.NET/Combine_and_digitally_sign_the_PDF_files
    • Convert_landscape_to_portrait_and_merge_PDF_files/.NET/Convert_landscape_to_portrait_and_merge_PDF_files
    • Crop_PDF_pages_and_merge_NET/.NET/Crop_PDF_pages_and_merge_NET
    • Extend-the-margin-of-PDF-pages-while-merging-PDFs/.NET/Extend-the-margin-of-PDF-pages-while-merging-PDFs
    • Import-multiple-pages-from-an-existing-PDF/.NET/Import-multiple-pages-from-an-existing-PDF
    • Import-pages-from-multiple-documents-and-arrange-pages/.NET/Import-pages-from-multiple-documents-and-arrange-pages
    • Importing-pages-from-one-document-another-document/.NET/Importing-pages-from-one-document-another-document
    • Merge-PDF-without-compromising-accessibility-tags/.NET/Merge-PDF-without-compromising-accessibility-tags
    • Merge-multiple-documents-from-stream/.NET/Merge-multiple-documents-from-stream
    • Merge-specific-range-of-pages-from-different-PDF/.NET/Merge-specific-range-of-pages-from-different-PDF
    • Merge_PDF_files_and_fill_form_fields_NET/.NET/Merge_PDF_files_and_fill_form_fields_NET
    • Merge_password_protected_PDF_files_NET/.NET/Merge_password_protected_PDF_files_NET
    • Optimize-the-PDF-resources-when-merging-PDF-documents/.NET/Optimize-the-PDF-resources-when-merging-PDF-documents
    • Reduce-size-of-PDF-file-while-importing-pages/.NET/Reduce-size-of-PDF-file-while-importing-pages
    • Rotate_pages_and_merge_PDF_files_NET/.NET/Rotate_pages_and_merge_PDF_files_NET
Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,34 @@
1-
// See https://aka.ms/new-console-template for more information
2-
3-
using Syncfusion.Pdf;
1+
using Syncfusion.Pdf;
42
using Syncfusion.Pdf.Graphics;
53

6-
//Create a PDF document.
7-
PdfDocument document = new PdfDocument();
8-
9-
//Add pages to the document.
10-
PdfPage page = document.Pages.Add();
4+
//Create a new PDF document.
5+
using (PdfDocument document = new PdfDocument())
6+
{
7+
//Add pages to the document.
8+
PdfPage page = document.Pages.Add();
119

12-
//Create PDF graphics for the page.
13-
PdfGraphics graphics = page.Graphics;
10+
//Create PDF graphics for the page.
11+
PdfGraphics graphics = page.Graphics;
1412

15-
//Get stream from the existing TIF file.
16-
FileStream imageStream = new FileStream(Path.GetFullPath(@"Data/image.tif"), FileMode.Open, FileAccess.Read);
13+
//Get stream from the existing TIF file.
14+
FileStream imageStream = new FileStream(Path.GetFullPath(@"Data/image.tif"), FileMode.Open, FileAccess.Read);
1715

18-
//Load the image from stream.
19-
PdfTiffImage image = new PdfTiffImage(imageStream);
16+
//Load the image from stream.
17+
PdfTiffImage image = new PdfTiffImage(imageStream);
2018

21-
//Get stream from the image file.
22-
FileStream maskStream = new FileStream(Path.GetFullPath(@"Data/mask2.bmp"), FileMode.Open, FileAccess.Read);
19+
//Get stream from the image file.
20+
FileStream maskStream = new FileStream(Path.GetFullPath(@"Data/mask2.bmp"), FileMode.Open, FileAccess.Read);
2321

24-
//Load the image mask file from stream.
25-
PdfImageMask mask = new PdfImageMask(new PdfTiffImage(maskStream));
22+
//Load the image mask file from stream.
23+
PdfImageMask mask = new PdfImageMask(new PdfTiffImage(maskStream));
2624

27-
//Assign the masking image to TIF image.
28-
image.Mask = mask;
25+
//Assign the masking image to TIF image.
26+
image.Mask = mask;
2927

30-
//Draw the image.
31-
graphics.DrawImage(image, 0, 0);
28+
//Draw the image.
29+
graphics.DrawImage(image, 0, 0);
3230

33-
//Create file stream.
34-
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite))
35-
{
36-
//Save the PDF document to file stream
37-
document.Save(outputFileStream);
31+
//Save the PDF document
32+
document.Save(Path.GetFullPath(@"Output/Output.pdf"));
3833
}
3934

40-
//Close the document
41-
document.Close(true);
42-
Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,37 @@
1-
// See https://aka.ms/new-console-template for more information
2-
3-
using Syncfusion.Pdf;
1+
using Syncfusion.Pdf;
42
using Syncfusion.Pdf.Graphics;
53

6-
//Create Document.
7-
PdfDocument document = new PdfDocument();
8-
9-
//Add a new page.
10-
PdfPage page = document.Pages.Add();
4+
//Create a new PDF document.
5+
using (PdfDocument document = new PdfDocument())
6+
{
7+
//Add a new page.
8+
PdfPage page = document.Pages.Add();
119

12-
//Load a image as stream.
13-
FileStream imageStream = new FileStream(Path.GetFullPath(@"Data/logo.png"), FileMode.Open, FileAccess.Read);
10+
//Load a image as stream.
11+
FileStream imageStream = new FileStream(Path.GetFullPath(@"Data/logo.png"), FileMode.Open, FileAccess.Read);
1412

15-
//Load a bitmap.
16-
PdfBitmap image = new PdfBitmap(imageStream);
13+
//Load a bitmap.
14+
PdfBitmap image = new PdfBitmap(imageStream);
1715

18-
//Save the current graphics state.
19-
PdfGraphicsState state = page.Graphics.Save();
16+
//Save the current graphics state.
17+
PdfGraphicsState state = page.Graphics.Save();
2018

21-
//Translate the coordinate system to the required position.
22-
page.Graphics.TranslateTransform(20, 100);
19+
//Translate the coordinate system to the required position.
20+
page.Graphics.TranslateTransform(20, 100);
2321

24-
//Apply transparency.
25-
page.Graphics.SetTransparency(0.5f);
22+
//Apply transparency.
23+
page.Graphics.SetTransparency(0.5f);
2624

27-
//Rotate the coordinate system.
28-
page.Graphics.RotateTransform(-45);
25+
//Rotate the coordinate system.
26+
page.Graphics.RotateTransform(-45);
2927

30-
//Draw image.
31-
image.Draw(page, 0, 100);
28+
//Draw image.
29+
image.Draw(page, 0, 100);
3230

33-
//Restore the graphics state.
34-
page.Graphics.Restore(state);
31+
//Restore the graphics state.
32+
page.Graphics.Restore(state);
3533

36-
//Create file stream.
37-
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite))
38-
{
39-
//Save the PDF document to file stream
40-
document.Save(outputFileStream);
34+
//Save the PDF document
35+
document.Save(Path.GetFullPath(@"Output/Output.pdf"));
4136
}
4237

43-
//Close the document
44-
document.Close(true);
45-

Images/Convert_Image_to_PDF/.NET/Convert_Image_to_PDF/Program.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,9 @@
1515
// Convert the image to a PDF document using the ImageToPdfConverter
1616
PdfDocument pdfDocument = imageToPdfConverter.Convert(imageStream);
1717

18-
//Create file stream.
19-
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite))
20-
{
21-
//Save the PDF document to file stream.
22-
pdfDocument.Save(outputFileStream);
23-
}
24-
18+
//Save the PDF document to file stream.
19+
pdfDocument.Save(Path.GetFullPath(@"Output/Output.pdf"));
20+
2521
// Close the document
2622
pdfDocument.Close(true);
2723
}
Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,34 @@
1-
// See https://aka.ms/new-console-template for more information
2-
3-
using Syncfusion.Pdf;
1+
using Syncfusion.Pdf;
42
using Syncfusion.Pdf.Graphics;
53

64
//Create a new PDF document.
7-
PdfDocument document = new PdfDocument();
5+
using (PdfDocument document = new PdfDocument())
6+
{
7+
//Set page margins.
8+
document.PageSettings.Margins.All = 0;
89

9-
//Set page margins.
10-
document.PageSettings.Margins.All = 0;
10+
//Load the multi frame TIFF image from the disk.
11+
FileStream imageStream = new FileStream(Path.GetFullPath(@"Data/image.tiff"), FileMode.Open, FileAccess.Read);
12+
PdfTiffImage tiffImage = new PdfTiffImage(imageStream);
1113

12-
//Load the multi frame TIFF image from the disk.
13-
FileStream imageStream = new FileStream(Path.GetFullPath(@"Data/image.tiff"), FileMode.Open, FileAccess.Read);
14-
PdfTiffImage tiffImage = new PdfTiffImage(imageStream);
14+
//Get the frame count.
15+
int frameCount = tiffImage.FrameCount;
1516

16-
//Get the frame count.
17-
int frameCount = tiffImage.FrameCount;
17+
//Access each frame and draw into the page.
18+
for (int i = 0; i < frameCount; i++)
19+
{
20+
//Add new page to PDF document.
21+
PdfPage page = document.Pages.Add();
1822

19-
//Access each frame and draw into the page.
20-
for (int i = 0; i < frameCount; i++)
21-
{
22-
//Add new page to PDF document.
23-
PdfPage page = document.Pages.Add();
23+
//Create graphics for PDF page
24+
PdfGraphics graphics = page.Graphics;
2425

25-
//Create graphics for PDF page
26-
PdfGraphics graphics = page.Graphics;
26+
tiffImage.ActiveFrame = i;
2727

28-
tiffImage.ActiveFrame = i;
28+
//Draw the image.
29+
graphics.DrawImage(tiffImage, 0, 0, page.GetClientSize().Width, page.GetClientSize().Height);
30+
}
2931

30-
//Draw the image.
31-
graphics.DrawImage(tiffImage, 0, 0, page.GetClientSize().Width, page.GetClientSize().Height);
32+
//Save the PDF document
33+
document.Save(Path.GetFullPath(@"Output/Output.pdf"));
3234
}
33-
34-
//Create file stream.
35-
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite))
36-
{
37-
//Save the PDF document to file stream
38-
document.Save(outputFileStream);
39-
}
40-
41-
//Close the document
42-
document.Close(true);
Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,24 @@
1-
// See https://aka.ms/new-console-template for more information
2-
3-
using Syncfusion.Pdf;
1+
using Syncfusion.Pdf;
42
using Syncfusion.Pdf.Graphics;
53

64
//Create a new PDF document.
7-
PdfDocument document = new PdfDocument();
8-
9-
//Add a page to the document.
10-
PdfPage page = document.Pages.Add();
11-
12-
//Create PDF graphics for the page.
13-
PdfGraphics graphics = page.Graphics;
5+
using (PdfDocument document = new PdfDocument())
6+
{
7+
//Add a page to the document.
8+
PdfPage page = document.Pages.Add();
149

15-
//Get stream from the existing image file.
16-
FileStream imageStream = new FileStream(Path.GetFullPath(@"Data/Autumn Leaves.jpg"), FileMode.Open, FileAccess.Read);
10+
//Create PDF graphics for the page.
11+
PdfGraphics graphics = page.Graphics;
1712

18-
//Load the image file.
19-
PdfBitmap image = new PdfBitmap(imageStream);
13+
//Get stream from the existing image file.
14+
FileStream imageStream = new FileStream(Path.GetFullPath(@"Data/Autumn Leaves.jpg"), FileMode.Open, FileAccess.Read);
2015

21-
//Draw the image.
22-
graphics.DrawImage(image, 0, 0);
16+
//Load the image file.
17+
PdfBitmap image = new PdfBitmap(imageStream);
2318

24-
//Create file stream.
25-
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite))
26-
{
27-
//Save the PDF document to file stream.
28-
document.Save(outputFileStream);
29-
}
19+
//Draw the image.
20+
graphics.DrawImage(image, 0, 0);
3021

31-
//Close the document.
32-
document.Close(true);
22+
//Save the PDF document
23+
document.Save(Path.GetFullPath(@"Output/Output.pdf"));
24+
}
Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,26 @@
1-
// See https://aka.ms/new-console-template for more information
2-
3-
using Syncfusion.Pdf;
1+
using Syncfusion.Pdf;
42
using Syncfusion.Pdf.Graphics;
53
using Syncfusion.Pdf.Parsing;
64

7-
//Get stream from an existing PDF document.
8-
FileStream docStream = new FileStream(Path.GetFullPath(@"Data/Input.pdf"), FileMode.Open, FileAccess.Read);
9-
105
//Load the PDF document.
11-
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream);
12-
13-
//Get first page from document.
14-
PdfLoadedPage loadedPage = loadedDocument.Pages[0] as PdfLoadedPage;
6+
using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(Path.GetFullPath(@"Data/Input.pdf")))
7+
{
8+
//Get first page from document.
9+
PdfLoadedPage loadedPage = loadedDocument.Pages[0] as PdfLoadedPage;
1510

16-
//Create PDF graphics for the page.
17-
PdfGraphics graphics = loadedPage.Graphics;
11+
//Create PDF graphics for the page.
12+
PdfGraphics graphics = loadedPage.Graphics;
1813

19-
//Get stream from the existing image file.
20-
FileStream imageStream = new FileStream(Path.GetFullPath(@"Data/Autumn Leaves.jpg"), FileMode.Open, FileAccess.Read);
14+
//Get stream from the existing image file.
15+
FileStream imageStream = new FileStream(Path.GetFullPath(@"Data/Autumn Leaves.jpg"), FileMode.Open, FileAccess.Read);
2116

22-
//Load the image from the disk.
23-
PdfBitmap image = new PdfBitmap(imageStream);
17+
//Load the image from the disk.
18+
PdfBitmap image = new PdfBitmap(imageStream);
2419

25-
//Draw the image.
26-
graphics.DrawImage(image, 0, 0);
20+
//Draw the image.
21+
graphics.DrawImage(image, 0, 0);
2722

28-
//Create file stream.
29-
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite))
30-
{
31-
//Save the PDF document to file stream.
32-
loadedDocument.Save(outputFileStream);
23+
//Save the PDF document
24+
loadedDocument.Save(Path.GetFullPath(@"Output/Output.pdf"));
3325
}
3426

35-
//Close the document.
36-
loadedDocument.Close(true);
37-
Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,25 @@
1-
// See https://aka.ms/new-console-template for more information
2-
3-
using Syncfusion.Pdf;
1+
using Syncfusion.Pdf;
42
using Syncfusion.Pdf.Graphics;
53

6-
//Create Document.
7-
PdfDocument document = new PdfDocument();
8-
9-
//Add new page.
10-
PdfPage page = document.Pages.Add();
4+
//Create a new PDF document.
5+
using (PdfDocument document = new PdfDocument())
6+
{
7+
//Add new page.
8+
PdfPage page = document.Pages.Add();
119

12-
//Load a bitmap.
13-
FileStream imageStream = new FileStream(Path.GetFullPath(@"Data/Autumn Leaves.jpg"), FileMode.Open, FileAccess.Read);
14-
PdfBitmap image = new PdfBitmap(imageStream);
10+
//Load a bitmap.
11+
FileStream imageStream = new FileStream(Path.GetFullPath(@"Data/Autumn Leaves.jpg"), FileMode.Open, FileAccess.Read);
12+
PdfBitmap image = new PdfBitmap(imageStream);
1513

16-
//Set layout property to make the element break across the pages.
17-
PdfLayoutFormat format = new PdfLayoutFormat();
18-
format.Break = PdfLayoutBreakType.FitPage;
19-
format.Layout = PdfLayoutType.Paginate;
14+
//Set layout property to make the element break across the pages.
15+
PdfLayoutFormat format = new PdfLayoutFormat();
16+
format.Break = PdfLayoutBreakType.FitPage;
17+
format.Layout = PdfLayoutType.Paginate;
2018

21-
//Draw image.
22-
image.Draw(page, 20, 400, format);
19+
//Draw image.
20+
image.Draw(page, 20, 400, format);
2321

24-
//Create file stream.
25-
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite))
26-
{
27-
//Save the PDF document to file stream
28-
document.Save(outputFileStream);
22+
//Save the PDF document
23+
document.Save(Path.GetFullPath(@"Output/Output.pdf"));
2924
}
3025

31-
//Close the document
32-
document.Close(true);
33-

0 commit comments

Comments
 (0)