Posted by: jbolduc on 8 June 2020, 7:39 am EST

  • Posted 8 June 2020, 7:39 am EST


    Beside setting the GcPdfDocument.CompressionLevel property, is there anything we can do to reduce the overall weigth of a pdf ?

    We start with a template pdf which is only 1.5mb, and after adding some dynamic content the final document reaches 10mb and we can't really explain why.
  • Replied 8 June 2020, 7:32 pm EST

    Hi Jonathan,

    To further investigate this, we need a stripped-down sample of your application replicating the issue so that we can get the cause of the issue.
    Please mention your Environment details and the build version of the assemblies that you are using.

    Note: If your file and sample are confidential then you can share it with us on our private portal SupportOne.

    Prabhat Sharma.
  • Replied 9 June 2020, 1:25 am EST

    We discovered that it has to do with an extension method we added to be able to copy a section of a document into another document.

    Each time we use the fonction to copy a zone, the entire source page size is added to the destination document instead of only the copied zone. Do you see something wrong with the code ?

    		public static void CopyZoneTo(
    this GcPdfDocument sourceDoc,
    GcPdfDocument destinationDoc,
    int destinationDocPageIndex,
    float sourceX,
    float sourceY,
    float sourceWidth,
    float sourceHeight,
    int sourceDocPageIndex,
    float destinationXOffset = 0,
    float destinationYOffset = 0,
    float pageHeight = 792)
    if (sourceDoc == null) throw new ArgumentNullException(nameof(sourceDoc));
    if (destinationDoc == null) throw new ArgumentNullException(nameof(destinationDoc));

    var sourceObject = new FormXObject(destinationDoc, sourceDoc.Pages[sourceDocPageIndex])
    Bounds = new RectangleF(sourceX, pageHeight - (sourceHeight + sourceY), sourceWidth, sourceHeight)

    new RectangleF(destinationXOffset, pageHeight - sourceObject.Bounds.Height + destinationYOffset, sourceObject.Bounds.Width, sourceObject.Bounds.Height),
  • Marked as Answer

    Replied 9 June 2020, 6:03 pm EST

    Hi Jonathan,

    By looking at the code snippet it seems to work fine. So to further investigate this we need a small sample to replicate the same issue at our end. It will help us to assist you accordingly and solve the issue that you are facing.

    Prabhat Sharma.
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels