GdViewer CopyRegionToGdPictureImage

Example requests & Code samples for GdPicture Toolkits.
Post Reply
schalla
Posts: 5
Joined: Tue Jan 14, 2020 5:11 pm

GdViewer CopyRegionToGdPictureImage

Post by schalla » Mon Jan 25, 2021 8:13 am

Hello,

I have a sample project but it says the file is too big to upload. So I am just pasting some sample code. We have a PDF and trying to make a snippet of that PDF. We are using CopyRegionToGdPictureImage(384, 552, 410, 377); All 4 of the parameters are valid and I have confirmed that.
How do I troubleshoot this?

Can you tell me why the newimage is always 0? if(newImage > 0)
{
MessageBox.Show("done");
}
What am I doing wrong?


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using GdPicture14;

namespace TestGDSnippet

Code: Select all

{
    public partial class Form1 : Form
    {
        public static class GdPictureSettings
        {
            #region Constants

            public const string SDKLicenseKey_V14 = ".....";

            #endregion
        }

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

            var image = File.ReadAllBytes(@"tewt.pdf");
            SetDocumentStream(image);
        }


        public void SetDocumentStream( byte[] i)
        {
            var licenseManager = new GdPicture14.LicenseManager();
            licenseManager.RegisterKEY(GdPictureSettings.SDKLicenseKey_V14);
            GdViewer GdViewer = new GdViewer();

            var GdPicturePDF = new GdPicturePDF();
            Stream stream = new MemoryStream(i);
            var DocumentStream = stream as MemoryStream;
           

           // DisplayFromDocumentStream();
            if (GdPicturePDF.LoadFromStream(DocumentStream) == GdPictureStatus.OK)
            {
                try
                {
                    GdPicturePDF.FlattenFormFields();
                }
                // ReSharper disable EmptyGeneralCatchClause
                catch (Exception) { } // Suppress error and continue
                // ReSharper restore EmptyGeneralCatchClause
                GdViewer.DisplayFromGdPicturePDF(GdPicturePDF);
            }

            GdViewer.DisplayPage(1);
            var newImage = GdViewer.CopyRegionToGdPictureImage(384, 552, 410, 377);
            if(newImage > 0)
            {
                MessageBox.Show("done");
            }
        }

    }
}

Hugo
Posts: 88
Joined: Tue Dec 18, 2018 10:09 am

Re: GdViewer CopyRegionToGdPictureImage

Post by Hugo » Mon Jan 25, 2021 5:52 pm

Schalla,

Thank you. As mentioned, since you contacted us via ticket, I will handle your issue there instead.

This issue is looking like it is due to:
1. Outdated version of GdPicture
or
2. GdViewer object setup

I will help you resolve this in your ticket as we can discuss what you are doing in your code sample together there.

Regards,
Hugo

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests