C# School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a C# Expert!

Join 306,805 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 1,659 people online right now. Registration is fast and FREE... Join Now!




PDF to Tiff

 

PDF to Tiff, simple api needed

samuraitux

11 May, 2009 - 03:30 PM
Post #1

New D.I.C Head
Group Icon

Joined: 29 Apr, 2009
Posts: 21


Dream Kudos: 25
My Contributions
Hey Guys, do you have any suggestions on a pdf api that I can use so that I can take pdf's and rasterize them into a multi page TIFF. I am looking at iTextSharp, PDFsharp, and PDFjet but I am not sure if they will let me do the conversion. Any help would be greatly appreciated. Also I know what the dreamincode policy about good faith codeis but I am not asking for code. I am looking for an API or sdk that is hopefully free or priced reasonably

User is offlineProfile CardPM
+Quote Post


samuraitux

RE: PDF To Tiff

11 May, 2009 - 04:35 PM
Post #2

New D.I.C Head
Group Icon

Joined: 29 Apr, 2009
Posts: 21


Dream Kudos: 25
My Contributions
Well I think I did find something worth looking into. Looks like an open source app called imagemagick is looking pretty good. I will try and test and see. They even have a java port, as well as a perl port so I have plenty of options. But I am still open to suggestions.
User is offlineProfile CardPM
+Quote Post

Cha0sBG

RE: PDF To Tiff

12 May, 2009 - 02:04 AM
Post #3

D.I.C Head
Group Icon

Joined: 9 Apr, 2009
Posts: 140



Thanked: 4 times
Dream Kudos: 50
My Contributions
QUOTE
The following code works for converting PDF to TIFF.But for that you have to use the ABCpdf 6.0 .NET Professional


CODE
Doc theDoc = new Doc();

theDoc.Read(Server.MapPath("../Pdfreports/Procedure_Report_" + ReportId.ToString() + ".pdf"));

// set up the rendering parameters

theDoc.Rendering.ColorSpace = "Gray";

theDoc.Rendering.BitsPerChannel = 1;

theDoc.Rendering.DotsPerInchX = 200;

theDoc.Rendering.DotsPerInchY = 400;

// loop through the pages

int n = theDoc.PageCount;

for (int i = 1; i <= n; i++)

{

theDoc.PageNumber = i;

theDoc.Rect.String = theDoc.CropBox.String;

theDoc.Rendering.SaveAppend = (i != 1);

//theDoc.Rendering.SaveCompression = XRendering.Compression.G4;

theDoc.SetInfo(0, "ImageCompression", "4");

theDoc.Rendering.Save(Server.MapPath("../Pdfreports/Procedure_Report_" + ReportId.ToString() + "_" + i.ToString() + ".tiff"));

}

theDoc.Clear();


This was taken from: http://social.msdn.microsoft.com/Forums/en...8-775f6d091ab1/

And here is a download link for the abcpdf .NET: http://wareseeker.com/free-abcpdf-.net/

Hope it helps you.

~Cha0sBG

This post has been edited by Cha0sBG: 12 May, 2009 - 02:06 AM
User is online!Profile CardPM
+Quote Post

samuraitux

RE: PDF To Tiff

12 May, 2009 - 05:10 AM
Post #4

New D.I.C Head
Group Icon

Joined: 29 Apr, 2009
Posts: 21


Dream Kudos: 25
My Contributions
Thanks Cha0sBG that has provided me a great start. Thanks for the links.
User is offlineProfile CardPM
+Quote Post

samuraitux

RE: PDF To Tiff

12 May, 2009 - 08:35 AM
Post #5

New D.I.C Head
Group Icon

Joined: 29 Apr, 2009
Posts: 21


Dream Kudos: 25
My Contributions
If someone else is wondering here is the code that I have. I have attached a picture of the app also.
CODE

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 System.IO;
using WebSupergoo.ABCpdf7;
using WebSupergoo.ABCpdf7.Objects;
using WebSupergoo.ABCpdf7.Atoms;
using WebSupergoo.ABCpdf7.Operations;

namespace CSBconvert
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        public void exitApplication(Object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void btnPDFLoc_Click(object sender, EventArgs e)
        {
            if (openFD.ShowDialog() == DialogResult.OK)
            {
                txtPDFLoc.Text = openFD.SelectedPath.ToString();
            }
        }

        private void btnOutput_Click(object sender, EventArgs e)
        {
            if (openFD.ShowDialog() == DialogResult.OK)
            {
                txtOutput.Text = openFD.SelectedPath.ToString();
            }
        }

        private void btnProcess_Click(object sender, EventArgs e)
        {
            string filePath = txtPDFLoc.Text + "\\";
            string savePath = txtOutput.Text;
            string fileName;
            DirectoryInfo directoryList = new DirectoryInfo(@filePath);
            FileInfo[] pdfFile = directoryList.GetFiles("*.pdf");
            foreach (FileInfo file in pdfFile)
            {
                Doc theDoc = new Doc();
                
                theDoc.Read(filePath + file.Name);

                // set up the rendering parameters

                theDoc.Rendering.ColorSpace = "Gray";
                theDoc.Rendering.BitsPerChannel = 1;
                theDoc.Rendering.DotsPerInchX = 200;
                theDoc.Rendering.DotsPerInchY = 400;
                // loop through the pages
                int n = theDoc.PageCount;
                fileName = Path.GetFileNameWithoutExtension(file.FullName);
                for (int i = 1; i <= n; i++)
                {
                    theDoc.PageNumber = i;
                    theDoc.Rect.String = theDoc.CropBox.String;
                    theDoc.Rendering.SaveAppend = (i != 1);
                    //theDoc.Rendering.SaveCompression = XRendering.Compression.G4;
                    theDoc.SetInfo(0, "ImageCompression", "4");

                    theDoc.Rendering.Save(savePath + "\\" + fileName + ".tiff");              
                }

                theDoc.Clear();
                
            }
        }
    }
}


Hope this helps someone else. Now I just need to figure out how I can add a progress bar.



Attached thumbnail(s)
Attached Image
User is offlineProfile CardPM
+Quote Post

Cha0sBG

RE: PDF To Tiff

12 May, 2009 - 09:09 AM
Post #6

D.I.C Head
Group Icon

Joined: 9 Apr, 2009
Posts: 140



Thanked: 4 times
Dream Kudos: 50
My Contributions
Hehe no problem samuraitux smile.gif glad to help you.
User is online!Profile CardPM
+Quote Post

samuraitux

RE: PDF To Tiff

12 May, 2009 - 09:11 AM
Post #7

New D.I.C Head
Group Icon

Joined: 29 Apr, 2009
Posts: 21


Dream Kudos: 25
My Contributions
Another quick update. I have gotten the progress bar to work. I just added it to the end after each conversion.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/20/09 09:41PM

Live C# Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month