none
PDF resize generated using rdlc and itextsharp RRS feed

  • Question

  • I have generated pdf's using rdlc and then combine multiple pdf files to single document using itextsharp pdfsmartcopy class. But my pdf size is large, i want to reduce the size of pdf. I have tried compression using itextsharp but that's unable to compress. When i upload the pdf to ilivepdf.com online for compression then it compress 21MB file to 1MB.
    • Moved by CoolDadTx Monday, April 8, 2019 1:59 PM Third party product
    Monday, April 8, 2019 6:00 AM

All replies

  • Hi

    Thank you for posting here.

    For your question, you want to reduce the size of pdf.

    You could try to use spire.pdf to do it, it will reduce the quality of images in pdf.

    Code:

    static void Main(string[] args)
            {
                PdfDocument doc = new PdfDocument(@"D:\test.pdf");
         
                doc.FileInfo.IncrementalUpdate = false;
    
                foreach (PdfPageBase page in doc.Pages)
                {
                    if (page != null)
                    {
                        if (page.ImagesInfo != null)
                        {
                            foreach (PdfImageInfo info in page.ImagesInfo)
                            {
                               
                                page.TryCompressImage(info.Index);
                            }
                        }
                    }
                }
       
                doc.SaveToFile("D:\\Output.pdf");
            }

    Result:

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, April 8, 2019 8:34 AM
  • This isn't really a C# question. Your questions is how to get a third party product like iTextSharp to generate more compressed PDFs. For questions related to third party products please post in their forums. They support some options to compress PDFs and they also have certain rules around how you have to fill PDFs so they do compress. Asking this question in their forums will help them give you a more focused answer.

    Michael Taylor http://www.michaeltaylorp3.net

    Monday, April 8, 2019 1:59 PM