private void btnPrintWithAdobe_Click(object sender, EventArgs e) { try { if (!PdfPrintTest.IsFileNameCorrect(tbFileName.Text)) { return; } var printLibrary = PdfPrintTest.GetPdfPrint(_configFile); if (!SetSettingsFromGUIAdobe(printLibrary)) { return; } var resultMessage = ""; PdfPrint.Status result = PdfPrint.Status.OK; if (cbUsePrinterSettingsAdobe.Checked) { if (_printerSettingsAdobe == null) { MessageBox.Show("PrinterSettings not set. Press Set Printer Settings button"); return; } result = printLibrary.PrintWithAdobe(tbFileName.Text, _printerSettingsAdobe, ref resultMessage); } else { result = printLibrary.PrintWithAdobe(tbFileName.Text, ref resultMessage); } MessageBox.Show("Result message=" + resultMessage); if (result == PdfPrint.Status.OK) { MessageBox.Show("Done successfully."); } else { MessageBox.Show("Error. " + PdfPrintTest.DecodeStatusCode(result)); } } catch (Exception ex) { MessageBox.Show("Exception " + ex.Message); } }
private void btnSavePdfAsImage_Click(object sender, EventArgs e) { var printLibrary = PdfPrintTest.GetPdfPrint(_configFile); var colorType = PdfPrint.ColorType.Original; if (rbAsItIsInPDF.Checked) { colorType = PdfPrint.ColorType.Original; } if (rbBlackAndWhite.Checked) { colorType = PdfPrint.ColorType.BlackAndWhite; } if (rbGray.Checked) { colorType = PdfPrint.ColorType.GrayScale; } try { PdfPrint.Status result; if (cbxMultiTiff.Checked) { var tiffCompression = GetTiffCompression(); if (cbIsStreamImage.Checked) { result = printLibrary.SavePdfPagesAsMultiPageTiff(PdfPrintTest.GetStream(tbFileName.Text), tbImageFileName.Text, (int)numFrom.Value, (int)numToPage.Value, (int)numZoom.Value, (float)numXResolution.Value, (float)numYResolution.Value, colorType, tbPassword.Text, tiffCompression); } else { result = printLibrary.SavePdfPagesAsMultiPageTiff(tbFileName.Text, tbImageFileName.Text, (int)numFrom.Value, (int)numToPage.Value, (int)numZoom.Value, (float)numXResolution.Value, (float)numYResolution.Value, colorType, tbPassword.Text, tiffCompression); } } else { if (cbIsStreamImage.Checked) { result = printLibrary.SavePdfPagesAsImages(PdfPrintTest.GetStream(tbFileName.Text), tbImageFileName.Text, (int)numFrom.Value, (int)numToPage.Value, (int)numZoom.Value, (float)numXResolution.Value, (float)numYResolution.Value, colorType, (long)numQuality.Value, tbPassword.Text); } else { result = printLibrary.SavePdfPagesAsImages(tbFileName.Text, tbImageFileName.Text, (int)numFrom.Value, (int)numToPage.Value, (int)numZoom.Value, (float)numXResolution.Value, (float)numYResolution.Value, colorType, (long)numQuality.Value, tbPassword.Text); } } if (result == PdfPrint.Status.OK) { MessageBox.Show("Done successfully."); } else { MessageBox.Show("Error. " + PdfPrintTest.DecodeStatusCode(result)); } } catch (Exception ex) { MessageBox.Show("Exception " + ex.Message); } }
private void btnPrint_Click(object sender, EventArgs e) { if (!PdfPrintTest.IsFileNameCorrect(tbFileName.Text)) { return; } var printLibrary = PdfPrintTest.GetPdfPrint(_configFile); if (!SetSettingsFromGUI(printLibrary)) { return; } PdfPrint.Status result = PdfPrint.Status.OK; if (cbUsePrintDialog.Checked) { printLibrary.SettingDialog = true; } if (!cbIsStream.Checked) { string jobName = string.IsNullOrEmpty(tbDocumentName.Text.Trim()) ? tbFileName.Text : tbDocumentName.Text.Trim(); if (cbUsePrinterSettings.Checked) { if (cbUseWatermark.Checked) { result = printLibrary.Print(tbFileName.Text, _printerSettings, tbPassword.Text, _watermark, jobName); } else { result = printLibrary.Print(tbFileName.Text, _printerSettings, tbPassword.Text, jobName); } } else { if (cbUseWatermark.Checked) { result = printLibrary.Print(tbFileName.Text, tbPassword.Text, _watermark, jobName); } else { result = printLibrary.Print(tbFileName.Text, tbPassword.Text, jobName); } } } else { if (cbUsePrinterSettings.Checked) { if (cbUseWatermark.Checked) { result = printLibrary.Print(PdfPrintTest.GetStream(tbFileName.Text), _printerSettings, tbPassword.Text, tbDocumentName.Text, _watermark); } else { result = printLibrary.Print(PdfPrintTest.GetStream(tbFileName.Text), _printerSettings, tbPassword.Text, tbDocumentName.Text); } } else { if (cbUseWatermark.Checked) { result = printLibrary.Print(PdfPrintTest.GetStream(tbFileName.Text), tbPassword.Text, tbDocumentName.Text, _watermark); } else { result = printLibrary.Print(PdfPrintTest.GetStream(tbFileName.Text), tbPassword.Text, tbDocumentName.Text); } } } if (result == PdfPrint.Status.OK) { MessageBox.Show("Done successfully."); } else { MessageBox.Show("Error. " + PdfPrintTest.DecodeStatusCode(result)); } }