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");
}
}
}
}