-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable PDF files in preview pane (#9088)
## Summary of the Pull Request This PR enables user to preview PDF files in the Explorer preview pane and in Outlook. **What is this about:** Windows does not support out of the box experience for previewing PDF files in the preview pane. Users need to install third-party software like Adobe Acrobat reader. The PdfPreviewHandler module enbales the user to preview PDF files. **How does someone test / validate:** Run the installer, open Explorer and select a PDF file, enable the preview pane. Maybe need to remove third-party PDF software. ## Quality Checklist - [X] **Linked issue:** #3548 - [ ] **Communication:** I've discussed this with core contributors in the issue. - [X] **Tests:** Added/updated and all pass - [X] **Installer:** Added/updated and all pass - [X] **Localization:** All end user facing strings can be localized - [ ] **Docs:** Added/ updated - [x] **Binaries:** Any new files are added to WXS / YML - [ ] No new binaries - [x] YML for signing - [x] WXS for installer
- Loading branch information
Showing
35 changed files
with
1,074 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1527,6 +1527,7 @@ PCWSTR | |
pdb | ||
pdbonly | ||
pdfpreviewhandler | ||
pdo | ||
pdto | ||
pdtobj | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"Projects": [ | ||
{ | ||
"LanguageSet": "Azure_Languages", | ||
"LocItems": [ | ||
{ | ||
"SourceFile": "src\\modules\\previewpane\\PdfPreviewHandler\\Properties\\Resources.resx", | ||
"CopyOption": "LangIDOnName", | ||
"OutputPath": "src\\modules\\previewpane\\PdfPreviewHandler\\Properties" | ||
} | ||
] | ||
} | ||
] | ||
} |
73 changes: 73 additions & 0 deletions
73
src/modules/previewpane/PdfPreviewHandler/PdfPreviewHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Copyright (c) Microsoft Corporation | ||
// The Microsoft Corporation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Runtime.InteropServices; | ||
using Common; | ||
using Microsoft.PowerToys.Telemetry; | ||
|
||
namespace Microsoft.PowerToys.PreviewHandler.Pdf | ||
{ | ||
/// <summary> | ||
/// Implementation of preview handler for pdf files. | ||
/// </summary> | ||
[Guid("07665729-6243-4746-95b7-79579308d1b2")] | ||
[ClassInterface(ClassInterfaceType.None)] | ||
[ComVisible(true)] | ||
public class PdfPreviewHandler : StreamBasedPreviewHandler, IDisposable | ||
{ | ||
private PdfPreviewHandlerControl _pdfPreviewHandlerControl; | ||
private bool _disposedValue; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="PdfPreviewHandler"/> class. | ||
/// </summary> | ||
public PdfPreviewHandler() | ||
{ | ||
Initialize(); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override void DoPreview() | ||
{ | ||
_pdfPreviewHandlerControl.DoPreview(Stream); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override IPreviewHandlerControl CreatePreviewHandlerControl() | ||
{ | ||
PowerToysTelemetry.Log.WriteEvent(new Telemetry.Events.PdfFileHandlerLoaded()); | ||
_pdfPreviewHandlerControl = new PdfPreviewHandlerControl(); | ||
|
||
return _pdfPreviewHandlerControl; | ||
} | ||
|
||
/// <summary> | ||
/// Disposes objects | ||
/// </summary> | ||
/// <param name="disposing">Is Disposing</param> | ||
protected virtual void Dispose(bool disposing) | ||
{ | ||
if (!_disposedValue) | ||
{ | ||
if (disposing) | ||
{ | ||
_pdfPreviewHandlerControl.Dispose(); | ||
} | ||
|
||
// TODO: free unmanaged resources (unmanaged objects) and override finalizer | ||
// TODO: set large fields to null | ||
_disposedValue = true; | ||
} | ||
} | ||
|
||
/// <inheritdoc /> | ||
public void Dispose() | ||
{ | ||
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method | ||
Dispose(disposing: true); | ||
GC.SuppressFinalize(this); | ||
} | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
src/modules/previewpane/PdfPreviewHandler/PdfPreviewHandler.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"> | ||
<PropertyGroup> | ||
<Platforms>x64</Platforms> | ||
<UseWindowsForms>true</UseWindowsForms> | ||
<AssemblyTitle>PdfPreviewHandler</AssemblyTitle> | ||
<AssemblyDescription>PowerToys PdfPreviewHandler</AssemblyDescription> | ||
<AssemblyCompany>Microsoft Corp.</AssemblyCompany> | ||
<AssemblyCopyright>Copyright (C) 2020 Microsoft Corporation</AssemblyCopyright> | ||
<AssemblyProduct>PowerToys</AssemblyProduct> | ||
<AssemblyTitle>PdfPreviewHandler</AssemblyTitle> | ||
<Company>Microsoft Corp.</Company> | ||
<Product>PowerToys</Product> | ||
<NeutralLanguage>en-US</NeutralLanguage> | ||
<Description>PowerToys PdfPreviewHandler</Description> | ||
<Copyright>Copyright (C) 2020 Microsoft Corporation</Copyright> | ||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
<DocumentationFile>$(SolutionDir)$(Platform)\$(Configuration)\modules\FileExplorerPreview\PdfPreviewPaneDocumentation.xml</DocumentationFile> | ||
<OutputPath>$(SolutionDir)$(Platform)\$(Configuration)\modules\FileExplorerPreview\</OutputPath> | ||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> | ||
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath> | ||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<ProjectGuid>{69E1EE8D-143A-4060-9129-4658ACF14AAF}</ProjectGuid> | ||
<RootNamespace>Microsoft.PowerToys.PreviewHandler.Pdf</RootNamespace> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
<EnableComHosting>true</EnableComHosting> | ||
<IntermediateOutputPath>$(SolutionDir)$(Platform)\$(Configuration)\obj\$(AssemblyName)\</IntermediateOutputPath> | ||
</PropertyGroup> | ||
|
||
<Import Project="..\..\..\Version.props" /> | ||
|
||
<ItemGroup> | ||
<Compile Include="..\..\..\codeAnalysis\GlobalSuppressions.cs" Link="GlobalSuppressions.cs" /> | ||
<Compile Update="PdfPreviewHandlerControl.cs" /> | ||
<Compile Update="Properties\Resources.Designer.cs"> | ||
<AutoGen>True</AutoGen> | ||
<DesignTime>True</DesignTime> | ||
<DependentUpon>Resources.resx</DependentUpon> | ||
</Compile> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.0"> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118"> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="System.IO.Abstractions" Version="12.2.5" /> | ||
<PackageReference Include="System.Runtime.WindowsRuntime" Version="4.7.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<AdditionalFiles Include="..\..\..\codeAnalysis\StyleCop.json"> | ||
<Link>StyleCop.json</Link> | ||
</AdditionalFiles> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\..\common\ManagedTelemetry\Telemetry\ManagedTelemetry.csproj" /> | ||
<ProjectReference Include="..\common\PreviewHandlerCommon.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Reference Include="Windows"> | ||
<HintPath>$(MSBuildProgramFiles32)\Windows Kits\10\UnionMetadata\10.0.17134.0\Windows.winmd</HintPath> | ||
<IsWinMDFile>true</IsWinMDFile> | ||
</Reference> | ||
</ItemGroup> | ||
</Project> |
Oops, something went wrong.