English 中文(简体)
向国防军出口形象
原标题:Export Images to PDF

我有一个必须向人民抵抗力量输出图像的项目。 图像和文字都需要出口到pdf,是否有办法利用银河PDF.dll和PdfReader?

这里的法律。

 private void btnOutlook_Click(object sender, System.Windows.RoutedEventArgs e)
    {
        XBrush xbrush;
        SaveFileDialog savePDF = new SaveFileDialog();
        savePDF.Filter = "PDF file format | *.pdf";
        if (savePDF.ShowDialog() == true)
        {
            PdfDocument document = new PdfDocument();
            PdfPage page = document.AddPage();
            XGraphics gfx = XGraphics.FromPdfPage(page);
            XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);

            XFont font = new XFont("Huxtable", 20, XFontStyle.Bold, options);

            for (int x = 0; x < 10; x++)
            {
                if (x % 2 == 0)
                {
                    xbrush = XBrushes.Red;
                }
                else
                    xbrush = XBrushes.Black;
                gfx.DrawString(string.Format("{0}", stringArray[x]), font, xbrush, new XRect(0, (x * 20), page.Width, page.Height), XStringFormats.TopLeft);
            }

            document.Save(savePDF.OpenFile());
        }

    }

where in this code can I insert an Image that inserts it to pdf? Is there any way? Thanks for all replies.

最佳回答

是否需要银河保护? 由于Iv在我以前的雇主使用iTextSharp图书馆做了类似的事情(否则我将删除过去样本代码)。

iTextSharp-Working-with-images

rel=“nofollow”>DownloadLink

问题回答

Tesseract 4.1.1, converting Images to PDF Full Text in C#

这里是利用2022年视觉演播室内Nugget包裹中的Tesseract 4.1.1和DotNet 6的全文层建设PDF的一种方法。

这里是从多个支队中创建国防军的职能。

  1. The jpg files name must be structured like that: IMG1.jpg,IMG2.jpg,IMG3.jpg, ...
  2. All images file are stored inside the same folder

private void PDFRenderer_OCR_MutipleJPG(String PDFName, String PDFTitle, String FolderJpg, int NumberImage)
  {
     IResultRenderer renderer = Tesseract.PdfResultRenderer.CreatePdfRenderer(PDFName, "tessdata", false);
     renderer.BeginDocument(PDFTitle);
     string configurationFilePath = "tessdata";
     string configfile = Path.Combine("tessdata", "pdf");
     //using (TesseractEngine engine = new TesseractEngine(configurationFilePath, "eng", EngineMode.TesseractAndLstm, configfile))
     EngineMode M1 = EngineMode.TesseractOnly;//election OCR mode
     TesseractEngine engine = new TesseractEngine("tessdata", "eng", M1);
     // progressBar1.Maximum= NumberImage;
     // progressBar1.Minimum = 1;   
          for (i =1 ; i < NumberImage+1;i++)//i=1, because my first image name is img1.jpg
            {
               //progressBar1.Value= i+1;
                lPage.Text = "Processing page: " + i.ToString();
                lPage.Refresh();       
                TesseractEngine engine = new TesseractEngine("tessdata", "eng", M1);
                string ImageJpg = "c:\temp" + "\" + FolderJpg + "\" + FolderJpg + i.ToString() + ".jpg";
               // MessageBox.Show("IMG: " + ImageJpg);      
                using (var imagefile = new Bitmap(ImageJpg))
                 {
                    using (var img = PixConverter.ToPix(imagefile))
                    {
                        using (Tesseract.Page page = engine.Process(img, PDFTitle))
                        {
                            renderer.AddPage(page); // Adding converted page 
                        }
                    }                  
                }      
            }
            renderer.Dispose(); // Clear ressourcce
            //Reset progressBar1 to origin setting
            //progressBar1.Value= 1;
            //progressBar1.Maximum = 100;
            //progressBar1.Minimum= 0;
            //progressBar1.Value = 0;
  }

仅指这种方法:

PDFRenderer_OCR_MutipleJPG("C:empoutp”,“tilte”,Document, 20);

  • “C: empoutp”-> name and path for final pdf without extension,it will be “C: empoutp.pdf”。

  • 标题=“所有权”元数据

  • 文件——和;是我的图像夹,也是每个图像名称的一部分,没有索引。

  • Here the Folder of images to convert is: C: empdocument -> inside: -> Document1.jpg, Document2.jpg, Document3.jpg, ...

  • 指数是20,是转换图像的数量。

  • B. 任择进展 B. 在处理过程中检查情报和安全局的页数

Best Regards Francis from France





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签