Click here to Skip to main content
15,867,686 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Modal show information Pin
Member 1490896420-Oct-20 2:47
Member 1490896420-Oct-20 2:47 
GeneralRe: Modal show information Pin
ZurdoDev20-Oct-20 2:48
professionalZurdoDev20-Oct-20 2:48 
AnswerRe: Modal show information Pin
ZurdoDev20-Oct-20 5:01
professionalZurdoDev20-Oct-20 5:01 
QuestionDisplay Tabs and details in ASP.Net MVC Pin
sagarpallavi18-Oct-20 17:21
sagarpallavi18-Oct-20 17:21 
AnswerRe: Display Tabs and details in ASP.Net MVC Pin
Richard MacCutchan18-Oct-20 21:55
mveRichard MacCutchan18-Oct-20 21:55 
QuestionFullCalendar button or click in day to add new event Pin
Member 1490896413-Oct-20 6:48
Member 1490896413-Oct-20 6:48 
QuestionRe: FullCalendar button or click in day to add new event Pin
ZurdoDev13-Oct-20 9:09
professionalZurdoDev13-Oct-20 9:09 
QuestionPDF to Images for encryption Pin
Member 105489775-Oct-20 4:30
Member 105489775-Oct-20 4:30 
Converting pdf files to image so that i can then encrypt the images converted. In my case pdf to jpg. My code will convert each pdf page to an individual image file. So that if the pdf file contains 3 pages I end up with 3 jpg. I then take the 3 images and merge them together to create one big image.


I noticed that if I removed the 3 images from the file system the one bigger image will not display the image. It's as if I removed a reference to the 3 images. And will not display the bigger image properly. Here's the code to convert pdf to images image merge. In this case there are 5 jpg images I merge to one jpg. I don't understand why the merged image will not display the 3 images merged.

Below are the 2 functions to do the convert and merge.

static void PDF2Image()
{
    List<string> listOfFiles = new List<string>();
    System.Drawing.Bitmap finalImage = null;
    int pgs = 0;
    System.Drawing.Image img;
    string xFile = string.Empty;
    FileStream stream;

        try
        {
            string path = @"c:\temp\pdf2Image\";
            PdfDocument documemt = new PdfDocument();
            documemt.LoadFromFile(@"c:\temp\pdf2Image\DDDDDD.pdf");
            pgs = documemt.Pages.Count;
            for (int i = 0; i < pgs; i++)
            {
                img = documemt.SaveAsImage(i, 600, 600);
                img.Save(@"c:\temp\pdf2Image\DDDDDD" + "_" + i + ".jpg");

                xFile = @"c:\temp\pdf2Image\DDDDDD" + "_" + i + ".jpg";

                listOfFiles.Add(xFile);

                img.Dispose();
            }
            documemt.Close();
        }
        catch (Exception ex)
        {
            throw;
        }
    Image2Merge(listOfFiles);
}


public static System.Drawing.Bitmap Image2Merge(List<string> listOfFiles)
{
    string imgPath = @"c:\temp\pdf2Image\";
    string imgType = "*.jpg";
    List<System.Drawing.Bitmap> images = new List<System.Drawing.Bitmap>();
    System.Drawing.Bitmap finalImage = null;
    int width = 0;
    int height = 0;

    try
    {
        foreach (string image in Directory.GetFiles(imgPath, imgType))
        {
            System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(image);

            //update the size of the final bitmap
            width += bitmap.Width;
            height = bitmap.Height > height ? bitmap.Height : height;

            images.Add(bitmap);
        }

        //bitmap canvas to hold the combined image
        finalImage = new System.Drawing.Bitmap(5000, height);

        using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(finalImage))
        {
            //go through each image and draw it on the final image
            int offset = 0;
            foreach (System.Drawing.Bitmap image in images)
            {
                image.SetResolution(72, 72);
                g.DrawImage(image, new System.Drawing.Rectangle(offset, 0, image.Width, image.Height));
                offset += image.Width;

                image.Dispose();
            }
        }
        return finalImage;
    }
    catch (Exception ex)
    {
        if (finalImage != null)
            finalImage.Dispose();
        throw;
    }
    finally
    {
        finalImage.Save(@"c:\temp\pdf2Image\DDDDDD.jpg", ImageFormat.Jpeg);
        foreach (string xFile in listOfFiles)
        {
            //if (File.Exists(xFile))  File.Delete(xFile);
        }
    }
}

AnswerRe: PDF to Images for encryption Pin
F-ES Sitecore6-Oct-20 0:07
professionalF-ES Sitecore6-Oct-20 0:07 
GeneralRe: PDF to Images for encryption Pin
Member 105489776-Oct-20 3:21
Member 105489776-Oct-20 3:21 
GeneralRe: PDF to Images for encryption Pin
F-ES Sitecore6-Oct-20 5:26
professionalF-ES Sitecore6-Oct-20 5:26 
GeneralRe: PDF to Images for encryption Pin
Member 105489776-Oct-20 5:57
Member 105489776-Oct-20 5:57 
GeneralRe: PDF to Images for encryption Pin
Member 105489776-Oct-20 6:00
Member 105489776-Oct-20 6:00 
GeneralRe: PDF to Images for encryption Pin
F-ES Sitecore6-Oct-20 6:08
professionalF-ES Sitecore6-Oct-20 6:08 
GeneralRe: PDF to Images for encryption Pin
Member 105489776-Oct-20 6:52
Member 105489776-Oct-20 6:52 
GeneralRe: PDF to Images for encryption Pin
F-ES Sitecore6-Oct-20 10:45
professionalF-ES Sitecore6-Oct-20 10:45 
GeneralRe: PDF to Images for encryption Pin
Member 105489777-Oct-20 7:00
Member 105489777-Oct-20 7:00 
GeneralRe: PDF to Images for encryption Pin
Member 105489776-Oct-20 3:22
Member 105489776-Oct-20 3:22 
QuestionDynamically added controls effecting other controls Pin
Member 149556174-Oct-20 11:22
Member 149556174-Oct-20 11:22 
AnswerRe: Dynamically added controls effecting other controls Pin
Richard Deeming5-Oct-20 2:55
mveRichard Deeming5-Oct-20 2:55 
GeneralRe: Dynamically added controls effecting other controls Pin
Member 149416716-Oct-20 1:16
Member 149416716-Oct-20 1:16 
Questiontrying to get some measurement data to ASP from Microsoft SQL? Pin
auting824-Oct-20 11:07
auting824-Oct-20 11:07 
AnswerRe: trying to get some measurement data to ASP from Microsoft SQL? Pin
Richard Deeming5-Oct-20 2:53
mveRichard Deeming5-Oct-20 2:53 
QuestionComplex View Model with Nested Item List / ModelState Pin
Guillermo Perez18-Sep-20 15:49
Guillermo Perez18-Sep-20 15:49 
AnswerRe: Complex View Model with Nested Item List / ModelState Pin
Richard Deeming27-Sep-20 22:21
mveRichard Deeming27-Sep-20 22:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.