I am extracting images from pdf in c#.
Someone has suggested that use Aspose namespace which is a third party namespace.
I have downloaded the aspose and included in my project as a reference.But the problem is i am not able to find the class PdfExtractor which is used to extract images.
I am sharing the link in which some one has suggested to use aspose and also sharing my code.
This is a link
and my code in which i just include aspose
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Aspose;
using Aspose.Pdf;
using Aspose.Pdf.Devices;
using Aspose.Pdf.DOM;
using Aspose.Pdf.Generator;
using Aspose.Pdf.InteractiveFeatures;
using Aspose.Pdf.Structure;
using Aspose.Pdf.Text;
namespace Imageget
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
And The class which is suggested in the link is PdfExtractor i am also sharing its code below so one can not waste his time to go to link.
PdfExtractor objExtractor = new PdfExtractor();
//bind input pdf file
objExtractor.BindPdf("input.pdf");
//extract image with specific mode
objExtractor.ExtractImage(ExtractImageMode.Default);
//check if images extracted and save them one by one
while (objExtractor.HasNextImage()) {
objExtractor.GetNextImage(DateTime.Now.Ticks.ToString() + ".jpg");
}
A first sight at google told me that you might need to add namespace:
Aspose.Pdf.Facades
Check out here and see the tree at the left.
and don;t forget to look at my comment at the top, it always help to find the namespace of class if i am unable to find it.
hope it helps!
Related
Very basic knowledge on c# and is the first i use anything p/invoke related.
Help me pls, i have made this code but it doesnt seem to work.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
[DllImport("C:\\Users\\lchris\\Desktop\\SevenZipLib_9.13.2\\SevenZipLib\\SevenZipLib\\7z86.dll")]
public static extern void SevenZipArchive(string c);
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
using (SevenZipArchive archive = new SevenZipArchive("file.rar"))
{
foreach (ArchiveEntry entry in archive)
{
Console.WriteLine(entry.FileName);
}
}
}
}
}
It tells me that SevenZipArchive is a 'Method' and is being used like a 'type'.
I have include the library to my project already, i just dont know how to use it.
Here is the library:
https://sevenziplib.codeplex.com/
You first need to remove this code:
[DllImport("...")]
public static extern void SevenZipArchive(string c);
You do not need to provide any p/invoke declarations. The library wraps that up for you.
This is a .net assembly. You use it just as you use any other. Take the following steps:
Download the project. You already did that I think.
Build the solution. Make sure that
In your project, add a reference to the assembly that you built in the previous stage. It's SevenZipLib\bin\Debug\SevenZipLib.dll or SevenZipLib\bin\Release\SevenZipLib.dll depending on the target you selected.
Add using SevenZipLib; to your project code to to gain access to the namespace.
Once you've done that your code will work. You can use the tests project that is supplied as part of the download as a rich source of example code.
Once again i need your help.. Anywho.. I've managed to get this code below to "work". the part there doesn't work is "this". I've no idea of what to use in static and how it works. I'm rather new to this aswell, so i might need some explenation for dummies.
Anyway. This code below is suppossed to be my "mainform", where everything is loaded like icons, size, settings, menu and whatever not.
Currently i'm trying to add a global "settings". which can be loaded from all the forms. So each invidual forms would be this.ClientSize = new System.Drawing.Size(1440, 900); and anything else i may add would have same impact on the form. like icons, opacity, whatever not.
Overally it's just a place to store settings there can be accessed from any other forms.
What i've written below here, is what i've managed so far. The SettingsOnProgramStart is recognised in my Settings form, but it does not change the Clientsize or the icon. It's pobably because of the "this" as it shows red lines.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace lala.events
{
public partial class TrayMenu : Form
{
public TrayMenu()
{
InitializeComponent();
SettingsOnProgramStart();
}
}
public static void SettingsOnProgramStart()
{
//
// Load global settings.
//
this.Icon = new Icon("images/skin/global/icon.ico");
this.ClientSize = new System.Drawing.Size(1440, 900);
}
}
}
Settings file :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace lala.events
{
public partial class Settings : Form
{
public Settings()
{
InitializeComponent();
TrayMenu.SettingsOnProgramStart();
}
}
}
Thank you for your time and sorry for any problems this may have caused :/
I'd love if anyone could give me a useful link to a "configuration for dummies", where i'd learn about using cfg, ini for my project. so i can get the invidual settings loaded from a file.
You need to pass the form whose settings need to be set in:
public static void SettingsOnProgramStart(Form formToSet)
{
//
// Load global settings.
//
formToSet.Icon = new Icon("images/skin/global/icon.ico");
formToSet.ClientSize = new System.Drawing.Size(1440, 900);
}
Used as:
//When called from another form
TrayForm.SettingsOnProgramStart(this);
As to settings, see MSDN application settings: http://msdn.microsoft.com/en-us/library/k4s6c3a0(v=vs.110).aspx
As an aside; this code doesn't really make sense as part of the TrayForm class, as its not related to that object at all. It should likely be a member of a GlobalSettingsManager class, or something similar.
I decided to try working with C# over c++ but ran into a problem.
The following code snippet shows the problem.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
using System.Device;
namespace Project_AREA
{
public partial class Form1 : Form
{
private Device device;
public Form1()
{
InitializeComponent();
}
}
}
That's as much code as I have right now.
In private Device device;, the keyword Device is not getting recognized although all the libraries have been referenced and the using directives are included.
Any ideas?
Managed to Solve the problem.. for your reference and also if other run in to the same problem. You must add all the following references to the project: (note all files can be found on your had disk at c:\Windows\Microsoft.NET\DirectX for Managed Code) 1: Microsoft.DirectX.dll from folder 1.0.2902.0 2: Microsoft.DirectX.Direct3D.dll from folder 1.0.2902.0 3: MicrosoftMicrosoft.DirectX.Direct3DX.dll from folder 1.0.2911.0 Thanks for the help tho guys :)
I was writing my Patient class, for clinic software, and wanted to add a Photo property, but the Image class doesn't seem to be working in my code, don't know why, considering that I have included System.Drawing.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
namespace ClinicFiles
{
public partial class Patient : Person
{
public Image Photo { get; set; }
//etc. etc.
}
}
P.S. What site do you find the best guideline to a beautiful Windows Application design? :) Nice and professional user interface, all details taken care of, as fonts, etc etc. :)
Try right-clicking your project References and adding System.Drawing.
I was working through the MSDN tutorial for Crystal Reports, and I get to the Binding the Embedded Report to the CrystalReportViewer Control step:
When I try the build, it tells me that I am missing my using declaration for Hierarchical_Grouping class. This brings up two questions for me...
What is the namespace for this class definition?
Is there an easy way of determining the namespace of a given class?
In another answer I saw the 'ALT, SHIFT, F10' and the 'CTRL, [period]' suggestions for intellisense, but they don't work in my Visual Studio.
I'm sure I have done something ridiculously stupid....sorry in advance....
Here's the code for the form:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
namespace CrystalTest3
{
public partial class Form1 : Form
{
private Hierarchical_Grouping hierarchicalGroupingReport;
public Form1()
{
InitializeComponent();
}
private void ConfigureCrystalReports()
{
hierarchicalGroupingReport = new Hierarchical_Grouping();
crystalReportViewer.ReportSource = hierarchicalGroupingReport;
}
private void Form1_Load(object sender, EventArgs e)
{
ConfigureCrystalReports();
}
}
}
I am assuming that you are referring to this tutorial.
The Hierarchical_Grouping seems to refer to the report file - which will contain the class named Hierarchical_Grouping. Have you added the report to your project?
The report should be somewhere in these Sample Reports Directories.