Skip to content

Commit

Permalink
Fixed some documentation, added more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Kees committed May 4, 2022
1 parent 15a0c83 commit fe32ec1
Show file tree
Hide file tree
Showing 22 changed files with 107 additions and 53 deletions.
Binary file modified .vs/QPdfNet/DesignTimeBuild/.dtbcache.v2
Binary file not shown.
Binary file modified .vs/QPdfNet/v17/.suo
Binary file not shown.
6 changes: 6 additions & 0 deletions QPdfNet/Info/Pdf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ public class Pdf
#endregion

#region FromFile
/// <summary>
/// Returns a <c>Pdf</c> object with information about the given <paramref name="fileName"/>
/// </summary>
/// <param name="fileName"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public static Pdf? FromFile(string fileName)
{
Logger.LogInformation($"Getting information from PDF '{fileName}'");
Expand Down
61 changes: 32 additions & 29 deletions QPdfNet/Job.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public Job OutputFile(string fileName)
#region Empty
/// <summary>
/// This option may be given in place of infile. This causes qpdf to use a dummy input file that contains zero pages.
/// This option is useful in conjunction with <see cref="Pages"/>. See Page Selection for details.
/// This option is useful in conjunction with <see cref="Pages"/>. See <see cref="Pages"/> for details.
/// </summary>
/// <returns>
/// <see cref="Job" />
Expand All @@ -194,10 +194,10 @@ public Job Empty()

#region ReplaceInput
/// <summary>
/// This option may be given in place of outfile. This causes qpdf to replace the input file with the output.
/// It does this by writing to infilename.~qpdf-temp# and, when done, overwriting the input file with the temporary
/// file. If there were any warnings, the original input is saved as infilename.~qpdf-orig. If there are errors, the
/// input file is left untouched.
/// This option may be given in place of <see cref="OutputFile"/>. This causes qpdf to replace the <see cref="InputFile"/>
/// file with the <see cref="OutputFile"/>. It does this by writing to infilename. ~qpdf-temp# and, when done, overwriting
/// the <see cref="InputFile"/> with the temporary file. If there were any warnings, the original input is saved as infilename.
/// ~qpdf-orig. If there are errors, the <see cref="InputFile"/> is left untouched.
/// </summary>
/// <returns>
/// <see cref="Job" />
Expand All @@ -215,8 +215,9 @@ public Job ReplaceInput()

#region WarningExit0
/// <summary>
/// If there were warnings only and no errors, exit with exit code 0 instead of 3. When combined with
/// <see cref="NoWarn" />, the effect is for qpdf to completely ignore warnings.
/// If there were warnings only and no errors, exit with exit code <see cref="ExitCode.Success" /> instead of
/// <see cref="ExitCode.WarningsWereFoundFileProcessed" />. When combined with <see cref="NoWarn" />, the effect
/// is for qpdf to completely ignore warnings.
/// </summary>
/// <returns>
/// <see cref="Job" />
Expand Down Expand Up @@ -286,8 +287,9 @@ public Job Verbose()
#region NoWarn
/// <summary>
/// Suppress writing of warnings to stderr. If warnings were detected and suppressed, qpdf will still exit with exit
/// code 3. To completely ignore warnings, also specify <see cref="WarningExit0" />. Use with caution as qpdf is not
/// always successful in recovering from situations that cause warnings to be issued.
/// code <see cref="ExitCode.WarningsWereFoundFileProcessed" />. To completely ignore warnings, also specify
/// <see cref="WarningExit0" />. Use with caution as qpdf is not always successful in recovering from situations that
/// cause warnings to be issued.
/// </summary>
/// <returns>
/// <see cref="Job" />
Expand Down Expand Up @@ -393,13 +395,13 @@ public Job KeepFilesOpenThreshold(int count = 200)
/// Overrides the usual computation/retrieval of the PDF file’s encryption key from user/owner password with an
/// explicit specification of the encryption key. When this option is specified, the parameter to the
/// <see cref="Password" /> option is interpreted as a hexadecimal-encoded key value. This only applies to the password
/// used to open the main input file. It does not apply to other files opened by --pages or other options or to files
/// being written. Most users will never have a need for this option, and no standard viewers support this mode of
/// operation, but it can be useful for forensic or investigatory purposes. For example, if a PDF file is encrypted with
/// an unknown password, a brute-force attack using the key directly is sometimes more efficient than one using the
/// password.Also, if a file is heavily damaged, it may be possible to derive the encryption key and recover parts of
/// the file using it directly.To expose the encryption key used by an encrypted file that you can open normally, use
/// the <see cref="ShowEncryptionKey" /> option.
/// used to open the main input file. It does not apply to other files opened by <see cref="Pages"/> or other options
/// or to files being written. Most users will never have a need for this option, and no standard viewers support this
/// mode of operation, but it can be useful for forensic or investigatory purposes. For example, if a PDF file is
/// encrypted with an unknown password, a brute-force attack using the key directly is sometimes more efficient than
/// one using the password.Also, if a file is heavily damaged, it may be possible to derive the encryption key and
/// recover parts of the file using it directly.To expose the encryption key used by an encrypted file that you can open
/// normally, use the <see cref="ShowEncryptionKey" /> option.
/// </summary>
/// <returns>
/// <see cref="Job" />
Expand Down Expand Up @@ -486,9 +488,10 @@ public Job IgnoreXrefStreams()

#region Linearize
/// <summary>
/// Create linearized (web-optimized) output files. Linearized files are formatted in a way that allows compliant
/// readers to begin displaying a PDF file before it is fully downloaded. Ordinarily, the entire file must be present
/// before it can be rendered because important cross-reference information typically appears at the end of the file.
/// Create linearized (web-optimized) <see cref="OutputFile"/>s. Linearized files are formatted in a way that allows
/// compliant readers to begin displaying a PDF file before it is fully downloaded. Ordinarily, the entire file must
/// be present before it can be rendered because important cross-reference information typically appears at the end
/// of the file.
/// </summary>
/// <returns>
/// <see cref="Job" />
Expand Down Expand Up @@ -520,10 +523,10 @@ public Job Encrypt(string? userPassword, string ownerPassword, IEncryption optio

#region Decrypt
/// <summary>
/// Create an output file with no encryption even if the input file is encrypted. This option overrides the default
/// behavior of preserving whatever encryption was present on the input file. This functionality is not intended to be
/// used for bypassing copyright restrictions or other restrictions placed on files by their producers. See also
/// <see cref="CopyEncryption"/>.
/// Create an <see cref="OutputFile"/> with no encryption even if the input file is encrypted. This option overrides
/// the default behavior of preserving whatever encryption was present on the <see cref="InputFile"/>. This functionality
/// is not intended to be used for bypassing copyright restrictions or other restrictions placed on files by their producers.
/// See also <see cref="CopyEncryption"/>.
/// </summary>
/// <returns>
/// <see cref="Job" />
Expand Down Expand Up @@ -1598,12 +1601,12 @@ public Job RequiresPassword()
#region Check
/// <summary>
/// Check the file’s structure as well as encryption, linearization, and encoding of stream data, and write information
/// about the file to standard output. An exit status of 0 indicates syntactic correctness of the PDF file. Note that
/// <see cref="Check" /> writes nothing to standard error when everything is valid, so if you are using this to
/// programmatically validate files in bulk, it is safe to run without output redirected to /dev/null and just check
/// for a 0 exit code. A file for which <see cref="Check" /> reports no errors may still have errors in stream data
/// content or may contain constructs that don’t conform to the PDF specification, but it should be syntactically
/// valid. If <see cref="Check" /> reports any errors, qpdf will exit with a status of
/// about the file to standard output. An exit status of <see cref="ExitCode.Success" /> indicates syntactic correctness
/// of the PDF file. Note that <see cref="Check" /> writes nothing to standard error when everything is valid, so if you
/// are using this to programmatically validate files in bulk, it is safe to run without output redirected to /dev/null
/// and just check for a <see cref="ExitCode.Success" />. A file for which <see cref="Check" /> reports no errors may
/// still have errors in stream data content or may contain constructs that don’t conform to the PDF specification, but
/// it should be syntactically valid. If <see cref="Check" /> reports any errors, qpdf will exit with a status of
/// <see cref="ExitCode.ErrorsFoundFileNotProcessed" />. There are some recoverable conditions that <see cref="Check" />
/// detects. These are issued as warnings instead of errors. If qpdf finds no errors but finds warnings, it will exit
/// with a status of <see cref="ExitCode.WarningsWereFoundFileProcessed" />. When <see cref="Check" /> is combined with
Expand Down
2 changes: 2 additions & 0 deletions QPdfNet/Output/CheckInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public class CheckInfo
public bool HasWarnings => Warnings?.Count > 0;
#endregion

#region Constructor
/// <summary>
/// Makes this object and sets all it's needed properties
/// </summary>
Expand Down Expand Up @@ -89,6 +90,7 @@ internal CheckInfo(string? output)
}
}
}
#endregion

#region GetValue
private string GetValue(char splitChar, string line)
Expand Down
6 changes: 6 additions & 0 deletions QPdfNet/Output/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

using System;
using System.Collections.Generic;
using QPdfNet.Loggers;

namespace QPdfNet.Output;

Expand All @@ -43,6 +44,8 @@ public static class Helper
/// <returns>A list with attachment names</returns>
public static List<string> ParseListAttachments(string? output)
{
Logger.LogInformation("Parsing output from 'Job.ListAttachments' method");

var result = new List<string>();

if (output == null)
Expand All @@ -69,6 +72,7 @@ public static List<string> ParseListAttachments(string? output)
/// <returns><see cref="EncryptionInfo"/></returns>
public static EncryptionInfo ParseShowEncryption(string? output)
{
Logger.LogInformation("Parsing output from 'Job.ShowEncryption' or 'Job.ShowEncryptionKey' method");
output ??= string.Empty;
return new EncryptionInfo(output);
}
Expand All @@ -82,6 +86,7 @@ public static EncryptionInfo ParseShowEncryption(string? output)
/// <returns><see cref="XrefInfos"/></returns>
public static XrefInfos ParseShowXref(string? output)
{
Logger.LogInformation("Parsing output from 'Job.ParseShowXRef' method");
output ??= string.Empty;
return new XrefInfos(output);
}
Expand All @@ -95,6 +100,7 @@ public static XrefInfos ParseShowXref(string? output)
/// <returns><see cref="CheckInfo"/></returns>
public static CheckInfo ParseCheck(string? output)
{
Logger.LogInformation("Parsing output from 'Job.Check' method");
output ??= string.Empty;
return new CheckInfo(output);
}
Expand Down
6 changes: 3 additions & 3 deletions QPdfNet/QPdfNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
<PackageReadmeFile>readme.md</PackageReadmeFile>
<Copyright>Copyright (c) 2021-2022 Kees van Spelde</Copyright>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<AssemblyVersion>1.0.4.0</AssemblyVersion>
<FileVersion>1.0.4.0</FileVersion>
<Version>1.0.4</Version>
<AssemblyVersion>1.0.5.0</AssemblyVersion>
<FileVersion>1.0.5.0</FileVersion>
<Version>1.0.5</Version>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
<NoWarn>$(NoWarn);1591</NoWarn>
</PropertyGroup>
Expand Down
Binary file added QPdfNet/bin/Release/QPdfNet.1.0.4.nupkg
Binary file not shown.
4 changes: 2 additions & 2 deletions QPdfNet/bin/Release/netstandard2.1/QPdfNet.deps.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"targets": {
".NETStandard,Version=v2.1": {},
".NETStandard,Version=v2.1/": {
"QPdfNet/1.0.3": {
"QPdfNet/1.0.4": {
"dependencies": {
"Microsoft.Extensions.Logging": "6.0.0",
"Newtonsoft.Json": "13.0.1"
Expand Down Expand Up @@ -147,7 +147,7 @@
}
},
"libraries": {
"QPdfNet/1.0.3": {
"QPdfNet/1.0.4": {
"type": "project",
"serviceable": false,
"sha512": ""
Expand Down
2 changes: 1 addition & 1 deletion QPdfNet/obj/QPdfNet.csproj.nuget.dgspec.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"projects": {
"C:\\Kees\\QPdfNet\\QPdfNet\\QPdfNet.csproj": {
"version": "1.0.4",
"version": "1.0.5",
"restore": {
"projectUniqueName": "C:\\Kees\\QPdfNet\\QPdfNet\\QPdfNet.csproj",
"projectName": "QPdfNet",
Expand Down
37 changes: 37 additions & 0 deletions QPdfNet/obj/Release/QPdfNet.1.0.4.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>QPdfNet</id>
<version>1.0.4</version>
<authors>QPdfNet</authors>
<icon>qpdf.png</icon>
<readme>readme.md</readme>
<projectUrl>https://github.com/Sicos1977/QPdfNet</projectUrl>
<description>A C# wrapper around QPDF that gives you all the options that you normally would have from the QPDF console app</description>
<releaseNotes>Added Pdf class and helper methods to parse output that is returned by some methods, also target .net 4.6.2</releaseNotes>
<copyright>Copyright (c) 2021-2022 Kees van Spelde</copyright>
<tags>qpdf pdf</tags>
<repository type="git" url="https://github.com/Sicos1977/QPdfNet" />
<dependencies>
<group targetFramework=".NETFramework4.6.2">
<dependency id="Microsoft.Extensions.Logging" version="6.0.0" exclude="Build,Analyzers" />
<dependency id="Newtonsoft.Json" version="13.0.1" exclude="Build,Analyzers" />
</group>
<group targetFramework=".NETStandard2.1">
<dependency id="Microsoft.Extensions.Logging" version="6.0.0" exclude="Build,Analyzers" />
<dependency id="Newtonsoft.Json" version="13.0.1" exclude="Build,Analyzers" />
</group>
</dependencies>
</metadata>
<files>
<file src="C:\Kees\QPdfNet\QPdfNet\bin\Release\net462\QPdfNet.dll" target="lib\net462\QPdfNet.dll" />
<file src="C:\Kees\QPdfNet\QPdfNet\bin\Release\net462\QPdfNet.xml" target="lib\net462\QPdfNet.xml" />
<file src="C:\Kees\QPdfNet\QPdfNet\bin\Release\netstandard2.1\QPdfNet.dll" target="lib\netstandard2.1\QPdfNet.dll" />
<file src="C:\Kees\QPdfNet\QPdfNet\bin\Release\netstandard2.1\QPdfNet.xml" target="lib\netstandard2.1\QPdfNet.xml" />
<file src="C:\Kees\QPdfNet\QPdfNet\x64\qpdf29.dll" target="x64\qpdf29.dll" />
<file src="C:\Kees\QPdfNet\QPdfNet\x64\qpdf29.dll" target="lib\qpdf29.dll" />
<file src="C:\Kees\QPdfNet\QPdfNet\x86\qpdf29.dll" target="x86\qpdf29.dll" />
<file src="C:\Kees\QPdfNet\QPdfNet\qpdf.png" target="\qpdf.png" />
<file src="C:\Kees\QPdfNet\QPdfNet\readme.md" target="\readme.md" />
</files>
</package>
6 changes: 3 additions & 3 deletions QPdfNet/obj/Release/net462/QPdfNet.AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
[assembly: System.Reflection.AssemblyCopyrightAttribute("Copyright (c) 2021-2022 Kees van Spelde")]
[assembly: System.Reflection.AssemblyDescriptionAttribute("A C# wrapper around QPDF that gives you all the options that you normally would h" +
"ave from the QPDF console app")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.4.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.4")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.5.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.5")]
[assembly: System.Reflection.AssemblyProductAttribute("QPdfNet")]
[assembly: System.Reflection.AssemblyTitleAttribute("QPdfNet")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.4.0")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.5.0")]
[assembly: System.Reflection.AssemblyMetadataAttribute("RepositoryUrl", "https://github.com/Sicos1977/QPdfNet")]

// Generated by the MSBuild WriteCodeFragment class.
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16755749b01d13404506cbfde64bab4ccec9f869
6765686cfefe38791a2015a547831db52f934aa9
6 changes: 3 additions & 3 deletions QPdfNet/obj/Release/netstandard2.1/QPdfNet.AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
[assembly: System.Reflection.AssemblyCopyrightAttribute("Copyright (c) 2021-2022 Kees van Spelde")]
[assembly: System.Reflection.AssemblyDescriptionAttribute("A C# wrapper around QPDF that gives you all the options that you normally would h" +
"ave from the QPDF console app")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.4.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.4")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.5.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.5")]
[assembly: System.Reflection.AssemblyProductAttribute("QPdfNet")]
[assembly: System.Reflection.AssemblyTitleAttribute("QPdfNet")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.4.0")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.5.0")]
[assembly: System.Reflection.AssemblyMetadataAttribute("RepositoryUrl", "https://github.com/Sicos1977/QPdfNet")]

// Generated by the MSBuild WriteCodeFragment class.
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16755749b01d13404506cbfde64bab4ccec9f869
6765686cfefe38791a2015a547831db52f934aa9
2 changes: 1 addition & 1 deletion QPdfNet/obj/project.assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder": {}
},
"project": {
"version": "1.0.4",
"version": "1.0.5",
"restore": {
"projectUniqueName": "C:\\Kees\\QPdfNet\\QPdfNet\\QPdfNet.csproj",
"projectName": "QPdfNet",
Expand Down
2 changes: 1 addition & 1 deletion QPdfNet/obj/project.nuget.cache
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": 2,
"dgSpecHash": "bFibWW1bQ3QIDiph8Z1k7Rc6YL/GZt/+vlnel46cma1r/rAktDbPiuYq7s6vGnMJIoHPv+oP2v/8f+gKuW3TIg==",
"dgSpecHash": "5qd3Hm7COyZBz1wJ1+R0MSDiXU47YepadapbyjTMeFbs9qKTbyCW124VCHdXNCypdxf9FxeDXGEOJS6+tU643Q==",
"success": true,
"projectFilePath": "C:\\Kees\\QPdfNet\\QPdfNet\\QPdfNet.csproj",
"expectedPackageFiles": [
Expand Down
6 changes: 3 additions & 3 deletions QpdfNetTest/bin/Release/net6.0/QpdfNetTest.deps.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"MSTest.TestFramework": "2.2.9",
"Microsoft.Extensions.Logging": "6.0.0",
"Microsoft.NET.Test.Sdk": "17.1.0",
"QPdfNet": "1.0.3",
"QPdfNet": "1.0.4",
"coverlet.collector": "3.1.2"
},
"runtime": {
Expand Down Expand Up @@ -1072,7 +1072,7 @@
"System.Xml.ReaderWriter": "4.3.0"
}
},
"QPdfNet/1.0.3": {
"QPdfNet/1.0.4": {
"dependencies": {
"Microsoft.Extensions.Logging": "6.0.0",
"Newtonsoft.Json": "13.0.1"
Expand Down Expand Up @@ -1733,7 +1733,7 @@
"path": "system.xml.xdocument/4.3.0",
"hashPath": "system.xml.xdocument.4.3.0.nupkg.sha512"
},
"QPdfNet/1.0.3": {
"QPdfNet/1.0.4": {
"type": "project",
"serviceable": false,
"sha512": ""
Expand Down
2 changes: 1 addition & 1 deletion QpdfNetTest/obj/QpdfNetTest.csproj.nuget.dgspec.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
}
},
"C:\\Kees\\QPdfNet\\QPdfNet\\QPdfNet.csproj": {
"version": "1.0.4",
"version": "1.0.5",
"restore": {
"projectUniqueName": "C:\\Kees\\QPdfNet\\QPdfNet\\QPdfNet.csproj",
"projectName": "QPdfNet",
Expand Down
Binary file not shown.
6 changes: 3 additions & 3 deletions QpdfNetTest/obj/project.assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -1666,7 +1666,7 @@
"lib/netstandard1.3/System.Xml.XDocument.dll": {}
}
},
"QPdfNet/1.0.4": {
"QPdfNet/1.0.5": {
"type": "project",
"framework": ".NETStandard,Version=v2.1",
"dependencies": {
Expand Down Expand Up @@ -6167,7 +6167,7 @@
"system.xml.xdocument.nuspec"
]
},
"QPdfNet/1.0.4": {
"QPdfNet/1.0.5": {
"type": "project",
"path": "../QPdfNet/QPdfNet.csproj",
"msbuildProject": "../QPdfNet/QPdfNet.csproj"
Expand All @@ -6179,7 +6179,7 @@
"MSTest.TestFramework >= 2.2.9",
"Microsoft.Extensions.Logging >= 6.0.0",
"Microsoft.NET.Test.Sdk >= 17.1.0",
"QPdfNet >= 1.0.4",
"QPdfNet >= 1.0.5",
"coverlet.collector >= 3.1.2"
]
},
Expand Down
Loading

0 comments on commit fe32ec1

Please sign in to comment.