|
@@ -3384,80 +3384,77 @@ namespace XHWK.WKTool
|
3384
|
3384
|
}
|
3385
|
3385
|
|
3386
|
3386
|
|
3387
|
|
- iTextSharp.text.Document document = new iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 0, 0, 0, 0);
|
3388
|
|
- //iTextSharp.text.Rectangle page = new iTextSharp.text.Rectangle(iTextSharp.text.PageSize.A4., 250f);//cs
|
3389
|
|
- ////设置纸张横向
|
3390
|
|
- //document.SetPageSize(iTextSharp.text.PageSize.A4.Rotate());
|
3391
|
|
-
|
3392
|
|
- string imgPath = FileToolsCommon.GetFileAbsolutePath("temp/");
|
3393
|
|
- FileToolsCommon.CreateDirectory(imgPath);
|
3394
|
|
- imgPath += "101.pdf";
|
3395
|
|
- iTextSharp.text.pdf.PdfWriter.GetInstance(document, new FileStream(imgPath, FileMode.Create, FileAccess.ReadWrite));
|
3396
|
|
- document.Open();
|
3397
|
|
- iTextSharp.text.Image image;
|
3398
|
|
- for (int i = 0; i < APP.PageDrawList.Count; i++)
|
3399
|
|
- {
|
3400
|
|
- long ii = Timestamp();
|
3401
|
|
- string directoryPath = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
|
3402
|
|
- string filePathOutPut = Path.Combine(directoryPath, string.Format("print{0}{1}.jpg", ii, i));
|
3403
|
|
- RectangleF rectangleFs = new RectangleF();
|
3404
|
|
- MergerImg("", filePathOutPut, rectangleFs, out string errmsg);
|
3405
|
|
- image = iTextSharp.text.Image.GetInstance(filePathOutPut);
|
3406
|
|
- if (string.IsNullOrEmpty(APP.PageDrawList[i].PageImagePath))//没有图片
|
3407
|
|
- {
|
3408
|
|
-
|
3409
|
|
- }
|
3410
|
|
- else if (APP.PageDrawList[i].ImgDocumentation == true&& !APP.PageDrawList[i].Type.Equals("ppt"))
|
3411
|
|
- {
|
3412
|
|
- image = iTextSharp.text.Image.GetInstance(APP.PageDrawList[i].PageImagePath);
|
3413
|
|
- }
|
3414
|
|
- else
|
3415
|
|
- {
|
3416
|
|
- RectangleF rectangleF = new RectangleF
|
3417
|
|
- {
|
3418
|
|
- Width = (float)APP.PageDrawList[i].ImageSizes.CenterX,
|
3419
|
|
- Height = (float)APP.PageDrawList[i].ImageSizes.CenterY,
|
3420
|
|
- X = (float)APP.PageDrawList[i].ImageLocation.X,
|
3421
|
|
- Y = (float)APP.PageDrawList[i].ImageLocation.Y
|
3422
|
|
- };
|
3423
|
|
-
|
3424
|
|
-
|
3425
|
|
- string msg = string.Empty;
|
3426
|
|
- bool isImg = MergerImg(APP.PageDrawList[i].PageImagePath, filePathOutPut, rectangleF, out msg);
|
3427
|
|
- if (isImg)
|
3428
|
|
- {
|
3429
|
|
- image = iTextSharp.text.Image.GetInstance(filePathOutPut);
|
3430
|
|
- }
|
3431
|
|
- else
|
3432
|
|
- {
|
3433
|
|
- image = iTextSharp.text.Image.GetInstance(APP.PageDrawList[i].PageImagePath);
|
3434
|
|
- }
|
3435
|
|
- }
|
3436
|
|
-
|
|
3387
|
+ //iTextSharp.text.Document document = new iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 0, 0, 0, 0);
|
|
3388
|
+ ////iTextSharp.text.Rectangle page = new iTextSharp.text.Rectangle(iTextSharp.text.PageSize.A4., 250f);//cs
|
|
3389
|
+ //////设置纸张横向
|
|
3390
|
+ ////document.SetPageSize(iTextSharp.text.PageSize.A4.Rotate());
|
|
3391
|
+
|
|
3392
|
+ //string imgPath = FileToolsCommon.GetFileAbsolutePath("temp/");
|
|
3393
|
+ //FileToolsCommon.CreateDirectory(imgPath);
|
|
3394
|
+ //imgPath += "101.pdf";
|
|
3395
|
+ //iTextSharp.text.pdf.PdfWriter.GetInstance(document, new FileStream(imgPath, FileMode.Create, FileAccess.ReadWrite));
|
|
3396
|
+ //document.Open();
|
|
3397
|
+ //iTextSharp.text.Image image;
|
|
3398
|
+ //for (int i = 0; i < APP.PageDrawList.Count; i++)
|
|
3399
|
+ //{
|
|
3400
|
+ // long ii = Timestamp();
|
|
3401
|
+ // string directoryPath = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
|
|
3402
|
+ // string filePathOutPut = Path.Combine(directoryPath, string.Format("print{0}{1}.jpg", ii, i));
|
|
3403
|
+ // RectangleF rectangleFs = new RectangleF();
|
|
3404
|
+ // MergerImg("", filePathOutPut, rectangleFs, out string errmsg);
|
|
3405
|
+ // image = iTextSharp.text.Image.GetInstance(filePathOutPut);
|
|
3406
|
+ // if (string.IsNullOrEmpty(APP.PageDrawList[i].PageImagePath))//没有图片
|
|
3407
|
+ // {
|
3437
|
3408
|
|
|
3409
|
+ // }
|
|
3410
|
+ // else if (APP.PageDrawList[i].ImgDocumentation == true&& !APP.PageDrawList[i].Type.Equals("ppt"))
|
|
3411
|
+ // {
|
|
3412
|
+ // image = iTextSharp.text.Image.GetInstance(APP.PageDrawList[i].PageImagePath);
|
|
3413
|
+ // }
|
|
3414
|
+ // else
|
|
3415
|
+ // {
|
|
3416
|
+ // RectangleF rectangleF = new RectangleF
|
|
3417
|
+ // {
|
|
3418
|
+ // Width = (float)APP.PageDrawList[i].ImageSizes.CenterX,
|
|
3419
|
+ // Height = (float)APP.PageDrawList[i].ImageSizes.CenterY,
|
|
3420
|
+ // X = (float)APP.PageDrawList[i].ImageLocation.X,
|
|
3421
|
+ // Y = (float)APP.PageDrawList[i].ImageLocation.Y
|
|
3422
|
+ // };
|
3438
|
3423
|
|
3439
|
3424
|
|
3440
|
|
- if (image.Height > iTextSharp.text.PageSize.A4.Height)
|
3441
|
|
- {
|
3442
|
|
- image.ScaleToFit(iTextSharp.text.PageSize.A4.Width, iTextSharp.text.PageSize.A4.Height);
|
3443
|
|
- }
|
3444
|
|
- else if (image.Width > iTextSharp.text.PageSize.A4.Width)
|
3445
|
|
- {
|
3446
|
|
- image.ScaleToFit(iTextSharp.text.PageSize.A4.Width, iTextSharp.text.PageSize.A4.Height);
|
3447
|
|
- }
|
3448
|
|
- image.Alignment = iTextSharp.text.Image.ALIGN_MIDDLE;
|
3449
|
|
- document.NewPage();
|
3450
|
|
- document.Add(image);
|
3451
|
|
- //iTextSharp.text.Chunk c1 = new iTextSharp.text.Chunk("Hello World");
|
3452
|
|
- //iTextSharp.text.Phrase p1 = new iTextSharp.text.Phrase();
|
3453
|
|
- //p1.Leading = 150; //行间距
|
3454
|
|
- //document.Add(p1);
|
3455
|
|
- }
|
3456
|
|
- Console.WriteLine("转换成功!");
|
3457
|
|
- document.Close();
|
|
3425
|
+ // string msg = string.Empty;
|
|
3426
|
+ // bool isImg = MergerImg(APP.PageDrawList[i].PageImagePath, filePathOutPut, rectangleF, out msg);
|
|
3427
|
+ // if (isImg)
|
|
3428
|
+ // {
|
|
3429
|
+ // image = iTextSharp.text.Image.GetInstance(filePathOutPut);
|
|
3430
|
+ // }
|
|
3431
|
+ // else
|
|
3432
|
+ // {
|
|
3433
|
+ // image = iTextSharp.text.Image.GetInstance(APP.PageDrawList[i].PageImagePath);
|
|
3434
|
+ // }
|
|
3435
|
+ // }
|
|
3436
|
+ // if (image.Height > iTextSharp.text.PageSize.A4.Height)
|
|
3437
|
+ // {
|
|
3438
|
+ // image.ScaleToFit(iTextSharp.text.PageSize.A4.Width, iTextSharp.text.PageSize.A4.Height);
|
|
3439
|
+ // }
|
|
3440
|
+ // else if (image.Width > iTextSharp.text.PageSize.A4.Width)
|
|
3441
|
+ // {
|
|
3442
|
+ // image.ScaleToFit(iTextSharp.text.PageSize.A4.Width, iTextSharp.text.PageSize.A4.Height);
|
|
3443
|
+ // }
|
|
3444
|
+ // image.Alignment = iTextSharp.text.Image.ALIGN_MIDDLE;
|
|
3445
|
+ // document.NewPage();
|
|
3446
|
+ // document.Add(image);
|
|
3447
|
+ // //iTextSharp.text.Chunk c1 = new iTextSharp.text.Chunk("Hello World");
|
|
3448
|
+ // //iTextSharp.text.Phrase p1 = new iTextSharp.text.Phrase();
|
|
3449
|
+ // //p1.Leading = 150; //行间距
|
|
3450
|
+ // //document.Add(p1);
|
|
3451
|
+ //}
|
|
3452
|
+ //Console.WriteLine("转换成功!");
|
|
3453
|
+ //document.Close();
|
3458
|
3454
|
}
|
3459
|
3455
|
catch (Exception ex)
|
3460
|
3456
|
{
|
|
3457
|
+ MessageWindow.Show(ex.Message);
|
3461
|
3458
|
Console.WriteLine("转换失败,原因:" + ex.Message);
|
3462
|
3459
|
}
|
3463
|
3460
|
//document.Close();
|
|
@@ -3472,11 +3469,11 @@ namespace XHWK.WKTool
|
3472
|
3469
|
}
|
3473
|
3470
|
if (APP.PageDrawList.Count > 0 && !string.IsNullOrWhiteSpace(APP.PageDrawList[0].PageImagePath))
|
3474
|
3471
|
{
|
3475
|
|
- APP.W_PrintWindow.Initialize(APP.PageDrawList[0].PageImagePath);
|
|
3472
|
+ APP.W_PrintWindow.Initialize(APP.PageDrawList[0].PageImagePath, gridM.ActualWidth, gridM.ActualHeight);
|
3476
|
3473
|
}
|
3477
|
3474
|
else
|
3478
|
3475
|
{
|
3479
|
|
- APP.W_PrintWindow.Initialize("");
|
|
3476
|
+ APP.W_PrintWindow.Initialize("", gridM.ActualWidth,gridActHeight);
|
3480
|
3477
|
}
|
3481
|
3478
|
APP.W_PrintWindow.ShowDialog();
|
3482
|
3479
|
//int pr = 1;
|