Skip to content

Commit

Permalink
Use images instead of pdf files for printing when viewer type is png …
Browse files Browse the repository at this point in the history
…or jpeg
  • Loading branch information
vladimir-litvinchik committed Sep 6, 2024
1 parent d5e8951 commit 0c0de57
Show file tree
Hide file tree
Showing 14 changed files with 332 additions and 30 deletions.
15 changes: 15 additions & 0 deletions GroupDocs.Viewer.UI.sln
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GroupDocs.Viewer.UI.Sample.CrossPlatform", "samples\GroupDocs.Viewer.UI.Sample.CrossPlatform\GroupDocs.Viewer.UI.Sample.CrossPlatform.csproj", "{A13FA861-68E3-4478-9698-1061C62C0CE6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GroupDocs.Viewer.UI.Sample.ViewAsPng", "samples\GroupDocs.Viewer.UI.Sample.ViewAsPng\GroupDocs.Viewer.UI.Sample.ViewAsPng.csproj", "{47CB008B-A0D8-46AD-A643-0D9651199CBD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -272,6 +274,18 @@ Global
{A13FA861-68E3-4478-9698-1061C62C0CE6}.Release|x64.Build.0 = Release|Any CPU
{A13FA861-68E3-4478-9698-1061C62C0CE6}.Release|x86.ActiveCfg = Release|Any CPU
{A13FA861-68E3-4478-9698-1061C62C0CE6}.Release|x86.Build.0 = Release|Any CPU
{47CB008B-A0D8-46AD-A643-0D9651199CBD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{47CB008B-A0D8-46AD-A643-0D9651199CBD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{47CB008B-A0D8-46AD-A643-0D9651199CBD}.Debug|x64.ActiveCfg = Debug|Any CPU
{47CB008B-A0D8-46AD-A643-0D9651199CBD}.Debug|x64.Build.0 = Debug|Any CPU
{47CB008B-A0D8-46AD-A643-0D9651199CBD}.Debug|x86.ActiveCfg = Debug|Any CPU
{47CB008B-A0D8-46AD-A643-0D9651199CBD}.Debug|x86.Build.0 = Debug|Any CPU
{47CB008B-A0D8-46AD-A643-0D9651199CBD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{47CB008B-A0D8-46AD-A643-0D9651199CBD}.Release|Any CPU.Build.0 = Release|Any CPU
{47CB008B-A0D8-46AD-A643-0D9651199CBD}.Release|x64.ActiveCfg = Release|Any CPU
{47CB008B-A0D8-46AD-A643-0D9651199CBD}.Release|x64.Build.0 = Release|Any CPU
{47CB008B-A0D8-46AD-A643-0D9651199CBD}.Release|x86.ActiveCfg = Release|Any CPU
{47CB008B-A0D8-46AD-A643-0D9651199CBD}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -296,6 +310,7 @@ Global
{CD2CFFFF-EC3B-4709-BCFD-FAE4B05D3769} = {F01C54A8-0505-4D3F-B12C-FEB3F827509E}
{09F5C6E7-90C5-4C0F-A7CC-45BBD70B1A2F} = {90B29C0F-7451-444C-B814-1B75EE88E1CB}
{A13FA861-68E3-4478-9698-1061C62C0CE6} = {98234968-D728-4D2D-B985-88A63DF6541A}
{47CB008B-A0D8-46AD-A643-0D9651199CBD} = {98234968-D728-4D2D-B985-88A63DF6541A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D7F2C427-C9AB-4B55-B1F9-C41195D7CD6C}
Expand Down
2 changes: 1 addition & 1 deletion build/dependencies.props
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</PropertyGroup>

<PropertyGroup Label="GroupDocs.Viewer UI Package Versions">
<GroupDocsViewerUI>6.0.19</GroupDocsViewerUI>
<GroupDocsViewerUI>6.0.20</GroupDocsViewerUI>
<GroupDocsViewerUIApi>6.0.9</GroupDocsViewerUIApi>
<GroupDocsViewerUIApiLocalCache>6.0.3</GroupDocsViewerUIApiLocalCache>
<GroupDocsViewerUIApiInMemoryCache>6.0.3</GroupDocsViewerUIApiInMemoryCache>
Expand Down
40 changes: 40 additions & 0 deletions samples/GroupDocs.Viewer.UI.Sample.ViewAsPng/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

RUN sed -i'.bak' 's/$/ contrib/' /etc/apt/sources.list
RUN apt update && apt install -y \
libgdiplus \
libc6-dev \
libx11-dev \
fontconfig \
ttf-mscorefonts-installer

RUN fc-cache -f -v

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["samples/GroupDocs.Viewer.UI.Sample.ViewAsPng/GroupDocs.Viewer.UI.Sample.ViewAsPng.csproj", "samples/GroupDocs.Viewer.UI.Sample.ViewAsPng/"]
COPY ["src/GroupDocs.Viewer.UI/GroupDocs.Viewer.UI.csproj", "src/GroupDocs.Viewer.UI/"]
COPY ["src/GroupDocs.Viewer.UI.Api/GroupDocs.Viewer.UI.Api.csproj", "src/GroupDocs.Viewer.UI.Api/"]
COPY ["src/GroupDocs.Viewer.UI.Core/GroupDocs.Viewer.UI.Core.csproj", "src/GroupDocs.Viewer.UI.Core/"]
COPY ["src/GroupDocs.Viewer.UI.Api.Local.Cache/GroupDocs.Viewer.UI.Api.Local.Cache.csproj", "src/GroupDocs.Viewer.UI.Api.Local.Cache/"]
COPY ["src/GroupDocs.Viewer.UI.Api.Local.Storage/GroupDocs.Viewer.UI.Api.Local.Storage.csproj", "src/GroupDocs.Viewer.UI.Api.Local.Storage/"]
COPY ["src/GroupDocs.Viewer.UI.SelfHost.Api/GroupDocs.Viewer.UI.SelfHost.Api.csproj", "src/GroupDocs.Viewer.UI.SelfHost.Api/"]
RUN dotnet restore "./samples/GroupDocs.Viewer.UI.Sample.ViewAsPng/GroupDocs.Viewer.UI.Sample.ViewAsPng.csproj"
COPY . .
WORKDIR "/src/samples/GroupDocs.Viewer.UI.Sample.ViewAsPng"
RUN dotnet build "./GroupDocs.Viewer.UI.Sample.ViewAsPng.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./GroupDocs.Viewer.UI.Sample.ViewAsPng.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "GroupDocs.Viewer.UI.Sample.ViewAsPng.dll"]
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>$(NetVersion)</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>ec7dd886-bc88-4c83-9991-a0d035628f15</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>..\..</DockerfileContext>
</PropertyGroup>

<ItemGroup>
<Compile Remove="wwwroot\**" />
<Content Remove="wwwroot\**" />
<EmbeddedResource Remove="wwwroot\**" />
<None Remove="wwwroot\**" />
<Compile Remove="Cache\**" />
<Compile Remove="Files\**" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\GroupDocs.Viewer.UI\GroupDocs.Viewer.UI.csproj" />
<ProjectReference Include="..\..\src\GroupDocs.Viewer.UI.Api\GroupDocs.Viewer.UI.Api.csproj" />
<ProjectReference Include="..\..\src\GroupDocs.Viewer.UI.Api.Local.Cache\GroupDocs.Viewer.UI.Api.Local.Cache.csproj" />
<ProjectReference Include="..\..\src\GroupDocs.Viewer.UI.Api.Local.Storage\GroupDocs.Viewer.UI.Api.Local.Storage.csproj" />
<ProjectReference Include="..\..\src\GroupDocs.Viewer.UI.SelfHost.Api\GroupDocs.Viewer.UI.SelfHost.Api.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.6" />
</ItemGroup>

<ItemGroup>
<Folder Include="Files\" />
</ItemGroup>

<ItemGroup>
<Folder Include="Cache\" />
</ItemGroup>

<ItemGroup>
<None Update="Files\password.pdf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\sample.docx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\sample.pdf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\sample.xlsx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\sample.pptx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup Label="runtimeconfig.json">
<RuntimeHostConfigurationOption Include="System.Drawing.EnableUnixSupport" Value="true" />
</ItemGroup>

</Project>
49 changes: 49 additions & 0 deletions samples/GroupDocs.Viewer.UI.Sample.ViewAsPng/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using GroupDocs.Viewer.UI.Core;

var builder = WebApplication.CreateBuilder(args);

ViewerType png = ViewerType.Png;

builder.Services
.AddGroupDocsViewerUI(config =>
{
//Preload first three pages
config.SetPreloadPageCount(3);
config.SetViewerType(png);
});

builder.Services
.AddControllers()
.AddGroupDocsViewerSelfHostApi(config =>
{
config.SetViewerType(png);
//Trial limitations https://docs.groupdocs.com/viewer/net/evaluation-limitations-and-licensing-of-groupdocs-viewer/
//Temporary license can be requested at https://purchase.groupdocs.com/temporary-license
//config.SetLicensePath("c:\\licenses\\GroupDocs.Viewer.lic"); // or set environment variable 'GROUPDOCS_LIC_PATH'
})
.AddLocalStorage("./Files")
.AddLocalCache("./Cache");

var app = builder.Build();

app
.UseRouting()
.UseEndpoints(endpoints =>
{
endpoints.MapGet("/", async context =>
{
await context.Response.WriteAsync("Viewer UI can be accessed at '/viewer' endpoint.");
});
endpoints.MapGroupDocsViewerUI(options =>
{
options.UIPath = "/viewer";
options.APIEndpoint = "/viewer-api";
});
endpoints.MapGroupDocsViewerApi(options =>
{
options.ApiPath = "/viewer-api";
});
});

app.Run();
9 changes: 9 additions & 0 deletions samples/GroupDocs.Viewer.UI.Sample.ViewAsPng/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
2 changes: 1 addition & 1 deletion src/GroupDocs.Viewer.UI/assets/main.js

Large diffs are not rendered by default.

28 changes: 17 additions & 11 deletions src/GroupDocs.Viewer.UI/client/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
# GroupdocsViewerUI
# Angular UI for GorupDocs.Viewer.UI

This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 11.2.3.
Building this app requires legacy tools that can be installed with `nvm`.

## Development server
### Prepare

Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
```bash
nvm install 14.15
nvm use 14.15.5
npm install -g @angular/[email protected]
npm install
```

## Code scaffolding
### Start dev server

Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
```bash
ng serve
```

## Build
### Build release packages

Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.
```bash
npm run build
```

## Further help

To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
Loading

0 comments on commit 0c0de57

Please sign in to comment.