Quality Setting for TIFF/JPG using SaveAs


hi,

i'm trying export jpg or tiff "preview" image single pdf page. however, terrible - accessing javascript object through c# , calling "saveas", can't find parameters or methods set quality of image. can help?

 

edit: using acro 9/x.

 

thanks

what ended doing using c# open pdf select first page , copying clipboard pulling image out of clipboard, resizing , saving...

public static void copypdfcovertoclipboard(string filepath)

        {

            arc.acroavdoc afile = new arc.acroavdoc();

            bool returned = afile.open(filepath,"");

            if (returned == true) {

                //console.writeline("opened file");

            }

            arc.acropddoc temp = afile.getpddoc();

            arc.acropdpage apage = temp.acquirepage(0);

            arc.acropoint size = apage.getsize();

            arc.acrorect rect = new arc.acrorect();

            rect.top = 0;

            rect.left = 0;

            rect.right = size.x;

            rect.bottom = size.y;

            bool returned2 = apage.copytoclipboard(rect, 0, 0, 100);

            if (returned2 == true) {

                //console.writeline("copied");

            } else {

                console.writeline("no copied");

            }

            /**forgot close , paid price when couldnt delelete... **/

           

            afile.close(0);

        }

 

/** took reading figure out... apparently has threading... **/

public static image collectimgfromclipandsave()

        {

            /***

             * ref - http://ryanfarley.com/blog/archive/2006/01/31/15840.aspx (*3)

             * http://msdn.microsoft.com/en-us/library/system.windows.forms.clipboard.getimage.aspx?cs-sa ve-lang=1&cs-lang=csharp#code-snippet-2

             *

             *

             *

             * grade pain in butt.....

             * [stathread] above main().... makes work.....

             * ouch head hurts happy works

             *

            **/

            imageformat theformat = imageformat.jpeg;

            //system.threading.thread.sleep(1000);

            if (clipboard.containsimage())

            {

                image clipboardimage = clipboard.getimage();

                return clipboardimage;

            }

            else

            {

                console.writeline("nothing contained!!!");

            }

            return null;

        }

public static image resizeimage(image imgtoresize, float width)

        {

            //http://tech.pro/tutorial/620/csharp-tutorial-image-editing-saving-cropping-and-resizing

            int sourcewidth = imgtoresize.width;

            int sourceheight = imgtoresize.height;

 

 

            float npercent = 0;

            /**convert sourcewidth float , divide width percentage*/

            npercent=(width/(float)sourcewidth);

            /** find new hight , width **/

            int destwidth = (int)(sourcewidth * npercent);

            int destheight = (int)(sourceheight * npercent);

 

 

            /** start of create new image return... */

            bitmap b = new bitmap(destwidth, destheight);

            graphics g = graphics.fromimage((image)b);

            g.interpolationmode = interpolationmode.highqualitybicubic;

 

 

            g.drawimage(imgtoresize, 0, 0, destwidth, destheight);

            g.dispose();

 

 

            return (image)b;

        }

 

 

 

 

        /** wrote function overloads **/

        private static void forpdftojpgfunc(string src, string outname, float w) {

            image image;

            string newpath;

            //console.writeline("copying page 1 of pdf");

            methods.copypdfcovertoclipboard(src);

            image = methods.collectimgfromclipandsave();

            image = methods.resizeimage(image, w);

            newpath = path.getdirectoryname(src) + "\\" + outname + ".jpg";

            image.save(newpath);     

        }

 

 

        public static void pdfpg1tojpg(string src, float w)

        {

            forpdftojpgfunc(src, path.getfilenamewithoutextension(src), w);

        }

        public static void pdfpg1tojpg(string src, string outname, float w)

        {

            forpdftojpgfunc(src, outname, w);

        }

    }

/************************ please note these functions pulled form different files need reorganize them them work properlpy ***************/

class program

    {

        [stathread]/**this makes magic work dont know why **/

        static void main(string[] args)

        {

            list<string> sources = new list<string>();

            string outname = "";

            if (args.count() < 1)

            {

                console.writeline("enter pdf");

                sources.add(console.readline());

                console.writeline("file out name");

                outname = console.readline();

            }

            else {

                (int = 0; < args.count(); i++)

                {

                    sources.add(args[i]);

                }

            }

            console.writeline("new width:");

            int width = convert.toint16(console.readline());

           

            foreach(string source in sources){

                if (outname != "")

                {

                    methods.pdfpg1tojpg(source, outname, width);

                }

                else

                {

                    methods.pdfpg1tojpg(source, width);

                }

            }

        }

    }

 

i know not looking maybe can in way...

 

i use make cover previews website in bulk or 1 @ time....

 

i hope helps....



More discussions in JavaScript


adobe

Comments

Popular posts from this blog

How to change text Component easybook reloaded *newbee* - Joomla! Forum - community, help and support

PProHeadless.exe has stopped working error when opening projects in Adobe Media Encoder CS6

Preconditions Failed. - Joomla! Forum - community, help and support