コード例 #1
0
        private static void Main(string[] args)
        {
            // open and load the file
            using (FileStream fs = new FileStream(@"..\..\map.pdf", FileMode.Open), fsOut = File.Create("out.tiff"))
            {
                // this objects represents a PDF document
                using (Document document = new Document(fs))
                {
                    // save to tiff using CCIT4 compression, black and white tiff.
                    // set the DPI to 144.0 for this sample, so twice more than default PDF dpi setting.
                    TiffRenderingSettings tiffRenderingSettings = new TiffRenderingSettings(TiffCompressionMethod.LZW,
                                                                                            DPI, DPI);
                    tiffRenderingSettings.RenderMode  = RenderMode.HighQuality;
                    tiffRenderingSettings.ScaleMode   = ScaleMode.PreserveAspectRatio;
                    tiffRenderingSettings.Compression = TiffCompressionMethod.LZW;

                    // subscribe to before rendering event and adjust rendering settings
                    // for each page as you want
                    tiffRenderingSettings.BeforeRenderPage += TiffRenderingSettings_BeforeRenderPage;

                    document.SaveToTiff(fsOut, tiffRenderingSettings);
                }

                System.Diagnostics.Process.Start("out.tiff");
            }
        }
コード例 #2
0
 private static void ProcessPdfDocument(Document document, TiffRenderingSettings settings, string outputFileName)
 {
     using (FileStream outputStream = File.Create(outputFileName))
     {
         document.SaveToTiff(outputStream, settings);
     }
 }
コード例 #3
0
        private static void Main(string[] args)
        {
            // open and load the file
            using (FileStream fs = new FileStream(@"..\..\..\..\development guide.pdf", FileMode.Open), fsOut = File.Create("out.tiff"))
                using (Document document = new Document(fs))         // this object represents a PDF document
                {
                    // save to tiff using CCIT4 compression, black and white tiff.
                    // set the DPI to 144.0 for this sample, so twice more than default PDF dpi setting.
                    TiffRenderingSettings tiffRenderingSettings = new TiffRenderingSettings(TiffCompressionMethod.CCIT4, 144, 144);

                    // set the white color brightness level
                    tiffRenderingSettings.WhiteColorTolerance = 0.9f;

                    document.SaveToTiff(fsOut, tiffRenderingSettings);

                    System.Diagnostics.Process.Start("out.tiff");
                }
        }
コード例 #4
0
        static void Main(string[] args)
        {
            using (FileStream stream = new FileStream(inputFileName, FileMode.Open, FileAccess.Read))
            {
                using (Document document = new Document(stream))
                {
                    TiffRenderingSettings settings = new TiffRenderingSettings();
                    settings.Compression = TiffCompressionMethod.LZW;

                    #region Before Rendering Page

                    settings.BeforeRenderPage += Settings_BeforeRenderPage;
                    ProcessPdfDocument(document, settings, "out_beforeevent.tiff");
                    System.Diagnostics.Process.Start("out_beforeevent.tiff");

                    #endregion

                    #region Standard convert to bitonal

                    settings.Compression = TiffCompressionMethod.CCIT4;
                    ProcessPdfDocument(document, settings, "out_standardbitonal.tiff");
                    System.Diagnostics.Process.Start("out_standardbitonal.tiff");

                    #endregion

                    #region Custom convert to bitonal

                    ConvertToBitonalDelegate convertDelegate = ConvertToBitonal;
                    settings.ConvertToBitonal = convertDelegate;
                    ProcessPdfDocument(document, settings, "out_cuctombitonal.tiff");
                    System.Diagnostics.Process.Start("out_cuctombitonal.tiff");

                    #endregion

                    #region After Rendering Page
                    settings.Compression      = TiffCompressionMethod.LZW;
                    settings.AfterRenderPage += Settings_AfterRenderPage;
                    ProcessPdfDocument(document, settings, "out_afterrendering.tiff");
                    System.Diagnostics.Process.Start("out_afterrendering.tiff");

                    #endregion
                }
            }
        }