/////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance"). // All rights reserved. // // This software and its documentation and related materials are owned by // the Alliance. The software may only be incorporated into application // programs owned by members of the Alliance, subject to a signed // Membership Agreement and Supplemental Software License Agreement with the // Alliance. The structure and organization of this software are the valuable // trade secrets of the Alliance and its suppliers. The software is also // protected by copyright law and international treaty provisions. Application // programs incorporating this software must include the following statement // with their copyright notices: // // This application incorporates Open Design Alliance software pursuant to a license // agreement with Open Design Alliance. // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance. // All rights reserved. // // By use of this software, its documentation or related materials, you // acknowledge and accept the above terms. /////////////////////////////////////////////////////////////////////////////// // CustomPDFPropertiesDialog.cpp : implementation file // #include "stdafx.h" #include "CustomPDFPropertiesDialog.h" #include "PlotStampWMarkDialog.h" using namespace TD_PDF_2D_EXPORT; CCustomPDFPropertiesDialog::CCustomPDFPropertiesDialog(AuxPdfProps& props, CWnd* pParent /*=NULL*/) : CDialog(CCustomPDFPropertiesDialog::IDD, pParent) , m_iPageCount(props.iPageCount) , m_piHatchDPI(props.piHatchDPI) , m_piGeomDPI(props.piGeomDPI) , m_piBWImagesDPI(props.piBWImagesDPI) , m_piColorImagesDPI(props.piColorImagesDPI) , m_piDCTQuality(props.piDCTQuality) , m_piPdfAMode(props.piPdfAMode) , m_piShadedVpMode(props.piShadedVpMode) , m_bMergeLinesCrossing(props.pbMergeLines) , m_bCropImages(props.pbCropImages) , m_bDCTCompression(props.pbDCTCompression) , m_bDCTCompressionShadedVp(props.pbDCTCompressionShadedVp) , m_bMeasuring(props.pbMeasuring) , m_bMeasuringGeo(props.pbMeasuringGeo) , m_bForceDisableGsDevice(props.pbForceDisableGsDevice) , m_bTranspBgForShadedViewports(props.pbTranspBgForShadedViewports) , m_bSearchTextOnShadedVp(props.pbSearchTextOnShadedVp) , m_bUpscaleImages(props.pbUpscaleImages) , m_bUseGsCache(props.pbUseGsCache) , m_bUseMTVectorization(props.pbUseMTVectorization) , m_bUsePdfBlocks(props.pbUsePdfBlocks) , m_bXRefsAsPdfBlocks(props.pbXRefsAsPdfBlocks) , m_bBookmarks(props.pbBookmarks) , m_bMonoImagesAsMask(props.pbMonoImagesAsMask) , m_bDPI720(props.pbDPI720) , m_bStopOnError(props.pbStopOnError) , m_bEmulateDbWrappers(props.pbEmulateDbWrappers) , m_WatermarksArray(props.watermarksArray) { } CCustomPDFPropertiesDialog::~CCustomPDFPropertiesDialog() { } void CCustomPDFPropertiesDialog::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Text(pDX, IDC_EDIT_HATCH_DPI, *m_piHatchDPI); DDX_Text(pDX, IDC_EDIT_GEOM_DPI, *m_piGeomDPI); DDX_Text(pDX, IDC_EDIT_COLOR_IMAGES_DPI, *m_piColorImagesDPI); DDX_Text(pDX, IDC_EDIT_BW_IMAGES_DPI, *m_piBWImagesDPI); DDX_Check(pDX, IDC_CROP, *m_bCropImages); DDX_Check(pDX, IDC_DCT, *m_bDCTCompression); DDX_Check(pDX, IDC_DCT_SHADED_VP, *m_bDCTCompressionShadedVp); DDX_Check(pDX, IDC_MEASURING, *m_bMeasuring); DDX_Check(pDX, IDC_CHECK_GEO_MEASURE, *m_bMeasuringGeo); DDX_Check(pDX, IDC_DISABLE_GS, *m_bForceDisableGsDevice); DDX_Check(pDX, IDC_TRANSPARENT_BG, *m_bTranspBgForShadedViewports); DDX_Check(pDX, IDC_SEARCHABLE_TXT_ON_SHADED_VP, *m_bSearchTextOnShadedVp); DDX_Check(pDX, IDC_UPSCALE_IMAGES, *m_bUpscaleImages); DDX_Check(pDX, IDC_USE_GS_CACHE, *m_bUseGsCache); DDX_Check(pDX, IDC_PDF_EXPORT_USE_MT_VECT, *m_bUseMTVectorization); DDX_Check(pDX, IDC_USE_PDF_BLOCKS, *m_bUsePdfBlocks); DDX_Check(pDX, IDC_XREFS_AS_PDF_BLOCKS, *m_bXRefsAsPdfBlocks); DDX_Check(pDX, IDC_CHECK_BOOKMARKS, *m_bBookmarks); DDX_Check(pDX, IDC_MONO_IMAGES_AS_MASK, *m_bMonoImagesAsMask); DDX_Check(pDX, IDC_CHECK_DPI720, *m_bDPI720); DDX_Check(pDX, IDC_CHECK_STOP_ON_ERROR, *m_bStopOnError); DDX_Check(pDX, IDC_CHECK_DBWRAPPERS, *m_bEmulateDbWrappers); DDX_Control(pDX, IDC_COMBO_MERGE_CONTROL, m_comboMergeControl); DDX_Control(pDX, IDC_COMBO_SHADED_VP_HANDLE, m_comboShadedVpMode); DDX_Control(pDX, IDC_COMBO_PDF_A, m_comboPDFAmode); } BEGIN_MESSAGE_MAP(CCustomPDFPropertiesDialog, CDialog) ON_BN_CLICKED(IDOK, OnOk) ON_BN_CLICKED(IDC_DCT, OnCheckDCTCompression) ON_BN_CLICKED(IDC_CHECK_DPI720, OnCheckDPI720) ON_BN_CLICKED(IDC_USE_GS_CACHE, OnCheckGsCache) ON_BN_CLICKED(IDC_USE_PDF_BLOCKS, OnCheckPdfBlocks) ON_BN_CLICKED(IDC_MEASURING, OnCheckMeasuring) ON_BN_CLICKED(IDC_BUTTON_WMARK, &CCustomPDFPropertiesDialog::OnBnClickedButtonWmark) ON_BN_CLICKED(IDC_BUTTON_CLEAR_WMARKS, &CCustomPDFPropertiesDialog::OnBnClickedButtonClearWmarks) END_MESSAGE_MAP() void CCustomPDFPropertiesDialog::OnCheckDCTCompression() { UpdateData(TRUE); GetDlgItem(IDC_SLIDER_QUALITY)->EnableWindow(*m_bDCTCompression); GetDlgItem(IDC_STATIC_IQ)->EnableWindow(*m_bDCTCompression); GetDlgItem(IDC_DCT_SHADED_VP)->EnableWindow(*m_bDCTCompression); UpdateData(FALSE); // save and validate } void CCustomPDFPropertiesDialog::OnCheckDPI720() { UpdateData(TRUE); GetDlgItem(IDC_EDIT_GEOM_DPI)->EnableWindow(!*m_bDPI720); UpdateData(FALSE); // save and validate } void CCustomPDFPropertiesDialog::OnCheckGsCache() { UpdateData(TRUE); GetDlgItem(IDC_USE_PDF_BLOCKS)->EnableWindow(*m_bUseGsCache); GetDlgItem(IDC_XREFS_AS_PDF_BLOCKS)->EnableWindow(*m_bUseGsCache && *m_bUsePdfBlocks); GetDlgItem(IDC_PDF_EXPORT_USE_MT_VECT)->EnableWindow(*m_bUseGsCache); UpdateData(FALSE); // save and validate } void CCustomPDFPropertiesDialog::OnCheckPdfBlocks() { UpdateData(TRUE); GetDlgItem(IDC_XREFS_AS_PDF_BLOCKS)->EnableWindow(*m_bUsePdfBlocks); UpdateData(FALSE); // save and validate } void CCustomPDFPropertiesDialog::OnCheckMeasuring() { UpdateData(TRUE); GetDlgItem(IDC_CHECK_GEO_MEASURE)->EnableWindow(*m_bMeasuring); UpdateData(FALSE); // save and validate } // CCustomPDFPropertiesDialog message handlers BOOL CCustomPDFPropertiesDialog::OnInitDialog() { if (!CDialog::OnInitDialog()) return FALSE; CSliderCtrl* pSlider = ((CSliderCtrl*)GetDlgItem(IDC_SLIDER_QUALITY)); pSlider->SetRange(10, 100); pSlider->SetPos(*m_piDCTQuality); pSlider->SetTicFreq(1); m_comboMergeControl.ResetContent(); m_comboMergeControl.InsertString(0, _T("Lines Overwrite")); m_comboMergeControl.InsertString(1, _T("Lines Merge")); m_comboMergeControl.SetCurSel(*m_bMergeLinesCrossing); m_comboPDFAmode.ResetContent(); m_comboPDFAmode.InsertString(0, _T("None")); m_comboPDFAmode.InsertString(1, _T("PDF/A-1b")); m_comboPDFAmode.InsertString(2, _T("PDF/A-2b (Recommended for archiving)")); m_comboPDFAmode.InsertString(3, _T("PDF/A-3b")); m_comboPDFAmode.SetCurSel(*m_piPdfAMode <= 3 ? *m_piPdfAMode : 0); m_comboShadedVpMode.ResetContent(); m_comboShadedVpMode.InsertString(0, _T("One-piece picture")); m_comboShadedVpMode.InsertString(1, _T("Tiled picture (hi-res)")); m_comboShadedVpMode.InsertString(2, _T("Striped picture (hi-res)")); m_comboShadedVpMode.SetCurSel(*m_piShadedVpMode); GetDlgItem(IDC_USE_PDF_BLOCKS)->EnableWindow(*m_bUseGsCache); GetDlgItem(IDC_XREFS_AS_PDF_BLOCKS)->EnableWindow(*m_bUseGsCache && *m_bUsePdfBlocks); GetDlgItem(IDC_PDF_EXPORT_USE_MT_VECT)->EnableWindow(*m_bUseGsCache); GetDlgItem(IDC_CHECK_GEO_MEASURE)->EnableWindow(*m_bMeasuring); //Make it invisible GetDlgItem(IDC_CHECK_DBWRAPPERS)->ShowWindow(SW_HIDE); if (m_WatermarksArray.isEmpty()) GetDlgItem(IDC_BUTTON_CLEAR_WMARKS)->ShowWindow(FALSE); CString WMarkCount; WMarkCount.Format(_T("Total plotstamps/watermarks count: %i"), m_WatermarksArray.size()); GetDlgItem(IDC_STATIC_WMARK_COUNT)->SetWindowText(WMarkCount); UpdateData(FALSE); return TRUE; } void CCustomPDFPropertiesDialog::OnOk() { UpdateData(TRUE); bool bWrongData = false; if (*m_piGeomDPI < 72) *m_piGeomDPI = 72; if (*m_piGeomDPI > 40000) *m_piGeomDPI = 40000; if (*m_piHatchDPI < 72) *m_piHatchDPI = 72; if (*m_piHatchDPI > *m_piGeomDPI) *m_piHatchDPI = *m_piGeomDPI; if (*m_piColorImagesDPI < 72) *m_piColorImagesDPI = 72; if (*m_piColorImagesDPI > *m_piGeomDPI) { bWrongData = true; *m_piColorImagesDPI = *m_piGeomDPI; } if (*m_piBWImagesDPI < 72) *m_piBWImagesDPI = 72; if (*m_piBWImagesDPI > *m_piGeomDPI) { bWrongData = true; *m_piBWImagesDPI = *m_piGeomDPI; } if(!*m_bUseGsCache) *m_bXRefsAsPdfBlocks = *m_bUsePdfBlocks = *m_bUseMTVectorization = false; if(!*m_bUsePdfBlocks) *m_bXRefsAsPdfBlocks = false; *m_piDCTQuality = ((CSliderCtrl*)GetDlgItem(IDC_SLIDER_QUALITY))->GetPos(); switch (m_comboMergeControl.GetCurSel()) { case 0: *m_bMergeLinesCrossing = FALSE; break; case 1: //Merge Lines *m_bMergeLinesCrossing = TRUE; break; } *m_piPdfAMode = m_comboPDFAmode.GetCurSel(); *m_piShadedVpMode = m_comboShadedVpMode.GetCurSel(); if (bWrongData) { ::MessageBox(NULL, _T("Raster resolution cannot exceed the current vector resolution settings."), _T("Resolution reset"), MB_OK); UpdateData(FALSE); } else CDialog::OnOK(); } void CCustomPDFPropertiesDialog::OnBnClickedButtonWmark() { TD_PDF_2D_EXPORT::Watermark watermark; PlotStampWMarkDialog dlgWmark(&watermark, m_iPageCount, this); if(dlgWmark.DoModal() == IDOK && (!watermark.text.isEmpty() || !watermark.imagePath.isEmpty())) m_WatermarksArray.append(watermark); if(!m_WatermarksArray.isEmpty()) GetDlgItem(IDC_BUTTON_CLEAR_WMARKS)->ShowWindow(TRUE); CString WMarkCount; WMarkCount.Format(_T("Total plotstamps/watermarks count: %i"), m_WatermarksArray.size()); GetDlgItem(IDC_STATIC_WMARK_COUNT)->SetWindowText(WMarkCount); } void CCustomPDFPropertiesDialog::OnBnClickedButtonClearWmarks() { m_WatermarksArray.clear(); GetDlgItem(IDC_BUTTON_CLEAR_WMARKS)->ShowWindow(FALSE); GetDlgItem(IDC_STATIC_WMARK_COUNT)->SetWindowText(_T("Total plotstamps/watermarks count: 0")); }