C # Word to picture PDF to picture

Source: Internet
Author: User

Word to picture uses the Aspose component, Aspose.word.dll

 public bool word2png (string docfile, string pngdir, out int  Pngcount)         {             imagesaveoptions options = new imagesaveoptions (SaveFormat.Png);             options. Resolution = 300;            options. Prettyformat = true;            options. useantialiasing = true;             pngcount = 0;            try             {                 aspose.wordS.document doc = new aspose.words.document (docfile);                 for  (int i = 0; i  < doc. pagecount; i++)                  {                     options. pageindex = i;                     doc. Save (pngdir + i +  ". png",  options);                     pngCount++;                 }                 return true;            }             catch             {                 return false;            }         }

PDF to picture is using the Aspose.pdf.dll component

 public bool pdf2png (String srcpdfpath, string despicpath)          {            try             {                 Aspose.Pdf.Document pdf = new  Aspose.Pdf.Document (Srcpdfpath);                 for  (int pagecount = 1; pagecount <= pdf. pages.count; pagecount++)                  {                     using  (Filestream imagestream = new filestream ( despicpath +  "\"  + pagecount +  ". png",  filemode.create)                      {                         //create  resolution object                         aspose.pdf.devices.resolution resolution  = new aspose.pdf.devices.resolution (;        )                  Aspose.pdf.devices.pngdevice pngdevice = new aspose.pdf.devices.pngdevice (resolution);                          //convert a particular page and save the image to stream                          pngdevice.process (PDF. Pages[pagecount], imagestream);                         //close stream                          imagestream.close ();                     }                 }                 return true;            }            catch  ( Exception e)             {                 return false;             }        }


C # Word to picture PDF to picture

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.