)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to shrink the content of existing PDF document

Platform: WinForms |
Control: PDF |
Published Date: January 28, 2016 |
Last Revised Date: January 24, 2020
Tags: pdf, pdftemplate

The content can be shrunk from the existing PDF document into the new PDF document using the PdfTemplate class. Refer the code snippet and sample below for the same.

// Create a new instance of PdfDocument class.
PdfLoadedDocument document = new PdfLoadedDocument("../../Data/sample.pdf");
 
PdfTemplate template = document.Pages[0].CreateTemplate();
 
//Newly created document
PdfDocument doc = new PdfDocument();
PdfPage page = doc.Pages.Add();
 
// Create Pdf graphics for the page.
PdfGraphics g = page.Graphics;
 
// Create a solid brush
PdfBrush brush = new PdfSolidBrush(Color.Black);
 
// Set the font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 20f);
 
// Draw the text.
g.DrawString("Hello world!", font, brush, new PointF(20, 20));
 
// Draw the PDF template with reduced size
g.DrawPdfTemplate(template, new PointF(0, 40), new SizeF(500, 500));
 
// Save and close the document.
doc.Save("Sample.pdf");
doc.Close(true);
document.Close(true);

 

Sample link:

http://www.syncfusion.com/downloads/support/directtrac/general/ze/ShrinkContent-1573558921903587331

 

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon